vim/vimrc
Danielle McLean ad496a7745
Support the XDG_STATE_HOME directory
It's a better place to store most of the stuff Vim wants to store lying
around on the filesystem than XDG_CACHE_HOME, it turns out? I'm still
keeping installed packages primarily in XDG_CACHE_HOME, since if that
directory is blown away then the same packages just get reinstalled
automatically and nothing particularly important is lost, but the other
stuff doesn't really belong in there.

Undo files, viminfo, and so on are definitely a good example of "state
data that should be persisted between (application) restarts, but that
is not important or portable enough to the user that it should be stored
in XDG_DATA_HOME", so XDG_STATE_HOME is a fine place for them.
2021-09-22 10:35:51 +10:00

15 lines
662 B
VimL

for [s:var, s:value] in items({'XDG_CONFIG_HOME': '~/.config', 'XDG_CACHE_HOME': '~/.cache', 'XDG_DATA_HOME': '~/.local/share', 'XDG_STATE_HOME': '~/.local/state'})
if (empty(eval('$' . s:var)))
exec 'let $' . s:var . ' = expand(s:value)'
endif
endfor
set runtimepath=$XDG_CONFIG_HOME/vim,$XDG_CACHE_HOME/vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$XDG_CONFIG_HOME/vim/after,$XDG_CACHE_HOME/vim/after
set viminfo+=n$XDG_STATE_HOME/vim/viminfo
if exists('+packpath')
set packpath^=$XDG_CONFIG_HOME/vim,$XDG_CACHE_HOME/vim
endif
let g:netrw_home = $XDG_CACHE_HOME . '/vim/netrw'
let $MYVIMRC = $XDG_CONFIG_HOME . '/vim/init.vim'
source $MYVIMRC