Migrate vimrc to Vim9 script

This commit is contained in:
Danielle McLean 2022-07-02 16:49:40 +10:00
parent a17be94d77
commit ca41e40e6a
Signed by: 00dani
GPG key ID: 52C059C3B22A753E

17
vimrc
View file

@ -1,6 +1,13 @@
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'}) vim9script
if (empty(eval('$' . s:var))) const xdg = {
exec 'let $' . s:var . ' = expand(s:value)' XDG_CONFIG_HOME: '~/.config',
XDG_CACHE_HOME: '~/.cache',
XDG_DATA_HOME: '~/.local/share',
XDG_STATE_HOME: '~/.local/state',
}
for [key, default] in items(xdg)
if !has_key(environ(), key)
setenv(key, expand(default))
endif endif
endfor endfor
@ -9,7 +16,7 @@ set viminfo+=n$XDG_STATE_HOME/vim/viminfo
if exists('+packpath') if exists('+packpath')
set packpath^=$XDG_CONFIG_HOME/vim,$XDG_CACHE_HOME/vim set packpath^=$XDG_CONFIG_HOME/vim,$XDG_CACHE_HOME/vim
endif endif
let g:netrw_home = $XDG_CACHE_HOME . '/vim/netrw' g:netrw_home = $XDG_CACHE_HOME .. '/vim/netrw'
let $MYVIMRC = $XDG_CONFIG_HOME . '/vim/init.vim' $MYVIMRC = $XDG_CONFIG_HOME .. '/vim/init.vim'
source $MYVIMRC source $MYVIMRC