aboutsummaryrefslogtreecommitdiff
path: root/vim/autoload
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2020-04-25 19:25:36 +1200
committerTom Ryder <tom@sanctum.geek.nz>2020-04-25 19:25:36 +1200
commitc9bc019da06f443b69cac5507594bd8b0d8e2a99 (patch)
tree662baffa1eeb6c1a66e3ec15e4ed8293ad8b3635 /vim/autoload
parentRoll out the beginnings of XDG support for Vim (diff)
downloaddotfiles-c9bc019da06f443b69cac5507594bd8b0d8e2a99.tar.gz
dotfiles-c9bc019da06f443b69cac5507594bd8b0d8e2a99.zip
Include XDG_{CONFIG,DATA}_DIRS handling in Vim
This obsoletes custom $MYVIM variables.
Diffstat (limited to 'vim/autoload')
-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