aboutsummaryrefslogtreecommitdiff
path: root/vim/autoload
diff options
context:
space:
mode:
Diffstat (limited to 'vim/autoload')
-rw-r--r--vim/autoload/getenv.vim17
-rw-r--r--vim/autoload/patch.vim18
-rw-r--r--vim/autoload/xdg.vim9
3 files changed, 18 insertions, 26 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