diff options
Diffstat (limited to 'vim/autoload/xdg.vim')
-rw-r--r-- | vim/autoload/xdg.vim | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/vim/autoload/xdg.vim b/vim/autoload/xdg.vim new file mode 100644 index 00000000..ab756f73 --- /dev/null +++ b/vim/autoload/xdg.vim @@ -0,0 +1,35 @@ +function! xdg#CacheDir(name) abort + let name = a:name + let home = exists('$XDG_CACHE_HOME') + \ ? $XDG_CACHE_HOME + \ : '~/.cache' + return join([home, name], '/') +endfunction + +function! xdg#ConfigDirs(name) abort + let name = a:name + let home = exists('$XDG_CONFIG_HOME') + \ ? $XDG_CONFIG_HOME + \ : '~/.config' + let dirs = exists('$XDG_CONFIG_DIRS') + \ ? split($XDG_CONFIG_DIRS, ':') + \ : [] + return map( + \ insert(dirs, home) + \,'join([v:val, name], "/")' + \) +endfunction + +function! xdg#DataDirs(name) abort + let name = a:name + let home = exists('$XDG_DATA_HOME') + \ ? $XDG_DATA_HOME + \ : '~/.local/share' + let dirs = exists('$XDG_DATA_DIRS') + \ ? split($XDG_DATA_DIRS, ':') + \ : [] + return map( + \ insert(dirs, home) + \,'join([v:val, name], "/")' + \) +endfunction |