diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2022-06-30 00:42:55 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2022-06-30 00:42:55 +1200 |
commit | a340fb62cb9ef88d31f705933a65b2bffa2046c1 (patch) | |
tree | dbb224467716997e6aac5597d1db6a896458a267 /vim/vimrc | |
parent | Correct another typo in gtkrc filetype detection (diff) | |
download | dotfiles-a340fb62cb9ef88d31f705933a65b2bffa2046c1.tar.gz dotfiles-a340fb62cb9ef88d31f705933a65b2bffa2046c1.zip |
Return empty values for XDG on non-Unix
This saves a mess of conditions in vimrc.
Diffstat (limited to 'vim/vimrc')
-rw-r--r-- | vim/vimrc | 41 |
1 files changed, 18 insertions, 23 deletions
@@ -137,18 +137,16 @@ let $MYVIM = option#Split(&runtimepath)[0] " both the XDG_CONFIG_HOME and XDG_CONFIG_DIRS variables, or from their " defaults, using autoloaded xdg# functions. " -if has('unix') - let s:xdgconfigdirs - \ = xdg#ConfigDirs() - let s:xdgconfighome - \ = xdg#ConfigHome() - let s:xdgdatadirs - \ = xdg#DataDirs() - let s:xdgdatahome - \ = xdg#DataHome() - let s:xdgstatehome - \ = xdg#StateHome() -endif +let s:xdgconfigdirs + \ = xdg#ConfigDirs() +let s:xdgconfighome + \ = xdg#ConfigHome() +let s:xdgdatadirs + \ = xdg#DataDirs() +let s:xdgdatahome + \ = xdg#DataHome() +let s:xdgstatehome + \ = xdg#StateHome() " 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 @@ -163,8 +161,7 @@ endif " " Ours not to reason why... " -if exists('s:xdgconfighome') && s:xdgconfighome !=# '' - \ || exists('s:xdgconfigdirs') && !empty(s:xdgconfigdirs) +if s:xdgconfighome !=# '' || !empty(s:xdgconfigdirs) execute 'set runtimepath^='.option#Escape(join(map( \ extend( \ s:xdgconfighome !=# '' ? [s:xdgconfighome] : [], @@ -191,7 +188,7 @@ 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 exists('s:xdgstatehome') && s:xdgstatehome !=# '' +if s:xdgstatehome !=# '' if !isdirectory(s:xdgstatehome) call mkdir(s:xdgstatehome, 'p', 0700) endif @@ -241,7 +238,7 @@ set history=300 " 'backupfullname', 'swapfilefullname' would have been clearer. " set backup -if exists('s:xdgstatehome') && s:xdgstatehome !=# '' +if s:xdgstatehome !=# '' if !isdirectory(s:xdgstatehome.'/backup') call mkdir(s:xdgstatehome.'/backup', 'p', 0700) endif @@ -302,7 +299,7 @@ endif " its name, in order to avoid filename collisions, since the 'directory' " option has supported that hint for much longer than 'backupdir' has. " -if exists('s:xdgstatehome') && s:xdgstatehome !=# '' +if s:xdgstatehome !=# '' if !isdirectory(s:xdgstatehome.'/swap') call mkdir(s:xdgstatehome.'/swap', 'p', 0700) endif @@ -323,7 +320,7 @@ 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 exists('s:xdgstatehome') && s:xdgstatehome !=# '' && has('persistent_undo') +if s:xdgstatehome !=# '' && has('persistent_undo') set undofile if !isdirectory(s:xdgstatehome.'/undo') call mkdir(s:xdgstatehome.'/undo', 'p', 0700) @@ -338,7 +335,7 @@ endif " directories of this type. This isn't a comma-separated list like the others " ('backupdir', 'directory', 'spell', 'undodir') " -if exists('s:xdgstatehome') && s:xdgstatehome !=# '' && has('mksession') +if s:xdgstatehome !=# '' && has('mksession') if !isdirectory(s:xdgstatehome.'/view') call mkdir(s:xdgstatehome.'/view', 'p', 0700) endif @@ -445,8 +442,7 @@ endif " directory. " set dictionary^=/usr/share/dict/words -if exists('s:xdgdatahome') && s:xdgdatahome !=# '' - \ || exists('s:xdgdatadirs') && !empty(s:xdgdatadirs) +if s:xdgdatahome !=# '' || !empty(s:xdgdatadirs) execute 'set dictionary^='.option#Escape(join(map( \ extend( \ s:xdgdatahome !=# '' ? [s:xdgdatahome] : [], @@ -465,8 +461,7 @@ endif " WordNet and MyThes-1. I had to remove the first two metadata lines from " thesaurus.txt, as Vim appeared to interpret them as part of the body data. " -if exists('s:xdgdatahome') && s:xdgdatahome !=# '' - \ || exists('s:xdgdatadirs') && !empty(s:xdgdatadirs) +if s:xdgdatahome !=# '' || !empty(s:xdgdatadirs) execute 'set thesaurus^='.option#Escape(join(map( \ extend( \ s:xdgdatahome !=# '' ? [s:xdgdatahome] : [], |