mirror of
https://github.com/amix/vimrc
synced 2025-06-30 11:54:59 +08:00
Updated plugins
This commit is contained in:
@ -77,6 +77,10 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort
|
||||
throw 'gitgutter not tracked'
|
||||
endif
|
||||
|
||||
if gitgutter#utility#repo_path(a:bufnr, 0) == -3
|
||||
throw 'gitgutter assume unchanged'
|
||||
endif
|
||||
|
||||
" Wrap compound commands in parentheses to make Windows happy.
|
||||
" bash doesn't mind the parentheses.
|
||||
let cmd = '('
|
||||
|
@ -150,12 +150,6 @@ function! s:lcs(s1, s2)
|
||||
return a:s1[endindex - maxlength + 1 : endindex]
|
||||
endfunction
|
||||
|
||||
if $VIM_GITGUTTER_TEST
|
||||
function! gitgutter#diff_highlight#lcs(s1, s2)
|
||||
return s:lcs(a:s1, a:s2)
|
||||
endfunction
|
||||
endif
|
||||
|
||||
|
||||
" Returns 0-based index of last character of common prefix
|
||||
" If there is no common prefix, returns -1.
|
||||
@ -168,19 +162,13 @@ function! s:common_prefix(a, b)
|
||||
return -1
|
||||
endif
|
||||
for i in range(len)
|
||||
if a:a[i:i] != a:b[i:i]
|
||||
if a:a[i:i] !=# a:b[i:i]
|
||||
return i - 1
|
||||
endif
|
||||
endfor
|
||||
return i
|
||||
endfunction
|
||||
|
||||
if $VIM_GITGUTTER_TEST
|
||||
function! gitgutter#diff_highlight#common_prefix(a, b)
|
||||
return s:common_prefix(a:a, a:b)
|
||||
endfunction
|
||||
endif
|
||||
|
||||
|
||||
" Returns 0-based indices of start of common suffix
|
||||
"
|
||||
@ -199,12 +187,6 @@ function! s:common_suffix(a, b, start)
|
||||
return [sa+1, sb+1]
|
||||
endfunction
|
||||
|
||||
if $VIM_GITGUTTER_TEST
|
||||
function! gitgutter#diff_highlight#common_suffix(a, b, start)
|
||||
return s:common_suffix(a:a, a:b, a:start)
|
||||
endfunction
|
||||
endif
|
||||
|
||||
|
||||
" Split a string on another string.
|
||||
" Assumes 1 occurrence of the delimiter.
|
||||
@ -217,9 +199,3 @@ function! s:split(str, delimiter)
|
||||
|
||||
return [a:str[:i-1], a:str[i+len(a:delimiter):]]
|
||||
endfunction
|
||||
|
||||
if $VIM_GITGUTTER_TEST
|
||||
function! gitgutter#diff_highlight#split(str, delimiter)
|
||||
return s:split(a:str, a:delimiter)
|
||||
endfunction
|
||||
endif
|
||||
|
@ -175,12 +175,12 @@ function! s:define_sign_line_highlights() abort
|
||||
sign define GitGutterLineRemovedAboveAndBelow linehl=GitGutterDeleteLine
|
||||
sign define GitGutterLineModifiedRemoved linehl=GitGutterChangeDeleteLine
|
||||
else
|
||||
sign define GitGutterLineAdded linehl=
|
||||
sign define GitGutterLineModified linehl=
|
||||
sign define GitGutterLineRemoved linehl=
|
||||
sign define GitGutterLineRemovedFirstLine linehl=
|
||||
sign define GitGutterLineRemovedAboveAndBelow linehl=
|
||||
sign define GitGutterLineModifiedRemoved linehl=
|
||||
sign define GitGutterLineAdded linehl=NONE
|
||||
sign define GitGutterLineModified linehl=NONE
|
||||
sign define GitGutterLineRemoved linehl=NONE
|
||||
sign define GitGutterLineRemovedFirstLine linehl=NONE
|
||||
sign define GitGutterLineRemovedAboveAndBelow linehl=NONE
|
||||
sign define GitGutterLineModifiedRemoved linehl=NONE
|
||||
endif
|
||||
endfunction
|
||||
|
||||
@ -195,12 +195,12 @@ function! s:define_sign_linenr_highlights() abort
|
||||
sign define GitGutterLineRemovedAboveAndBelow numhl=GitGutterDeleteLineNr
|
||||
sign define GitGutterLineModifiedRemoved numhl=GitGutterChangeDeleteLineNr
|
||||
else
|
||||
sign define GitGutterLineAdded numhl=
|
||||
sign define GitGutterLineModified numhl=
|
||||
sign define GitGutterLineRemoved numhl=
|
||||
sign define GitGutterLineRemovedFirstLine numhl=
|
||||
sign define GitGutterLineRemovedAboveAndBelow numhl=
|
||||
sign define GitGutterLineModifiedRemoved numhl=
|
||||
sign define GitGutterLineAdded numhl=NONE
|
||||
sign define GitGutterLineModified numhl=NONE
|
||||
sign define GitGutterLineRemoved numhl=NONE
|
||||
sign define GitGutterLineRemovedFirstLine numhl=NONE
|
||||
sign define GitGutterLineRemovedAboveAndBelow numhl=NONE
|
||||
sign define GitGutterLineModifiedRemoved numhl=NONE
|
||||
endif
|
||||
catch /E475/
|
||||
endtry
|
||||
|
@ -382,12 +382,6 @@ function! s:fix_file_references(filepath, hunk_diff)
|
||||
return join(lines, "\n")."\n"
|
||||
endfunction
|
||||
|
||||
if $VIM_GITGUTTER_TEST
|
||||
function! gitgutter#hunk#fix_file_references(filepath, hunk_diff)
|
||||
return s:fix_file_references(a:filepath, a:hunk_diff)
|
||||
endfunction
|
||||
endif
|
||||
|
||||
|
||||
function! s:adjust_hunk_summary(hunk_diff) abort
|
||||
let line_adjustment = s:line_adjustment_for_current_hunk()
|
||||
@ -431,14 +425,7 @@ function! s:open_hunk_preview_window()
|
||||
|
||||
let buf = nvim_create_buf(v:false, v:false)
|
||||
" Set default width and height for now.
|
||||
let s:winid = nvim_open_win(buf, v:false, {
|
||||
\ 'relative': 'cursor',
|
||||
\ 'row': 1,
|
||||
\ 'col': 0,
|
||||
\ 'width': 42,
|
||||
\ 'height': &previewheight,
|
||||
\ 'style': 'minimal'
|
||||
\ })
|
||||
let s:winid = nvim_open_win(buf, v:false, g:gitgutter_floating_window_options)
|
||||
call nvim_buf_set_option(buf, 'filetype', 'diff')
|
||||
call nvim_buf_set_option(buf, 'buftype', 'acwrite')
|
||||
call nvim_buf_set_option(buf, 'bufhidden', 'delete')
|
||||
@ -461,16 +448,11 @@ function! s:open_hunk_preview_window()
|
||||
endif
|
||||
|
||||
if exists('*popup_create')
|
||||
let opts = {
|
||||
\ 'line': 'cursor+1',
|
||||
\ 'col': 'cursor',
|
||||
\ 'moved': 'any',
|
||||
\ }
|
||||
if g:gitgutter_close_preview_on_escape
|
||||
let opts.filter = function('s:close_popup_on_escape')
|
||||
let g:gitgutter_floating_window_options.filter = function('s:close_popup_on_escape')
|
||||
endif
|
||||
|
||||
let s:winid = popup_create('', opts)
|
||||
let s:winid = popup_create('', g:gitgutter_floating_window_options)
|
||||
|
||||
call setbufvar(winbufnr(s:winid), '&filetype', 'diff')
|
||||
|
||||
@ -478,6 +460,10 @@ function! s:open_hunk_preview_window()
|
||||
endif
|
||||
endif
|
||||
|
||||
if exists('&previewpopup')
|
||||
let [previewpopup, &previewpopup] = [&previewpopup, '']
|
||||
endif
|
||||
|
||||
" Specifying where to open the preview window can lead to the cursor going
|
||||
" to an unexpected window when the preview window is closed (#769).
|
||||
silent! noautocmd execute g:gitgutter_preview_win_location 'pedit gitgutter://hunk-preview'
|
||||
@ -496,6 +482,10 @@ function! s:open_hunk_preview_window()
|
||||
" Ensure cursor goes to the expected window.
|
||||
nnoremap <buffer> <silent> <Esc> :<C-U>wincmd p<Bar>pclose<CR>
|
||||
endif
|
||||
|
||||
if exists('&previewpopup')
|
||||
let &previewpopup=previewpopup
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
@ -515,7 +505,7 @@ function! s:populate_hunk_preview_window(header, body)
|
||||
|
||||
if g:gitgutter_preview_win_floating
|
||||
if exists('*nvim_open_win')
|
||||
let height = min([body_length, &previewheight])
|
||||
let height = min([body_length, g:gitgutter_floating_window_options.height])
|
||||
|
||||
" Assumes cursor is not in previewing window.
|
||||
call nvim_buf_set_var(winbufnr(s:winid), 'hunk_header', a:header)
|
||||
|
@ -48,8 +48,7 @@ endfunction
|
||||
" Returns truthy when the buffer's file should be processed; and falsey when it shouldn't.
|
||||
" This function does not and should not make any system calls.
|
||||
function! gitgutter#utility#is_active(bufnr) abort
|
||||
return g:gitgutter_enabled &&
|
||||
\ gitgutter#utility#getbufvar(a:bufnr, 'enabled', 1) &&
|
||||
return gitgutter#utility#getbufvar(a:bufnr, 'enabled') &&
|
||||
\ !pumvisible() &&
|
||||
\ s:is_file_buffer(a:bufnr) &&
|
||||
\ s:exists_file(a:bufnr) &&
|
||||
@ -109,6 +108,7 @@ endfunction
|
||||
" * non-empty string - path
|
||||
" * -1 - pending
|
||||
" * -2 - not tracked by git
|
||||
" * -3 - assume unchanged
|
||||
function! gitgutter#utility#repo_path(bufnr, shellesc) abort
|
||||
let p = gitgutter#utility#getbufvar(a:bufnr, 'path', '')
|
||||
return a:shellesc ? gitgutter#utility#shellescape(p) : p
|
||||
@ -117,9 +117,14 @@ endfunction
|
||||
|
||||
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)
|
||||
function! s:set_path_handler.out(buffer, listing) abort
|
||||
let listing = s:strip_trailing_new_line(a:listing)
|
||||
let [status, path] = [listing[0], listing[2:]]
|
||||
if status =~# '[a-z]'
|
||||
call gitgutter#utility#setbufvar(a:buffer, 'path', -3)
|
||||
else
|
||||
call gitgutter#utility#setbufvar(a:buffer, 'path', path)
|
||||
endif
|
||||
|
||||
if type(self.continuation) == type(function('tr'))
|
||||
call self.continuation()
|
||||
@ -141,9 +146,13 @@ function! gitgutter#utility#set_repo_path(bufnr, continuation) abort
|
||||
" * non-empty string - path
|
||||
" * -1 - pending
|
||||
" * -2 - not tracked by git
|
||||
" * -3 - assume unchanged
|
||||
|
||||
call gitgutter#utility#setbufvar(a:bufnr, 'path', -1)
|
||||
let cmd = gitgutter#utility#cd_cmd(a:bufnr, g:gitgutter_git_executable.' '.g:gitgutter_git_args.' ls-files --error-unmatch --full-name -z -- '.gitgutter#utility#shellescape(s:filename(a:bufnr)))
|
||||
let cmd = gitgutter#utility#cd_cmd(a:bufnr,
|
||||
\ g:gitgutter_git_executable.' '.g:gitgutter_git_args.
|
||||
\ ' ls-files -v --error-unmatch --full-name -z -- '.
|
||||
\ gitgutter#utility#shellescape(s:filename(a:bufnr)))
|
||||
|
||||
if g:gitgutter_async && gitgutter#async#available() && !has('vim_starting')
|
||||
let handler = copy(s:set_path_handler)
|
||||
@ -152,11 +161,19 @@ function! gitgutter#utility#set_repo_path(bufnr, continuation) abort
|
||||
return 'async'
|
||||
endif
|
||||
|
||||
let path = gitgutter#utility#system(cmd)
|
||||
let listing = gitgutter#utility#system(cmd)
|
||||
|
||||
if v:shell_error
|
||||
call gitgutter#utility#setbufvar(a:bufnr, 'path', -2)
|
||||
return
|
||||
endif
|
||||
|
||||
let listing = s:strip_trailing_new_line(listing)
|
||||
let [status, path] = [listing[0], listing[2:]]
|
||||
if status =~# '[a-z]'
|
||||
call gitgutter#utility#setbufvar(a:bufnr, 'path', -3)
|
||||
else
|
||||
call gitgutter#utility#setbufvar(a:bufnr, 'path', s:strip_trailing_new_line(path))
|
||||
call gitgutter#utility#setbufvar(a:bufnr, 'path', path)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
Reference in New Issue
Block a user