diff options
Diffstat (limited to 'vim')
-rw-r--r-- | vim/autoload/getenv.vim | 17 | ||||
-rw-r--r-- | vim/autoload/patch.vim | 18 | ||||
-rw-r--r-- | vim/autoload/xdg.vim | 9 | ||||
-rw-r--r-- | vim/vimrc | 17 |
4 files changed, 29 insertions, 32 deletions
diff --git a/vim/autoload/getenv.vim b/vim/autoload/getenv.vim deleted file mode 100644 index 3b5f4c1b..00000000 --- a/vim/autoload/getenv.vim +++ /dev/null @@ -1,17 +0,0 @@ -" Backport getenv() from v8.1.1305, except return an empty string rather than -" v:null -" -" <https://github.com/vim/vim/releases/tag/v8.1.1305> -" -function! getenv#(name) abort - - if a:name !~# '^[A-Z][A-Z0-9_]*$' - throw 'Illegal env var name' - endif - let value = '' - if exists('$'.a:name) - execute 'let value = $'.a:name - endif - return value - -endfunction diff --git a/vim/autoload/patch.vim b/vim/autoload/patch.vim index 614be462..3a17ccda 100644 --- a/vim/autoload/patch.vim +++ b/vim/autoload/patch.vim @@ -6,19 +6,27 @@ " function! patch#(version) abort - " If we're new enough, we can just use the native has() + " If the Vim running is new enough for its has() function to support + " checking patch levels with version prefixes, we can just add a "patch-" + " prefix to the query, and pass it on to has(). + " if has('patch-7.4.237') return has('patch-'.a:version) endif - " Otherwise, we need to start splitting and comparing numbers + " Failing that, we need to do our own version number and patch number + " comparisons; split the queried version on dots. + " let [major, minor, patch] = split(a:version, '\.') - " The v:version variable looks like e.g. 801 for v8.1 + " The internal variable v:version describing the running Vim looks like + " e.g. 801 for v8.1; reproduce that logic for the queried version. + " let l:version = major * 100 + minor - " If the version numbers are the same, return whether we have the patch; - " otherwise, return whether the version + " If the running version number is the same as the required one, return + " whether we have the specific patch requested; otherwise, return whether + " the running version number is greater than the required one. " return v:version == l:version \ ? has('patch-'.patch) diff --git a/vim/autoload/xdg.vim b/vim/autoload/xdg.vim index c5737506..67a9c5b2 100644 --- a/vim/autoload/xdg.vim +++ b/vim/autoload/xdg.vim @@ -12,10 +12,11 @@ function! s:Get(name) abort if !has_key(s:defaults, name) throw 'Illegal XDG basedirs env var name' endif - let value = getenv#(name) - return value !=# '' - \ ? value - \ : s:defaults[name] + let value = s:defaults[name] + if exists('$'.a:name) + execute 'let value = $'.a:name + endif + return value endfunction function! s:Absolute(path) abort @@ -2,7 +2,7 @@ " Tom Ryder (tejr)’s Literate Vimrc " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ " -" Last updated: Sun, 04 Oct 2020 04:15:27 UTC +" Last updated: Fri, 09 Oct 2020 08:52:09 UTC " " │ And I was lifted up in heart, and thought " │ Of all my late-shown prowess in the lists, @@ -137,11 +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. " -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() +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 |