Migrate vimrc to Vim9 script
This commit is contained in:
parent
a17be94d77
commit
ca41e40e6a
1 changed files with 12 additions and 5 deletions
17
vimrc
17
vimrc
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue