aboutsummaryrefslogtreecommitdiff
path: root/vim/autoload/patch.vim
diff options
context:
space:
mode:
Diffstat (limited to 'vim/autoload/patch.vim')
-rw-r--r--vim/autoload/patch.vim27
1 files changed, 27 insertions, 0 deletions
diff --git a/vim/autoload/patch.vim b/vim/autoload/patch.vim
new file mode 100644
index 00000000..54637e09
--- /dev/null
+++ b/vim/autoload/patch.vim
@@ -0,0 +1,27 @@
+" Wrapper to emulate the nicer has() syntax for simultaneous version and patch
+" level checking that was introduced in v7.4.236 and fixed in v7.4.237.
+"
+" * <https://github.com/vim/vim/releases/tag/v7.4.236>
+" * <https://github.com/vim/vim/releases/tag/v7.4.237>
+"
+function! patch#(feature) abort
+
+ " If we're new enough, we can just run the native has()
+ if has('patch-7.4.237')
+ return has(a:feature)
+ endif
+
+ " Otherwise, we need to start splitting and comparing numbers
+ let [major, minor, patch] = split(a:feature, '\.')
+
+ " The v:version variable looks like e.g. 801 for v8.1
+ let l:version = major * 100 + minor
+
+ " If the version numbers are the same, return whether we have the patch;
+ " otherwise, return whether the version
+ "
+ return v:version == l:version
+ \ ? has('patch-'.patch)
+ \ : v:version > l:version
+
+endfunction