Backward compatibility for nvim-0.1.7.

NeoVim 0.1.7 does not support the `function()` function accepting an
optional argument list.

Fixes #496.
This commit is contained in:
Andy Stewart
2018-03-14 11:43:36 +00:00
parent 380e7935b7
commit 2f736d58b4

View File

@@ -123,12 +123,19 @@ function! gitgutter#utility#set_repo_path(bufnr) abort
\ 'out': {bufnr, path -> gitgutter#utility#setbufvar(bufnr, 'path', s:strip_trailing_new_line(path))},
\ 'err': {bufnr -> gitgutter#utility#setbufvar(bufnr, 'path', -2)},
\ })
else
if has('nvim') && !has('nvim-0.2.0')
call gitgutter#async#execute(cmd, a:bufnr, {
\ 'out': function('s:set_path'),
\ 'err': function('s:not_tracked_by_git')
\ })
else
call gitgutter#async#execute(cmd, a:bufnr, {
\ 'out': function('s:set_path'),
\ 'err': function('s:set_path', [-2])
\ })
endif
endif
else
let path = gitgutter#utility#system(cmd)
if v:shell_error
@@ -139,6 +146,12 @@ function! gitgutter#utility#set_repo_path(bufnr) abort
endif
endfunction
if has('nvim') && !has('nvim-0.2.0')
function! s:not_tracked_by_git(bufnr)
call s:set_path(a:bufnr, -2)
endfunction
endif
function! s:set_path(bufnr, path)
if a:bufnr == -2
let [bufnr, path] = [a:path, a:bufnr]