diff --git a/vim.fish b/vim.fish new file mode 100644 index 0000000..9594937 --- /dev/null +++ b/vim.fish @@ -0,0 +1,25 @@ +# This will avoid user defined aliases and possibly stuff defined earlier in the PATH. +# Redirecting is for the case when the binary is missing. +set vim_cond (which vim 2> /dev/null) +set vi_cond (which vi 2> /dev/null) + +switch "$vim_cond-$vi_cond" + case /usr/bin/vim-/usr/bin/vi + # apply only if founded vim and vi are in the expected dir from distro + function vi + command vim $argv + end + + function view + command vim -R $argv + end + case -/usr/bin/vi + # apply only when no vim is installed and founded vi is in the expected dir from distro + function vim + command read -p 'No vim found, using vi, press ENTER to continue' -n1 -t 20 -s && vi $argv + end +end + +# just in case +set -e vim_cond +set -e vi_cond diff --git a/vim.spec b/vim.spec index f696dc1..5f4c5f2 100644 --- a/vim.spec +++ b/vim.spec @@ -40,6 +40,7 @@ Source15: macros.vim Source16: vim-default-editor.sh Source17: vim-default-editor.csh Source18: vim-default-editor.fish +Source19: vim.fish Patch2002: vim-7.0-fixkeys.patch Patch2003: vim-7.4-specsyntax.patch @@ -546,6 +547,7 @@ install -p -m644 %{SOURCE16} %{buildroot}/%{_sysconfdir}/profile.d/vim-default-e install -p -m644 %{SOURCE17} %{buildroot}/%{_sysconfdir}/profile.d/vim-default-editor.csh mkdir -p %{buildroot}/%{_datadir}/fish/vendor_conf.d/ install -p -m644 %{SOURCE18} %{buildroot}/%{_datadir}/fish/vendor_conf.d/vim-default-editor.fish +install -p -m644 %{SOURCE19} %{buildroot}/%{_datadir}/fish/vendor_conf.d/vim.fish install -p -m644 %{SOURCE4} %{buildroot}/%{_sysconfdir}/virc install -p -m644 %{SOURCE5} %{buildroot}/%{_sysconfdir}/vimrc @@ -744,7 +746,9 @@ touch %{buildroot}/%{_datadir}/%{name}/vimfiles/doc/tags %endif %files minimal -%dir %{_sysconfdir}/profile.d/ +%dir %{_datadir}/fish/vendor_conf.d +%{_datadir}/fish/vendor_conf.d/vim.fish +%dir %{_sysconfdir}/profile.d %config(noreplace) %{_sysconfdir}/profile.d/vim.* %config(noreplace) %{_sysconfdir}/virc %{_bindir}/ex @@ -760,7 +764,9 @@ touch %{buildroot}/%{_datadir}/%{name}/vimfiles/doc/tags %{_mandir}/man5/virc.* %files enhanced -%dir %{_sysconfdir}/profile.d/ +%dir %{_datadir}/fish/vendor_conf.d +%{_datadir}/fish/vendor_conf.d/vim.fish +%dir %{_sysconfdir}/profile.d %config(noreplace) %{_sysconfdir}/profile.d/vim.* %{_bindir}/vim %{_bindir}/rvim @@ -824,6 +830,7 @@ touch %{buildroot}/%{_datadir}/%{name}/vimfiles/doc/tags * Thu Oct 15 2020 Zdenek Dohnal - 2:8.2.1815-2 - vim-default-editor.fish - dont give EDITOR universal scope - vim.sh, vim.csh - set aliases only for OS default vi and vim +- add fish profile for Vim * Mon Oct 12 2020 Zdenek Dohnal - 2:8.2.1815-2 - fix installing fish profile, set virtual provide for default editor