mirror of
https://github.com/amix/vimrc
synced 2025-07-04 15:04:59 +08:00
update plugins
ran the plugin update script
This commit is contained in:
@ -10,7 +10,6 @@ function! gitgutter#all(force) abort
|
||||
let file = expand('#'.bufnr.':p')
|
||||
if !empty(file)
|
||||
if index(visible, bufnr) != -1
|
||||
call gitgutter#init_buffer(bufnr)
|
||||
call gitgutter#process_buffer(bufnr, a:force)
|
||||
elseif a:force
|
||||
call s:reset_tick(bufnr)
|
||||
@ -21,22 +20,23 @@ function! gitgutter#all(force) abort
|
||||
endfunction
|
||||
|
||||
|
||||
" Finds the file's path relative to the repo root.
|
||||
function! gitgutter#init_buffer(bufnr)
|
||||
if gitgutter#utility#is_active(a:bufnr)
|
||||
let p = gitgutter#utility#repo_path(a:bufnr, 0)
|
||||
if type(p) != s:t_string || empty(p)
|
||||
call gitgutter#utility#set_repo_path(a:bufnr)
|
||||
call s:setup_maps()
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
function! gitgutter#process_buffer(bufnr, force) abort
|
||||
" NOTE a:bufnr is not necessarily the current buffer.
|
||||
|
||||
if gitgutter#utility#is_active(a:bufnr)
|
||||
|
||||
call s:setup_maps(a:bufnr)
|
||||
|
||||
if has('patch-7.4.1559')
|
||||
let l:Callback = function('gitgutter#process_buffer', [a:bufnr, a:force])
|
||||
else
|
||||
let l:Callback = {'function': 'gitgutter#process_buffer', 'arguments': [a:bufnr, a:force]}
|
||||
endif
|
||||
let how = s:setup_path(a:bufnr, l:Callback)
|
||||
if [how] == ['async'] " avoid string-to-number conversion if how is a number
|
||||
return
|
||||
endif
|
||||
|
||||
if a:force || s:has_fresh_changes(a:bufnr)
|
||||
|
||||
let diff = ''
|
||||
@ -108,11 +108,15 @@ endfunction
|
||||
|
||||
" }}}
|
||||
|
||||
function! s:setup_maps()
|
||||
function! s:setup_maps(bufnr)
|
||||
if !g:gitgutter_map_keys
|
||||
return
|
||||
endif
|
||||
|
||||
if gitgutter#utility#getbufvar(a:bufnr, 'mapped', 0)
|
||||
return
|
||||
endif
|
||||
|
||||
if !hasmapto('<Plug>GitGutterPrevHunk') && maparg('[c', 'n') ==# ''
|
||||
nmap <buffer> [c <Plug>GitGutterPrevHunk
|
||||
endif
|
||||
@ -142,6 +146,18 @@ function! s:setup_maps()
|
||||
if !hasmapto('<Plug>GitGutterTextObjectOuterVisual') && maparg('ac', 'x') ==# ''
|
||||
xmap <buffer> ac <Plug>GitGutterTextObjectOuterVisual
|
||||
endif
|
||||
|
||||
call gitgutter#utility#setbufvar(a:bufnr, 'mapped', 1)
|
||||
endfunction
|
||||
|
||||
function! s:setup_path(bufnr, continuation)
|
||||
let p = gitgutter#utility#repo_path(a:bufnr, 0)
|
||||
|
||||
if type(p) == s:t_string && !empty(p) " if path is known
|
||||
return
|
||||
endif
|
||||
|
||||
return gitgutter#utility#set_repo_path(a:bufnr, a:continuation)
|
||||
endfunction
|
||||
|
||||
function! s:has_fresh_changes(bufnr) abort
|
||||
|
@ -68,9 +68,9 @@ let s:counter = 0
|
||||
" the hunk headers (@@ -x,y +m,n @@); only possible if
|
||||
" grep is available.
|
||||
function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort
|
||||
while gitgutter#utility#repo_path(a:bufnr, 0) == -1
|
||||
sleep 5m
|
||||
endwhile
|
||||
if gitgutter#utility#repo_path(a:bufnr, 0) == -1
|
||||
throw 'gitgutter author fail'
|
||||
endif
|
||||
|
||||
if gitgutter#utility#repo_path(a:bufnr, 0) == -2
|
||||
throw 'gitgutter not tracked'
|
||||
|
@ -114,7 +114,29 @@ function! gitgutter#utility#repo_path(bufnr, shellesc) abort
|
||||
return a:shellesc ? gitgutter#utility#shellescape(p) : p
|
||||
endfunction
|
||||
|
||||
function! gitgutter#utility#set_repo_path(bufnr) abort
|
||||
|
||||
let s:set_path_handler = {}
|
||||
|
||||
function! s:set_path_handler.out(buffer, path) abort
|
||||
let path = s:strip_trailing_new_line(a:path)
|
||||
call gitgutter#utility#setbufvar(a:buffer, 'path', path)
|
||||
|
||||
if type(self.continuation) == type(function('tr'))
|
||||
call self.continuation()
|
||||
else
|
||||
call call(self.continuation.function, self.continuation.arguments)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:set_path_handler.err(buffer) abort
|
||||
call gitgutter#utility#setbufvar(a:buffer, 'path', -2)
|
||||
endfunction
|
||||
|
||||
|
||||
" continuation - a funcref or hash to call after setting the repo path asynchronously.
|
||||
"
|
||||
" Returns 'async' if the the path is set asynchronously, 0 otherwise.
|
||||
function! gitgutter#utility#set_repo_path(bufnr, continuation) abort
|
||||
" Values of path:
|
||||
" * non-empty string - path
|
||||
" * -1 - pending
|
||||
@ -124,48 +146,20 @@ function! gitgutter#utility#set_repo_path(bufnr) abort
|
||||
let cmd = gitgutter#utility#cd_cmd(a:bufnr, g:gitgutter_git_executable.' ls-files --error-unmatch --full-name -z -- '.gitgutter#utility#shellescape(s:filename(a:bufnr)))
|
||||
|
||||
if g:gitgutter_async && gitgutter#async#available()
|
||||
if has('lambda')
|
||||
call gitgutter#async#execute(cmd, a:bufnr, {
|
||||
\ '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
|
||||
let handler = copy(s:set_path_handler)
|
||||
let handler.continuation = a:continuation
|
||||
call gitgutter#async#execute(cmd, a:bufnr, handler)
|
||||
return 'async'
|
||||
endif
|
||||
|
||||
let path = gitgutter#utility#system(cmd)
|
||||
if v:shell_error
|
||||
call gitgutter#utility#setbufvar(a:bufnr, 'path', -2)
|
||||
else
|
||||
let path = gitgutter#utility#system(cmd)
|
||||
if v:shell_error
|
||||
call gitgutter#utility#setbufvar(a:bufnr, 'path', -2)
|
||||
else
|
||||
call gitgutter#utility#setbufvar(a:bufnr, 'path', s:strip_trailing_new_line(path))
|
||||
endif
|
||||
call gitgutter#utility#setbufvar(a:bufnr, 'path', s:strip_trailing_new_line(path))
|
||||
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]
|
||||
call gitgutter#utility#setbufvar(bufnr, 'path', path)
|
||||
else
|
||||
call gitgutter#utility#setbufvar(a:bufnr, 'path', s:strip_trailing_new_line(a:path))
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! gitgutter#utility#cd_cmd(bufnr, cmd) abort
|
||||
let cd = s:unc_path(a:bufnr) ? 'pushd' : (gitgutter#utility#windows() ? 'cd /d' : 'cd')
|
||||
|
@ -190,7 +190,6 @@ function! s:on_bufenter()
|
||||
let t:gitgutter_didtabenter = 0
|
||||
call gitgutter#all(!g:gitgutter_terminal_reports_focus)
|
||||
else
|
||||
call gitgutter#init_buffer(bufnr(''))
|
||||
call gitgutter#process_buffer(bufnr(''), !g:gitgutter_terminal_reports_focus)
|
||||
endif
|
||||
endfunction
|
||||
|
@ -71,7 +71,7 @@ function Test_add_lines()
|
||||
normal ggo*
|
||||
call s:trigger_gitgutter()
|
||||
|
||||
let expected = ["line=2 id=3000 name=GitGutterLineAdded"]
|
||||
let expected = ["line=2 id=3000 name=GitGutterLineAdded priority=10"]
|
||||
call assert_equal(expected, s:signs('fixture.txt'))
|
||||
endfunction
|
||||
|
||||
@ -83,7 +83,7 @@ function Test_add_lines_fish()
|
||||
normal ggo*
|
||||
call s:trigger_gitgutter()
|
||||
|
||||
let expected = ["line=2 id=3000 name=GitGutterLineAdded"]
|
||||
let expected = ["line=2 id=3000 name=GitGutterLineAdded priority=10"]
|
||||
call assert_equal(expected, s:signs('fixture.txt'))
|
||||
|
||||
let &shell = _shell
|
||||
@ -94,7 +94,7 @@ function Test_modify_lines()
|
||||
normal ggi*
|
||||
call s:trigger_gitgutter()
|
||||
|
||||
let expected = ["line=1 id=3000 name=GitGutterLineModified"]
|
||||
let expected = ["line=1 id=3000 name=GitGutterLineModified priority=10"]
|
||||
call assert_equal(expected, s:signs('fixture.txt'))
|
||||
endfunction
|
||||
|
||||
@ -103,7 +103,7 @@ function Test_remove_lines()
|
||||
execute '5d'
|
||||
call s:trigger_gitgutter()
|
||||
|
||||
let expected = ["line=4 id=3000 name=GitGutterLineRemoved"]
|
||||
let expected = ["line=4 id=3000 name=GitGutterLineRemoved priority=10"]
|
||||
call assert_equal(expected, s:signs('fixture.txt'))
|
||||
endfunction
|
||||
|
||||
@ -112,7 +112,7 @@ function Test_remove_first_lines()
|
||||
execute '1d'
|
||||
call s:trigger_gitgutter()
|
||||
|
||||
let expected = ["line=1 id=3000 name=GitGutterLineRemovedFirstLine"]
|
||||
let expected = ["line=1 id=3000 name=GitGutterLineRemovedFirstLine priority=10"]
|
||||
call assert_equal(expected, s:signs('fixture.txt'))
|
||||
endfunction
|
||||
|
||||
@ -122,7 +122,7 @@ function Test_overlapping_hunks()
|
||||
execute '1d'
|
||||
call s:trigger_gitgutter()
|
||||
|
||||
let expected = ["line=1 id=3000 name=GitGutterLineRemovedAboveAndBelow"]
|
||||
let expected = ["line=1 id=3000 name=GitGutterLineRemovedAboveAndBelow priority=10"]
|
||||
call assert_equal(expected, s:signs('fixture.txt'))
|
||||
endfunction
|
||||
|
||||
@ -132,7 +132,7 @@ function Test_edit_file_with_same_name_as_a_branch()
|
||||
call system('git checkout -b fixture.txt')
|
||||
call s:trigger_gitgutter()
|
||||
|
||||
let expected = ["line=5 id=3000 name=GitGutterLineModified"]
|
||||
let expected = ["line=5 id=3000 name=GitGutterLineModified priority=10"]
|
||||
call assert_equal(expected, s:signs('fixture.txt'))
|
||||
endfunction
|
||||
|
||||
@ -144,7 +144,7 @@ function Test_file_added_to_git()
|
||||
normal ihello
|
||||
call s:trigger_gitgutter()
|
||||
|
||||
let expected = ["line=1 id=3000 name=GitGutterLineAdded"]
|
||||
let expected = ["line=1 id=3000 name=GitGutterLineAdded priority=10"]
|
||||
call assert_equal(expected, s:signs('fileAddedToGit.tmp'))
|
||||
endfunction
|
||||
|
||||
@ -156,8 +156,8 @@ function Test_filename_with_equals()
|
||||
call s:trigger_gitgutter()
|
||||
|
||||
let expected = [
|
||||
\ 'line=1 id=3000 name=GitGutterLineAdded',
|
||||
\ 'line=2 id=3001 name=GitGutterLineAdded'
|
||||
\ 'line=1 id=3000 name=GitGutterLineAdded priority=10',
|
||||
\ 'line=2 id=3001 name=GitGutterLineAdded priority=10'
|
||||
\ ]
|
||||
call assert_equal(expected, s:signs('=fixture=.txt'))
|
||||
endfunction
|
||||
@ -170,8 +170,8 @@ function Test_filename_with_square_brackets()
|
||||
call s:trigger_gitgutter()
|
||||
|
||||
let expected = [
|
||||
\ 'line=1 id=3000 name=GitGutterLineAdded',
|
||||
\ 'line=2 id=3001 name=GitGutterLineAdded'
|
||||
\ 'line=1 id=3000 name=GitGutterLineAdded priority=10',
|
||||
\ 'line=2 id=3001 name=GitGutterLineAdded priority=10'
|
||||
\ ]
|
||||
call assert_equal(expected, s:signs('fix[tu]re.txt'))
|
||||
endfunction
|
||||
@ -184,8 +184,8 @@ function Test_filename_leading_dash()
|
||||
call s:trigger_gitgutter()
|
||||
|
||||
let expected = [
|
||||
\ 'line=1 id=3000 name=GitGutterLineAdded',
|
||||
\ 'line=2 id=3001 name=GitGutterLineAdded'
|
||||
\ 'line=1 id=3000 name=GitGutterLineAdded priority=10',
|
||||
\ 'line=2 id=3001 name=GitGutterLineAdded priority=10'
|
||||
\ ]
|
||||
call assert_equal(expected, s:signs('-fixture.txt'))
|
||||
endfunction
|
||||
@ -198,8 +198,8 @@ function Test_filename_umlaut()
|
||||
call s:trigger_gitgutter()
|
||||
|
||||
let expected = [
|
||||
\ 'line=1 id=3000 name=GitGutterLineAdded',
|
||||
\ 'line=2 id=3001 name=GitGutterLineAdded'
|
||||
\ 'line=1 id=3000 name=GitGutterLineAdded priority=10',
|
||||
\ 'line=2 id=3001 name=GitGutterLineAdded priority=10'
|
||||
\ ]
|
||||
call assert_equal(expected, s:signs('fixtüre.txt'))
|
||||
endfunction
|
||||
@ -213,7 +213,7 @@ function Test_follow_symlink()
|
||||
6d
|
||||
call s:trigger_gitgutter()
|
||||
|
||||
let expected = ['line=5 id=3000 name=GitGutterLineRemoved']
|
||||
let expected = ['line=5 id=3000 name=GitGutterLineRemoved priority=10']
|
||||
call assert_equal(expected, s:signs('symlink'))
|
||||
endfunction
|
||||
|
||||
@ -265,7 +265,7 @@ function Test_orphaned_signs()
|
||||
6d
|
||||
call s:trigger_gitgutter()
|
||||
|
||||
let expected = ['line=6 id=3001 name=GitGutterLineAdded']
|
||||
let expected = ['line=6 id=3001 name=GitGutterLineAdded priority=10']
|
||||
call assert_equal(expected, s:signs('fixture.txt'))
|
||||
endfunction
|
||||
|
||||
@ -372,9 +372,9 @@ function Test_hunk_stage_nearby_hunk()
|
||||
GitGutterStageHunk
|
||||
|
||||
let expected = [
|
||||
\ 'line=3 id=3000 name=GitGutterLineAdded',
|
||||
\ 'line=4 id=3001 name=GitGutterLineAdded',
|
||||
\ 'line=5 id=3002 name=GitGutterLineAdded'
|
||||
\ 'line=3 id=3000 name=GitGutterLineAdded priority=10',
|
||||
\ 'line=4 id=3001 name=GitGutterLineAdded priority=10',
|
||||
\ 'line=5 id=3002 name=GitGutterLineAdded priority=10'
|
||||
\ ]
|
||||
call assert_equal(expected, s:signs('fixture.txt'))
|
||||
|
||||
@ -442,9 +442,9 @@ function Test_undo_nearby_hunk()
|
||||
call s:trigger_gitgutter()
|
||||
|
||||
let expected = [
|
||||
\ 'line=3 id=3000 name=GitGutterLineAdded',
|
||||
\ 'line=4 id=3001 name=GitGutterLineAdded',
|
||||
\ 'line=5 id=3002 name=GitGutterLineAdded'
|
||||
\ 'line=3 id=3000 name=GitGutterLineAdded priority=10',
|
||||
\ 'line=4 id=3001 name=GitGutterLineAdded priority=10',
|
||||
\ 'line=5 id=3002 name=GitGutterLineAdded priority=10'
|
||||
\ ]
|
||||
call assert_equal(expected, s:signs('fixture.txt'))
|
||||
|
||||
@ -486,7 +486,7 @@ function Test_overlapping_hunk_op()
|
||||
call s:trigger_gitgutter()
|
||||
|
||||
let expected = [
|
||||
\ 'line=2 id=3000 name=GitGutterLineRemoved',
|
||||
\ 'line=2 id=3000 name=GitGutterLineRemoved priority=10',
|
||||
\ ]
|
||||
call assert_equal(expected, s:signs('fixture.txt'))
|
||||
|
||||
@ -500,7 +500,7 @@ function Test_overlapping_hunk_op()
|
||||
call s:trigger_gitgutter()
|
||||
|
||||
let expected = [
|
||||
\ 'line=1 id=3000 name=GitGutterLineRemovedFirstLine',
|
||||
\ 'line=1 id=3000 name=GitGutterLineRemovedFirstLine priority=10',
|
||||
\ ]
|
||||
call assert_equal(expected, s:signs('fixture.txt'))
|
||||
endfunction
|
||||
@ -512,7 +512,7 @@ function Test_write_option()
|
||||
normal ggo*
|
||||
call s:trigger_gitgutter()
|
||||
|
||||
let expected = ["line=2 id=3000 name=GitGutterLineAdded"]
|
||||
let expected = ["line=2 id=3000 name=GitGutterLineAdded priority=10"]
|
||||
call assert_equal(expected, s:signs('fixture.txt'))
|
||||
|
||||
set write
|
||||
|
Reference in New Issue
Block a user