diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2020-05-16 03:43:41 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2020-05-16 03:43:41 +1200 |
commit | ba9ea13e821538309c8979a1a322d97bfde45244 (patch) | |
tree | c39b07efc6e7893172d5c01d800468cc1c4d9269 /vim/autoload/xdg.vim | |
parent | Merge branch 'hotfix/v8.37.2' (diff) | |
parent | Bump VERSION (diff) | |
download | dotfiles-ba9ea13e821538309c8979a1a322d97bfde45244.tar.gz dotfiles-ba9ea13e821538309c8979a1a322d97bfde45244.zip |
Merge branch 'release/v8.38.0'v8.38.0
* release/v8.38.0:
Update updated date in vimrc
Correct some poor writing
Bail from Vim if &runtimepath is empty
Write out over-engineered path creation function
Switch XDG semantics to functions not global var
Simplify Vim XDG subdir definition
Use $HOME not tildes for XDG basedir defaults
Add an issue with syntax highlighting
Add an issue
Diffstat (limited to 'vim/autoload/xdg.vim')
-rw-r--r-- | vim/autoload/xdg.vim | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/vim/autoload/xdg.vim b/vim/autoload/xdg.vim index 5cef0f98..c5737506 100644 --- a/vim/autoload/xdg.vim +++ b/vim/autoload/xdg.vim @@ -1,14 +1,12 @@ " <https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html#variables> let s:defaults = { - \ 'XDG_CACHE_HOME': '~/.cache', - \ 'XDG_CONFIG_HOME': '~/.config', + \ 'XDG_CACHE_HOME': $HOME.'/.cache', + \ 'XDG_CONFIG_HOME': $HOME.'/.config', \ 'XDG_CONFIG_DIRS': '/etc/xdg', - \ 'XDG_DATA_HOME': '~/.local/share', + \ 'XDG_DATA_HOME': $HOME.'/.local/share', \ 'XDG_DATA_DIRS': '/usr/local/share:/usr/share', \} -let s:subdir = 'vim' - function! s:Get(name) abort let name = a:name if !has_key(s:defaults, name) @@ -31,27 +29,33 @@ function! s:Home(name) abort if !s:Absolute(home) return '' endif - return join([home, s:subdir], '/') + return home.'/vim' endfunction function! s:Dirs(name) abort let dirs = split(s:Get(a:name), ':') return map( \ filter(copy(dirs), 's:Absolute(v:val)') - \,'join([v:val, s:subdir], "/")' + \,'v:val.''/vim''' \) endfunction -let xdg# = { - \ 'cache': { - \ 'home': s:Home('XDG_CACHE_HOME'), - \ }, - \ 'config': { - \ 'home': s:Home('XDG_CONFIG_HOME'), - \ 'dirs': s:Dirs('XDG_CONFIG_DIRS'), - \ }, - \ 'data': { - \ 'home': s:Home('XDG_DATA_HOME'), - \ 'dirs': s:Dirs('XDG_DATA_DIRS'), - \ }, - \} +function! xdg#CacheHome() abort + return s:Home('XDG_CACHE_HOME') +endfunction + +function! xdg#ConfigHome() abort + return s:Home('XDG_CONFIG_HOME') +endfunction + +function! xdg#DataHome() abort + return s:Home('XDG_DATA_HOME') +endfunction + +function! xdg#ConfigDirs() abort + return s:Dirs('XDG_CONFIG_DIRS') +endfunction + +function! xdg#DataDirs() abort + return s:Dirs('XDG_DATA_DIRS') +endfunction |