Convert vim config to XDG standard

https://blog.joren.ga/configuring/vim-xdg
main
Buddy Sandidge 4 years ago
parent 899676b529
commit b02c8b9391

@ -0,0 +1,3 @@
# shellcheck disable=SC2016,SC2034
VIMINIT='if !has("nvim") | source $XDG_CONFIG_HOME/vim/vimrc | endif'
MYVIMRC='$XDG_CONFIG_HOME/vim/vimrc'

@ -0,0 +1,21 @@
if empty($MYVIMRC) | let $MYVIMRC = expand('%:p') | endif
if empty($XDG_CACHE_HOME) | let $XDG_CACHE_HOME = $HOME.'/.cache' | endif
if empty($XDG_CONFIG_HOME) | let $XDG_CONFIG_HOME = $HOME.'/.config' | endif
if empty($XDG_DATA_HOME) | let $XDG_DATA_HOME = $HOME.'/.local/share' | endif
set runtimepath^=$XDG_CONFIG_HOME/vim
set runtimepath+=$XDG_CONFIG_HOME/vim/after
set runtimepath+=$XDG_DATA_HOME/vim
set packpath^=$XDG_DATA_HOME/vim
call mkdir($XDG_DATA_HOME.'/vim/spell', 'p', 0700)
set backupdir=$XDG_CACHE_HOME/vim/backup | call mkdir(&backupdir, 'p', 0700)
set directory=$XDG_CACHE_HOME/vim/swap | call mkdir(&directory, 'p', 0700)
set undodir=$XDG_CACHE_HOME/vim/undo | call mkdir(&undodir, 'p', 0700)
set viewdir=$XDG_CACHE_HOME/vim/view | call mkdir(&viewdir, 'p', 0700)
if !has('nvim')
set viminfofile=$XDG_CACHE_HOME/vim/viminfo
endif

@ -1,15 +1,15 @@
" Load from init.d instead of plugin directory. This is done so a leader key
" can be set before loading plugin settings. This allows the plugin setting
" files to set mappings with leader keys
for f in split(glob('~/.vim/init.d/*.vim'), '\n')
for f in split(glob($XDG_CONFIG_HOME.'/vim/init.d/*.vim'), '\n')
exe 'source' f
endfor
" The plugged plugin manager function calls need to be called between the
" plug#begin and plug#end. Because of that, using the normal plugin directory
" loading won't work.
call plug#begin('~/.vim/plugged')
for f in split(glob('~/.vim/plug.d/*.vim'), '\n')
call plug#begin($XDG_DATA_HOME.'/vim/plugged')
for f in split(glob($XDG_CONFIG_HOME.'/vim/plug.d/*.vim'), '\n')
exe 'source' f
endfor
call plug#end()
Loading…
Cancel
Save