-source $VIMRUNTIME/defaults.vim
-
+" use our new vim dir primarily
let x = ($XDG_CONFIG_HOME??($HOME.'/.config')).'/vim'
execute 'set runtimepath='.x.','.&runtimepath.','.x.'/after'
execute 'set packpath='.x.','.&packpath.','.x.'/after'
-packadd matchit
+if !has('nvim')
+ " neovim doesn't have defaults to load explicitly
+ source $VIMRUNTIME/defaults.vim
+
+ " neovim does this stuff already
+ packadd matchit
+ packadd editorconfig
+
+ set autoindent
+endif
+" define and create a centralized dir to keep transient state files in
let x = ($XDG_STATE_HOME??($HOME.'/.local/state')).'/vim'
if !isdirectory(x)
call mkdir(x, 'p', 0700)
endif
-execute 'set viminfofile='.x.'/.viminfo'
-
-let y = x.'/swap'
-if !isdirectory(y)
- call mkdir(y, 'p', 0700)
-endif
-execute 'set directory='.y.'//'
let y = x.'/backup'
if !isdirectory(y)
call mkdir(y, 'p', 0700)
endif
-set backup
execute 'set backupdir='.y.'//'
-set backupcopy=yes
+set backup backupcopy=yes
-let y = x.'/undo'
-if !isdirectory(y)
- call mkdir(y, 'p', 0700)
+
+" NOTE: neovim uses ShaDa (SHAred DAta) format for viminfo and swap, and uses a
+" different version for undo files, so these types of files when created
+" by vim cannot be used with neovim, and the 'viminfofile', 'directory',
+" and 'undodir' directories cannot be shared.
+" NOTE: neovim has a nice default for these directories and files so
+" customizing them is not necessary for it.
+if !has('nvim')
+ " NOTE: 'viminfofile' is a deprecated alias for 'shada' in neovim
+ execute 'set viminfofile='.x.'/.viminfo'
+
+ let y = x.'/swap'
+ if !isdirectory(y)
+ call mkdir(y, 'p', 0700)
+ endif
+ execute 'set directory='.y.'//'
+
+ let y = x.'/undo'
+ if !isdirectory(y)
+ call mkdir(y, 'p', 0700)
+ endif
+ execute 'set undodir='.y.'//'
endif
-set undofile
-execute 'set undodir='.y.'//'
+
+autocmd BufNew * set undofile
unlet x
unlet y
-set autoindent
-set colorcolumn=80
-highlight ColorColumn term=NONE ctermbg=0
-autocmd FileType python setlocal softtabstop=4 shiftwidth=4 expandtab
-autocmd FileType markdown setlocal softtabstop=4 shiftwidth=4 expandtab
-autocmd FileType javascript setlocal softtabstop=2 shiftwidth=2 expandtab
-autocmd FileType json setlocal softtabstop=2 shiftwidth=2 expandtab
-autocmd FileType html setlocal softtabstop=2 shiftwidth=2 expandtab
-autocmd FileType todo setlocal colorcolumn=0
-
-set cursorline
+" options
+autocmd VimEnter,WinNew * set number
+autocmd VimEnter,WinNew * set relativenumber
+autocmd InsertEnter * set norelativenumber
+autocmd InsertLeave * set relativenumber
+autocmd FocusLost * set norelativenumber
+autocmd FocusGained * set relativenumber
+
+autocmd VimEnter,WinNew * set colorcolumn=80
+autocmd VimEnter,WinNew * set cursorline
set hlsearch
-set list
+
+autocmd VimEnter,WinNew * set list
set listchars=tab:├─,extends:»,precedes:«,space:·,trail:∙,nbsp:■
-set number
-set relativenumber
-autocmd InsertEnter * setlocal norelativenumber
-autocmd InsertLeave * setlocal relativenumber
-autocmd FocusLost * setlocal norelativenumber
-autocmd FocusGained * setlocal relativenumber
-highlight WhiteSpaceBol ctermfg=DarkBlue
+
+" styles
+highlight ColorColumn term=NONE ctermbg=0
+
highlight WhiteSpaceMol ctermfg=Black
-autocmd BufEnter * match WhiteSpaceMol / /
-autocmd BufEnter * 2match WhiteSpaceBol /\(^ \+\)\|\( \+$\)/
+autocmd VimEnter,WinNew * match WhiteSpaceMol / /
+highlight WhiteSpaceBol ctermfg=DarkBlue
+autocmd VimEnter,WinNew * 2match WhiteSpaceBol /\(^ \+\)\|\( \+$\)/
+" indent
+autocmd FileType python set softtabstop=4 shiftwidth=4 expandtab
+autocmd FileType markdown set softtabstop=4 shiftwidth=4 expandtab
+autocmd FileType javascript set softtabstop=2 shiftwidth=2 expandtab
+autocmd FileType json set softtabstop=2 shiftwidth=2 expandtab
+autocmd FileType html set softtabstop=2 shiftwidth=2 expandtab
let g:EditorConfig_enable_for_new_buf = 1
+
+" syntax
+autocmd FileType todo set colorcolumn=0