From 3ad4f7d72b74da2a2f3480c719c1270588a1135e Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Sun, 3 Jan 2021 23:37:13 +0100 Subject: [PATCH] vim: replace vim with neovim --- bootstrap | 27 +++++++++++---------- files/bashrc | 7 +++--- files/gitconfig | 1 - files/{vimrc => init.vim} | 51 ++++++++++++++------------------------- 4 files changed, 35 insertions(+), 51 deletions(-) rename files/{vimrc => init.vim} (83%) diff --git a/bootstrap b/bootstrap index fdcd972..c0b7a2c 100755 --- a/bootstrap +++ b/bootstrap @@ -20,14 +20,15 @@ ${XDG_CONFIG_HOME}/mintty ${XDG_CONFIG_HOME}/python ${XDG_CONFIG_HOME}/readline ${XDG_CONFIG_HOME}/tmux -${XDG_CONFIG_HOME}/vim -${XDG_CONFIG_HOME}/vim/autoload +${XDG_CONFIG_HOME}/nvim +${XDG_CONFIG_HOME}/nvim/autoload ${XDG_DATA_HOME}/bash ${XDG_DATA_HOME}/bash-completion/completions ${XDG_DATA_HOME}/less ${XDG_DATA_HOME}/python -${XDG_DATA_HOME}/vim -${XDG_DATA_HOME}/vim/plugged +${XDG_DATA_HOME}/nvim +${XDG_DATA_HOME}/nvim/plugged +${XDG_DATA_HOME}/nvim/shada EOF ) @@ -40,11 +41,11 @@ files/gitconfig ${XDG_CONFIG_HOME}/git/config files/gitignore ${XDG_CONFIG_HOME}/git/ignore files/inputrc ${XDG_CONFIG_HOME}/readline/inputrc files/minttyrc ${XDG_CONFIG_HOME}/mintty/config -files/plug.vim ${XDG_CONFIG_HOME}/vim/autoload/plug.vim +files/plug.vim ${XDG_CONFIG_HOME}/nvim/autoload/plug.vim files/python-startup.py ${XDG_CONFIG_HOME}/python/startup.py files/tmux-colors.conf ${XDG_CONFIG_HOME}/tmux/tmux-colors.conf files/tmux.conf ${XDG_CONFIG_HOME}/tmux/tmux.conf -files/vimrc ${XDG_CONFIG_HOME}/vim/vimrc +files/init.vim ${XDG_CONFIG_HOME}/nvim/init.vim EOF ) @@ -172,13 +173,13 @@ task_make_logins_silent() { file_touch "$HOME/.hushlogin" } -task_install_vim_plugins() { - heading "Install vim plugins" - if command -v vim >/dev/null 2>&1; then - warn "Installing vim plugins" - $DRY_RUN || vim -nes -u "$XDG_CONFIG_HOME/vim/vimrc" -c 'PlugInstall | qall!' +task_install_nvim_plugins() { + heading "Install neovim plugins" + if command -v nvim >/dev/null 2>&1; then + warn "Installing neovim plugins" + $DRY_RUN || nvim -nes -u "$XDG_CONFIG_HOME/nvim/init.vim" -c 'PlugInstall | qall!' else - error "vim is not installed; skipping plugin installation..." + error "neovim is not installed; skipping plugin installation..." fi } @@ -191,7 +192,7 @@ main() { task_link_local_commands task_link_dircolors task_make_logins_silent - task_install_vim_plugins + task_install_nvim_plugins } main diff --git a/files/bashrc b/files/bashrc index 0e46c31..2ac615a 100644 --- a/files/bashrc +++ b/files/bashrc @@ -12,7 +12,7 @@ export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}" export BACKGROUND="dark" -export EDITOR="vim" +export EDITOR="nvim" export INPUTRC="$XDG_CONFIG_HOME/readline/inputrc" export LANG="en_US.UTF-8" export LANGUAGE="en_US" @@ -27,8 +27,6 @@ MANPATH="$(unset MANPATH; manpath)" export MANPATH export PAGER=less export PYTHONSTARTUP="$XDG_CONFIG_HOME/python/startup.py" -# shellcheck disable=SC2016 # This expression is to be interpreted by vim, not bash. -export VIMINIT='let $MYVIMRC="$XDG_CONFIG_HOME/vim/vimrc" | source $MYVIMRC' # Prevent path_helper from messing with the PATH when starting tmux. # See: https://superuser.com/a/583502 @@ -172,7 +170,8 @@ alias lla="la -l" command -v colorman >/dev/null && alias man=colorman alias g='git' -alias v='vim' +alias v='nvim' +alias vim='nvim' alias grep="grep --color=auto" alias egrep="egrep --color=auto" diff --git a/files/gitconfig b/files/gitconfig index dd2daae..979e8e3 100644 --- a/files/gitconfig +++ b/files/gitconfig @@ -46,7 +46,6 @@ [core] excludesfile = ~/.config/git/ignore - editor = vim trustctime = false # http://www.git-tower.com/blog/make-git-rebase-safe-on-osx/ pager = less -F -X diff --git a/files/vimrc b/files/init.vim similarity index 83% rename from files/vimrc rename to files/init.vim index 6af7142..827b3e7 100644 --- a/files/vimrc +++ b/files/init.vim @@ -1,15 +1,9 @@ -set nocompatible - if $XDG_CONFIG_HOME == "" | let $XDG_CONFIG_HOME="~/.config" | endif if $XDG_CACHE_HOME == "" | let $XDG_CACHE_HOME="~/.cache" | endif if $XDG_DATA_HOME == "" | let $XDG_DATA_HOME="~/.local/share" | endif if $LOCAL_CONFIG == "" | let $LOCAL_CONFIG="~/.local/etc" | endif -let $MYVIMRC="$XDG_CONFIG_HOME/vim/vimrc" - " Options {{{ -set autoindent " take indent for new line from previous line -set autoread " autom. read file when changed outside of Vim let &background = $BACKGROUND ==? 'light' ? 'light' : 'dark' set backspace=indent,eol,start " sane backspace behavior set nobackup " don't keep backup file after overwriting a file @@ -17,7 +11,6 @@ set clipboard=unnamed " synchronize with system clipboard set colorcolumn=+1 " highlight column after 'textwidth' set cursorline " highlight the line of the cursor set diffopt=filler,vertical " make side-by-side diffs better -set encoding=utf8 " use UTF-8 by default set expandtab " use spaces whe is inserted set fileformats=unix,mac,dos " prioritize unix format set foldenable " enable folding @@ -30,55 +23,47 @@ set formatoptions+=c " do auto-wrap comments on 'textwidth' set formatoptions+=j " remove comment leader when joining lings set formatoptions+=n " recognize and indent lists automatically set hidden " hide abandoned buffers -set history=1000 " how many ":" commands to remember -set hlsearch " highlight search results set ignorecase " ignore case when searching (see 'smartcase' below) -set incsearch " use incremental search set nojoinspaces " use one space after a period whe joining lines -set laststatus=2 " always show a status line set lazyredraw " don't redraw screen when executing macros set list " show invisible characters set listchars=tab:>~,extends:>,precedes:<,trail:- " invisible chars set modelines=0 " never use modelines set number " show line numbers set nrformats-=octal " number formats for CTRL-A & CTRL-X commands -set runtimepath=$XDG_CONFIG_HOME/vim,$VIMRUNTIME " so vim-plug can work set scrolloff=3 " minimum number of lines above and below cursor set shiftwidth=0 " use 'tabstop' spaces for (auto)indent step set shortmess+=I " don't show the intro message when starting Vim set showbreak="-> " " prefix for wrapped lines set showmatch " briefly jump to matching bracket if insert one set noshowmode " don't show mode (using airline instead) -set sidescroll=1 " minimum number of columns to scroll horizontal set sidescrolloff=3 " min. number of columns to left and right of cursor set smartcase " case sensitive search if pattern has uppercase chars set smartindent " use smart autoindenting -set smarttab " use 'shiftwidth' when inserting set splitbelow " new window from split is below the current one set splitright " new window is put right of the current one set noswapfile " don't use swap files set tabstop=4 " tabs are 4 spaces set textwidth=79 " maximum width for text being inserted set timeout timeoutlen=1000 ttimeoutlen=100 " timeout on mappings & key codes -set ttyfast " indicate a fast terminal for smoother redrawing - " +--Disable hlsearch while loading viminfo - " | +--Remember marks for last 500 files - " | | +--Remember up to 10000 lines in each register - " | | | +--Remember up to 1MB in each register - " | | | | +--Remember last 1000 search patterns - " | | | | | +---Remember last 1000 commands - " | | | | | | - " v v v v v v -set viminfo=h,'500,<10000,s1000,/1000,:1000 -set viminfofile=$XDG_DATA_HOME/vim/viminfo set virtualedit=block " position the cursor anywhere in Visual Block mode set wildignore=*.o,*.obj,*.pyc,*.exe,*.so,*.dll set wildignorecase " ignore case when completing file names -set wildmenu " show wildmenu after list (see 'wildmode') set wildmode=longest,list,full " complete longest common, then list, then wildmenu set wrap " wrap long lines set writebackup " make a backup before overwriting a file + " +--Disable hlsearch while loading viminfo + " | +--Remember marks for last 100 files + " | | +--Remember up to 1000 lines in each register + " | | | +--Remember up to 1MB in each register + " | | | | +--Remember last 1000 search patterns + " | | | | | +---Remember last 1000 commands + " | | | | | | +-- name of shared data file + " | | | | | | | + " v v v v v v v +set shada=h,'100,<1000,s1000,/1000,:1000,n$XDG_DATA_HOME/nvim/shada/main.shada + " Overrides when UTF-8 is available if has('multi_byte') && &encoding ==? 'utf-8' set fillchars=vert:┃,fold:· @@ -88,7 +73,7 @@ endif " }}} " Plugins {{{ -call plug#begin('$XDG_DATA_HOME/vim/plugged') +call plug#begin('$XDG_DATA_HOME/nvim/plugged') Plug 'altercation/vim-colors-solarized' Plug 'bronson/vim-trailing-whitespace' Plug 'elzr/vim-json' @@ -144,10 +129,7 @@ call plug#begin('$XDG_DATA_HOME/vim/plugged') Plug 'chr4/nginx.vim' call plug#end() - silent! colorscheme solarized -filetype plugin indent on -syntax enable " }}} " Functions {{{ @@ -226,16 +208,19 @@ augroup vimrc " {{{ autocmd BufNewFile,BufRead gitconfig set filetype=gitconfig autocmd BufNewFile,BufRead *.sx,*.s19 set filetype=srec autocmd BufNewFile,BufRead Vagrantfile set filetype=ruby - autocmd BufNewFile,BufRead vimrc set foldmethod=marker + autocmd BufNewFile,BufRead init.vim set foldmethod=marker autocmd FileType python setlocal foldmethod=indent foldignore= autocmd FileType markdown,text,gitcommit setlocal formatoptions+=t spell autocmd FileType gitcommit setlocal textwidth=72 - autocmd BufWritePost vimrc source % + " Disable cursorline in INSERT mode. + autocmd InsertEnter,InsertLeave * set cursorline! + + autocmd BufWritePost init.vim source % augroup END " }}} -for extra_vimrc in expand("$LOCAL_CONFIG/vim/*", v:none, v:true) +for extra_vimrc in expand("$LOCAL_CONFIG/nvim/*", v:false, v:true) if filereadable(extra_vimrc) exec "source " . extra_vimrc endif