aboutsummaryrefslogtreecommitdiff
path: root/vim/autoload/patch.vim
blob: 54637e09c03702bb97493a40f80f472ba5897f09 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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