aboutsummaryrefslogtreecommitdiff
path: root/vim
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2020-05-24 22:04:11 +1200
committerTom Ryder <tom@sanctum.geek.nz>2020-05-24 22:04:11 +1200
commit360f270b4226649d09782646f09daf8618680039 (patch)
tree0beb8f426bfd7fc05d6f5489318cc2f7910a2ee9 /vim
parentRewrite and rewrap a comment block in vimrc (diff)
downloaddotfiles-360f270b4226649d09782646f09daf8618680039.tar.gz
dotfiles-360f270b4226649d09782646f09daf8618680039.zip
Cache XDG values in vimrc
I'm still not entirely happy with this, but not quite sure how else to handle it yet.
Diffstat (limited to 'vim')
-rw-r--r--vim/vimrc75
1 files changed, 40 insertions, 35 deletions
diff --git a/vim/vimrc b/vim/vimrc
index de11a3a3..f59fbc25 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -2,7 +2,7 @@
" Tom Ryder (tejr)’s Literate Vimrc
" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
"
-" Last updated: Thu, 21 May 2020 05:54:00 UTC
+" Last updated: Sun, 24 May 2020 10:00:15 UTC
"
" │ And I was lifted up in heart, and thought
" │ Of all my late-shown prowess in the lists,
@@ -128,14 +128,19 @@ let $MYVIM = option#Split(&runtimepath)[0]
" $MYVIM, per the above. We're just leaning on XDG’s conventions to provide
" separate locations for cache files and other configuration.
"
-
" We'll start by retrieving the list of valid paths for configuration from
" both the XDG_CONFIG_HOME and XDG_CONFIG_DIRS variables, or from their
" defaults, using autoloaded xdg# functions.
"
-" We put XDG_CONFIG_HOME at the front of the list with insert(), provided it
-" isn't empty, which is what the function returns when the configured path
-" isn't absolute. This is per the standard's dictum:
+let s:xdgcachehome = xdg#CacheHome()
+let s:xdgconfigdirs = xdg#ConfigDirs()
+let s:xdgconfighome = xdg#ConfigHome()
+let s:xdgdatadirs = xdg#DataDirs()
+let s:xdgdatahome = xdg#DataHome()
+
+" We put XDG_CONFIG_HOME at the front of the 'runtimepath' list with insert(),
+" provided it isn't empty, which is what the function returns when the
+" configured path isn't absolute. This is per the standard's dictum:
"
" │ All paths set in these environment variables must be absolute. If an
" │ implementation encounters a relative path in any of these variables it
@@ -146,18 +151,18 @@ let $MYVIM = option#Split(&runtimepath)[0]
"
" Ours not to reason why…
"
-if xdg#ConfigHome() !=# '' || !empty(xdg#ConfigDirs())
+if s:xdgconfighome !=# '' || !empty(s:xdgconfigdirs)
execute 'set runtimepath^='.option#Escape(join(map(
\ extend(
- \ xdg#ConfigHome() !=# '' ? [xdg#ConfigHome()] : [],
- \ xdg#ConfigDirs()
+ \ s:xdgconfighome !=# '' ? [s:xdgconfighome] : [],
+ \ s:xdgconfigdirs
\),
\ 'option#item#Escape(v:val)'
\), ','))
execute 'set runtimepath+='.option#Escape(join(map(
\ reverse(extend(
- \ xdg#ConfigHome() !=# '' ? [xdg#ConfigHome()] : [],
- \ xdg#ConfigDirs()
+ \ s:xdgconfighome !=# '' ? [s:xdgconfighome] : [],
+ \ s:xdgconfigdirs
\)),
\ 'option#item#Escape(v:val.''/after'')'
\), ','))
@@ -173,12 +178,12 @@ endif
" v8.1.716 introduced a way to set this with an option named 'viminfofile',
" but I don't see a reason to use that.
"
-if xdg#CacheHome() !=# ''
- if !isdirectory(xdg#CacheHome())
- call mkdir(xdg#CacheHome(), 'p', 0700)
+if s:xdgcachehome !=# ''
+ if !isdirectory(s:xdgcachehome)
+ call mkdir(s:xdgcachehome, 'p', 0700)
endif
execute 'set viminfo+='.option#Escape(
- \ 'n'.xdg#CacheHome().'/viminfo'
+ \ 'n'.s:xdgcachehome.'/viminfo'
\)
endif
@@ -225,12 +230,12 @@ set history=10000
" 'backupfullname', 'swapfilefullname' would have been clearer.
"
set backup
-if xdg#CacheHome() !=# ''
- if !isdirectory(xdg#CacheHome().'/backup')
- call mkdir(xdg#CacheHome().'/backup', 'p', 0700)
+if s:xdgcachehome !=# ''
+ if !isdirectory(s:xdgcachehome.'/backup')
+ call mkdir(s:xdgcachehome.'/backup', 'p', 0700)
endif
execute 'set backupdir^='.option#Escape(option#item#Escape(
- \ xdg#CacheHome().'/backup'.(has#('patch-8.1.251') ? '//' : '')
+ \ s:xdgcachehome.'/backup'.(has#('patch-8.1.251') ? '//' : '')
\))
endif
@@ -267,12 +272,12 @@ endif
" its name, in order to avoid filename collisions, since the 'directory'
" option has supported that hint for much longer than 'backupdir' has.
"
-if xdg#CacheHome() !=# ''
- if !isdirectory(xdg#CacheHome().'/swap')
- call mkdir(xdg#CacheHome().'/swap', 'p', 0700)
+if s:xdgcachehome !=# ''
+ if !isdirectory(s:xdgcachehome.'/swap')
+ call mkdir(s:xdgcachehome.'/swap', 'p', 0700)
endif
execute 'set directory^='.option#Escape(option#item#Escape(
- \ xdg#CacheHome().'/swap//'
+ \ s:xdgcachehome.'/swap//'
\))
endif
@@ -288,13 +293,13 @@ endif
" Support for these persistent undo file caches was not released until v7.3.0,
" so we need to check for the feature’s presence before we enable it.
"
-if xdg#CacheHome() !=# '' && has#('persistent_undo')
+if s:xdgcachehome !=# '' && has#('persistent_undo')
set undofile
- if !isdirectory(xdg#CacheHome().'/undo')
- call mkdir(xdg#CacheHome().'/undo', 'p', 0700)
+ if !isdirectory(s:xdgcachehome.'/undo')
+ call mkdir(s:xdgcachehome.'/undo', 'p', 0700)
endif
execute 'set undodir^='.option#Escape(option#item#Escape(
- \ xdg#CacheHome().'/undo//'
+ \ s:xdgcachehome.'/undo//'
\))
endif
@@ -303,12 +308,12 @@ endif
" directories of this type. This isn't a comma-separated list like the others
" ('backupdir', 'directory', 'spell', 'undodir')
"
-if xdg#CacheHome() !=# '' && has#('mksession')
- if !isdirectory(xdg#CacheHome().'/view')
- call mkdir(xdg#CacheHome().'/view', 'p', 0700)
+if s:xdgcachehome !=# '' && has#('mksession')
+ if !isdirectory(s:xdgcachehome.'/view')
+ call mkdir(s:xdgcachehome.'/view', 'p', 0700)
endif
execute 'set viewdir='.option#Escape(option#item#Escape(
- \ xdg#CacheHome().'/view'
+ \ s:xdgcachehome.'/view'
\))
endif
@@ -429,18 +434,18 @@ set spellcapcheck=[.?!]\\%(\ \ \\\|[\\n\\r\\t]\\)
" 'isfname'; the blacklist is hard-coded.
"
set dictionary^=/usr/share/dict/words
-if xdg#DataHome() !=# '' || !empty(xdg#DataDirs())
+if s:xdgdatahome !=# '' || !empty(s:xdgdatadirs)
execute 'set dictionary^='.option#Escape(join(map(
\ extend(
- \ xdg#DataHome() !=# '' ? [xdg#DataHome()] : [],
- \ xdg#DataDirs()
+ \ s:xdgdatahome !=# '' ? [s:xdgdatahome] : [],
+ \ s:xdgdatadirs
\),
\ 'option#item#Escape(v:val.''/dictionary.txt'')'
\), ','))
execute 'set thesaurus^='.option#Escape(join(map(
\ extend(
- \ xdg#DataHome() !=# '' ? [xdg#DataHome()] : [],
- \ xdg#DataDirs()
+ \ s:xdgdatahome !=# '' ? [s:xdgdatahome] : [],
+ \ s:xdgdatadirs
\),
\ 'option#item#Escape(v:val.''/thesaurus.txt'')'
\), ','))