aboutsummaryrefslogtreecommitdiff
path: root/vim/autoload/xdg.vim
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2020-04-25 19:34:14 +1200
committerTom Ryder <tom@sanctum.geek.nz>2020-04-25 19:34:14 +1200
commit0d1a44c4b4a8a3a8d25a6d3a433dfcd4f408e9f3 (patch)
tree5ab01f553a43bfe353d491614650a0b6d9682c1a /vim/autoload/xdg.vim
parentMerge branch 'release/v8.19.0' (diff)
parentBump VERSION (diff)
downloaddotfiles-0d1a44c4b4a8a3a8d25a6d3a433dfcd4f408e9f3.tar.gz
dotfiles-0d1a44c4b4a8a3a8d25a6d3a433dfcd4f408e9f3.zip
Merge branch 'release/v8.20.0'v8.20.0
* release/v8.20.0: Revert "Remove Vim :helptags generation" Remove Vim :helptags generation Include XDG_{CONFIG,DATA}_DIRS handling in Vim Roll out the beginnings of XDG support for Vim Remove thesaurus install target Correct built paths for Vim cache dirs Use explicitly nullglob Zsh patterns
Diffstat (limited to 'vim/autoload/xdg.vim')
-rw-r--r--vim/autoload/xdg.vim35
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