mirror of
https://github.com/amix/vimrc
synced 2025-08-03 03:34:59 +08:00
Updated plugins
This commit is contained in:
@ -294,11 +294,32 @@ endfunction
|
||||
|
||||
function! s:stage(hunk_diff)
|
||||
let bufnr = bufnr('')
|
||||
let diff = s:adjust_header(bufnr, a:hunk_diff)
|
||||
" Apply patch to index.
|
||||
call gitgutter#utility#system(
|
||||
\ gitgutter#utility#cd_cmd(bufnr, g:gitgutter_git_executable.' '.g:gitgutter_git_args.' apply --cached --unidiff-zero - '),
|
||||
\ diff)
|
||||
|
||||
if gitgutter#utility#clean_smudge_filter_applies(bufnr)
|
||||
let choice = input('File uses clean/smudge filter. Stage entire file (y/n)? ')
|
||||
normal! :<ESC>
|
||||
if choice =~ 'y'
|
||||
" We are about to add the file to the index so write the buffer to
|
||||
" ensure the file on disk matches it (the buffer).
|
||||
write
|
||||
let path = gitgutter#utility#repo_path(bufnr, 1)
|
||||
" Add file to index.
|
||||
let cmd = gitgutter#utility#cd_cmd(bufnr,
|
||||
\ gitgutter#git().' add '.
|
||||
\ gitgutter#utility#shellescape(gitgutter#utility#filename(bufnr)))
|
||||
call gitgutter#utility#system(cmd)
|
||||
else
|
||||
return
|
||||
endif
|
||||
|
||||
else
|
||||
let diff = s:adjust_header(bufnr, a:hunk_diff)
|
||||
" Apply patch to index.
|
||||
call gitgutter#utility#system(
|
||||
\ gitgutter#utility#cd_cmd(bufnr, gitgutter#git().' apply --cached --unidiff-zero - '),
|
||||
\ diff)
|
||||
endif
|
||||
|
||||
if v:shell_error
|
||||
call gitgutter#utility#warn('Patch does not apply')
|
||||
else
|
||||
@ -422,6 +443,9 @@ endfunction
|
||||
" Floating window: does not move cursor to floating window.
|
||||
" Preview window: moves cursor to preview window.
|
||||
function! s:open_hunk_preview_window()
|
||||
let source_wrap = &wrap
|
||||
let source_window = winnr()
|
||||
|
||||
if g:gitgutter_preview_win_floating
|
||||
if exists('*nvim_open_win')
|
||||
call gitgutter#hunk#close_hunk_preview_window()
|
||||
@ -429,6 +453,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, g:gitgutter_floating_window_options)
|
||||
call nvim_win_set_option(s:winid, 'wrap', source_wrap ? v:true : v:false)
|
||||
call nvim_buf_set_option(buf, 'filetype', 'diff')
|
||||
call nvim_buf_set_option(buf, 'buftype', 'acwrite')
|
||||
call nvim_buf_set_option(buf, 'bufhidden', 'delete')
|
||||
@ -458,6 +483,7 @@ function! s:open_hunk_preview_window()
|
||||
let s:winid = popup_create('', g:gitgutter_floating_window_options)
|
||||
|
||||
call setbufvar(winbufnr(s:winid), '&filetype', 'diff')
|
||||
call setwinvar(s:winid, '&wrap', source_wrap)
|
||||
|
||||
return
|
||||
endif
|
||||
@ -479,11 +505,13 @@ function! s:open_hunk_preview_window()
|
||||
let s:preview_bufnr = bufnr('')
|
||||
endif
|
||||
setlocal filetype=diff buftype=acwrite bufhidden=delete
|
||||
let &l:wrap = source_wrap
|
||||
let b:source_window = source_window
|
||||
" Reset some defaults in case someone else has changed them.
|
||||
setlocal noreadonly modifiable noswapfile
|
||||
if g:gitgutter_close_preview_on_escape
|
||||
" Ensure cursor goes to the expected window.
|
||||
nnoremap <buffer> <silent> <Esc> :<C-U>wincmd p<Bar>pclose<CR>
|
||||
nnoremap <buffer> <silent> <Esc> :<C-U>execute b:source_window . "wincmd w"<Bar>pclose<CR>
|
||||
endif
|
||||
|
||||
if exists('&previewpopup')
|
||||
@ -594,7 +622,7 @@ endfunction
|
||||
|
||||
|
||||
function! s:goto_original_window()
|
||||
noautocmd wincmd p
|
||||
noautocmd execute b:source_window . "wincmd w"
|
||||
doautocmd WinEnter
|
||||
endfunction
|
||||
|
||||
|
Reference in New Issue
Block a user