mirror of
https://github.com/amix/vimrc
synced 2025-06-30 20:05:01 +08:00
Updated plugins
This commit is contained in:
@ -6,6 +6,8 @@ let s:available = has('nvim') || (
|
||||
\ )
|
||||
\ )
|
||||
|
||||
let s:jobs = {}
|
||||
|
||||
function! gitgutter#async#available()
|
||||
return s:available
|
||||
endfunction
|
||||
@ -28,11 +30,12 @@ function! gitgutter#async#execute(cmd, bufnr, handler) abort
|
||||
\ 'on_exit': function('s:on_exit_nvim')
|
||||
\ }))
|
||||
else
|
||||
call job_start(command, {
|
||||
let job = job_start(command, {
|
||||
\ 'out_cb': function('s:on_stdout_vim', options),
|
||||
\ 'err_cb': function('s:on_stderr_vim', options),
|
||||
\ 'close_cb': function('s:on_exit_vim', options)
|
||||
\ })
|
||||
let s:jobs[s:job_id(job)] = 1
|
||||
endif
|
||||
endfunction
|
||||
|
||||
@ -83,6 +86,8 @@ endfunction
|
||||
|
||||
function! s:on_exit_vim(channel) dict abort
|
||||
let job = ch_getjob(a:channel)
|
||||
let jobid = s:job_id(job)
|
||||
if has_key(s:jobs, jobid) | unlet s:jobs[jobid] | endif
|
||||
while 1
|
||||
if job_status(job) == 'dead'
|
||||
let exit_code = job_info(job).exitval
|
||||
@ -95,3 +100,8 @@ function! s:on_exit_vim(channel) dict abort
|
||||
call self.handler.out(self.buffer, join(self.stdoutbuffer, "\n"))
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:job_id(job)
|
||||
" Vim
|
||||
return job_info(a:job).process
|
||||
endfunction
|
||||
|
@ -22,16 +22,6 @@ function! gitgutter#debug#debug()
|
||||
call s:separator()
|
||||
|
||||
call s:option('updatetime')
|
||||
call s:option('shell')
|
||||
call s:option('shellcmdflag')
|
||||
call s:option('shellpipe')
|
||||
call s:option('shellquote')
|
||||
call s:option('shellredir')
|
||||
call s:option('shellslash')
|
||||
call s:option('shelltemp')
|
||||
call s:option('shelltype')
|
||||
call s:option('shellxescape')
|
||||
call s:option('shellxquote')
|
||||
endfunction
|
||||
|
||||
|
||||
@ -52,10 +42,10 @@ function! s:git_version()
|
||||
endfunction
|
||||
|
||||
function! s:grep_version()
|
||||
let v = system('grep --version')
|
||||
let v = system(g:gitgutter_grep.' --version')
|
||||
call s:output( substitute(v, '\n$', '', '') )
|
||||
|
||||
let v = system('grep --help')
|
||||
let v = system(g:gitgutter_grep.' --help')
|
||||
call s:output( substitute(v, '\%x00', '', 'g') )
|
||||
endfunction
|
||||
|
||||
|
@ -12,6 +12,8 @@ endfunction
|
||||
|
||||
let s:c_flag = s:git_supports_command_line_config_override()
|
||||
|
||||
let s:temp_from = tempname()
|
||||
let s:temp_buffer = tempname()
|
||||
let s:counter = 0
|
||||
|
||||
" Returns a diff of the buffer against the index or the working tree.
|
||||
@ -75,9 +77,6 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort
|
||||
throw 'gitgutter not tracked'
|
||||
endif
|
||||
|
||||
let temp_from = tempname()
|
||||
let temp_buffer = tempname()
|
||||
|
||||
" Wrap compound commands in parentheses to make Windows happy.
|
||||
" bash doesn't mind the parentheses.
|
||||
let cmd = '('
|
||||
@ -90,7 +89,7 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort
|
||||
" second gitgutter#process_buffer() writing the file (synchronously, below)
|
||||
" and the first gitgutter#process_buffer()'s async job reading it (with
|
||||
" git-diff).
|
||||
let buff_file = temp_buffer.'.'.a:bufnr
|
||||
let buff_file = s:temp_buffer.'.'.a:bufnr
|
||||
|
||||
" Add a counter to avoid a similar race with two quick writes of the same buffer.
|
||||
" Use a modulus greater than a maximum reasonable number of visible buffers.
|
||||
@ -110,7 +109,7 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort
|
||||
" Without the buffer number, from_file would have a race in the shell
|
||||
" between the second process writing it (with git-show) and the first
|
||||
" reading it (with git-diff).
|
||||
let from_file = temp_from.'.'.a:bufnr
|
||||
let from_file = s:temp_from.'.'.a:bufnr
|
||||
|
||||
" Add a counter to avoid a similar race with two quick writes of the same buffer.
|
||||
let from_file .= '.'.s:counter
|
||||
@ -128,7 +127,7 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort
|
||||
endif
|
||||
|
||||
" Call git-diff.
|
||||
let cmd .= g:gitgutter_git_executable.' '.g:gitgutter_git_args.' --no-pager '.g:gitgutter_git_args
|
||||
let cmd .= g:gitgutter_git_executable.' '.g:gitgutter_git_args.' --no-pager'
|
||||
if s:c_flag
|
||||
let cmd .= ' -c "diff.autorefreshindex=0"'
|
||||
let cmd .= ' -c "diff.noprefix=false"'
|
||||
@ -400,7 +399,16 @@ function! s:write_buffer(bufnr, file)
|
||||
let bufcontents[0]=''.bufcontents[0]
|
||||
endif
|
||||
|
||||
call writefile(bufcontents, a:file, 'b')
|
||||
" The file we are writing to is a temporary file. Sometimes the parent
|
||||
" directory is deleted outside Vim but, because Vim caches the directory
|
||||
" name at startup and does not check for its existence subsequently, Vim
|
||||
" does not realise. This causes E482 errors.
|
||||
try
|
||||
call writefile(bufcontents, a:file, 'b')
|
||||
catch /E482/
|
||||
call mkdir(fnamemodify(a:file, ':h'), '', '0700')
|
||||
call writefile(bufcontents, a:file, 'b')
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
|
||||
|
@ -77,7 +77,7 @@ function! gitgutter#highlight#define_highlights() abort
|
||||
|
||||
" When they are visible.
|
||||
for type in ["Add", "Change", "Delete"]
|
||||
if hlexists("GitGutter".type)
|
||||
if hlexists("GitGutter".type) && s:get_foreground_colors("GitGutter".type) != ['NONE', 'NONE']
|
||||
if g:gitgutter_set_sign_backgrounds
|
||||
execute "highlight GitGutter".type." guibg=".guibg." ctermbg=".ctermbg
|
||||
endif
|
||||
|
@ -46,39 +46,57 @@ endfunction
|
||||
|
||||
function! gitgutter#hunk#next_hunk(count) abort
|
||||
let bufnr = bufnr('')
|
||||
if gitgutter#utility#is_active(bufnr)
|
||||
let current_line = line('.')
|
||||
let hunk_count = 0
|
||||
for hunk in gitgutter#hunk#hunks(bufnr)
|
||||
if hunk[2] > current_line
|
||||
let hunk_count += 1
|
||||
if hunk_count == a:count
|
||||
execute 'normal!' hunk[2] . 'Gzv'
|
||||
return
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
call gitgutter#utility#warn('No more hunks')
|
||||
if !gitgutter#utility#is_active(bufnr) | return | endif
|
||||
|
||||
let hunks = gitgutter#hunk#hunks(bufnr)
|
||||
if empty(hunks)
|
||||
call gitgutter#utility#warn('No hunks in file')
|
||||
return
|
||||
endif
|
||||
|
||||
let current_line = line('.')
|
||||
let hunk_count = 0
|
||||
for hunk in hunks
|
||||
if hunk[2] > current_line
|
||||
let hunk_count += 1
|
||||
if hunk_count == a:count
|
||||
execute 'normal!' hunk[2] . 'Gzv'
|
||||
if g:gitgutter_show_msg_on_hunk_jumping
|
||||
redraw | echo printf('Hunk %d of %d', index(hunks, hunk) + 1, len(hunks))
|
||||
endif
|
||||
return
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
call gitgutter#utility#warn('No more hunks')
|
||||
endfunction
|
||||
|
||||
function! gitgutter#hunk#prev_hunk(count) abort
|
||||
let bufnr = bufnr('')
|
||||
if gitgutter#utility#is_active(bufnr)
|
||||
let current_line = line('.')
|
||||
let hunk_count = 0
|
||||
for hunk in reverse(copy(gitgutter#hunk#hunks(bufnr)))
|
||||
if hunk[2] < current_line
|
||||
let hunk_count += 1
|
||||
if hunk_count == a:count
|
||||
let target = hunk[2] == 0 ? 1 : hunk[2]
|
||||
execute 'normal!' target . 'Gzv'
|
||||
return
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
call gitgutter#utility#warn('No previous hunks')
|
||||
if !gitgutter#utility#is_active(bufnr) | return | endif
|
||||
|
||||
let hunks = gitgutter#hunk#hunks(bufnr)
|
||||
if empty(hunks)
|
||||
call gitgutter#utility#warn('No hunks in file')
|
||||
return
|
||||
endif
|
||||
|
||||
let current_line = line('.')
|
||||
let hunk_count = 0
|
||||
for hunk in reverse(copy(hunks))
|
||||
if hunk[2] < current_line
|
||||
let hunk_count += 1
|
||||
if hunk_count == a:count
|
||||
let target = hunk[2] == 0 ? 1 : hunk[2]
|
||||
execute 'normal!' target . 'Gzv'
|
||||
if g:gitgutter_show_msg_on_hunk_jumping
|
||||
redraw | echo printf('Hunk %d of %d', index(hunks, hunk) + 1, len(hunks))
|
||||
endif
|
||||
return
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
call gitgutter#utility#warn('No previous hunks')
|
||||
endfunction
|
||||
|
||||
" Returns the hunk the cursor is currently in or an empty list if the cursor
|
||||
@ -455,6 +473,9 @@ function! s:open_hunk_preview_window()
|
||||
setlocal filetype=diff buftype=acwrite bufhidden=delete
|
||||
" Reset some defaults in case someone else has changed them.
|
||||
setlocal noreadonly modifiable noswapfile
|
||||
if g:gitgutter_close_preview_on_escape
|
||||
nnoremap <buffer> <silent> <Esc> :pclose<CR>
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user