From dfe6dfe212e38d830d017a05fa7a3428bc9cad86 Mon Sep 17 00:00:00 2001 From: Gal Szkolnik Date: Thu, 9 Jun 2022 14:22:39 -0400 Subject: [PATCH] Cleanup vi support --- _home/dot_sz.shrc.d/22_editor.aliases | 34 +++++++++++++------------ _home/private_dot_config/nvim/init.vim | 35 +++++++++++++++----------- 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/_home/dot_sz.shrc.d/22_editor.aliases b/_home/dot_sz.shrc.d/22_editor.aliases index 8c83b85..dc05560 100644 --- a/_home/dot_sz.shrc.d/22_editor.aliases +++ b/_home/dot_sz.shrc.d/22_editor.aliases @@ -1,3 +1,16 @@ +PREFERED_VI=$(type -fP nvim vim | head -1) +if [[ -z "$PREFERED_VI" ]]; then + PREFERED_VI=$(type -fP vi | head -1) + + if [[ -z "$PREFERED_VI" ]]; then + alias my_vi='eval $EDITOR ' + else + alias my_vi="$PREFERED_VI" + fi +else + alias my_vi="$PREFERED_VI -p" +fi + if [[ -r "$HOME/.config/_my.emacs/spacemacs/emacs.d/init.el" \ && -n "$(type -fP emacsclient)" \ && -n "$(type -fP emacs)" \ @@ -5,23 +18,12 @@ if [[ -r "$HOME/.config/_my.emacs/spacemacs/emacs.d/init.el" \ ]]; then alias my_editor='edit-with-spacemacs' else - PREFERED_VI=$(type -fP nvim vim | head -1) - if [[ -z "$PREFERED_VI" ]]; then - PREFERED_VI=$(type -fP vi | head -1) - - if [[ -z "$PREFERED_VI" ]]; then - alias my_editor='eval $EDITOR ' - else - alias my_editor="$PREFERED_VI" - fi - else - alias my_editor="$PREFERED_VI -p" - fi + alias my_editor='my_vi' fi -alias nvim="my_editor" -alias vim="my_editor" -alias vi="my_editor" +alias nvim="my_vi" +alias vim="my_vi" +alias vi="my_vi" alias ed="my_editor" alias edit="my_editor" -alias editor="my_editor" \ No newline at end of file +alias editor="my_editor" diff --git a/_home/private_dot_config/nvim/init.vim b/_home/private_dot_config/nvim/init.vim index 7fa8dd1..41f9c3a 100644 --- a/_home/private_dot_config/nvim/init.vim +++ b/_home/private_dot_config/nvim/init.vim @@ -1,19 +1,24 @@ set background=dark -" Install vim-plug if not found -let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim' -if empty(glob(data_dir . '/autoload/plug.vim')) - silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' - autocmd VimEnter * PlugInstall --sync | source $MYVIMRC + +if !has("compatible") + " Install vim-plug if not found + let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim' + if empty(glob(data_dir . '/autoload/plug.vim')) + silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' + autocmd VimEnter * PlugInstall --sync | source $MYVIMRC + endif + + " Run PlugInstall if there are missing plugins + autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)')) | PlugInstall --sync | source $MYVIMRC | endif + + " Plugins will be downloaded under the specified directory. + call plug#begin(has('nvim') ? stdpath('data') . '/plugged' : '~/.vim/plugged') + + " Declare the list of plugins. + Plug 'tpope/vim-sensible' + Plug 'junegunn/seoul256.vim' + + call plug#end() endif -" Run PlugInstall if there are missing plugins -autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)')) | PlugInstall --sync | source $MYVIMRC | endif -" Plugins will be downloaded under the specified directory. -call plug#begin(has('nvim') ? stdpath('data') . '/plugged' : '~/.vim/plugged') - -" Declare the list of plugins. -Plug 'tpope/vim-sensible' -Plug 'junegunn/seoul256.vim' - -call plug#end()