1
0
mirror of https://github.com/amix/vimrc synced 2025-07-27 15:04:59 +08:00
This commit is contained in:
geezus
2021-06-30 12:00:07 -05:00
parent 43c7efba8d
commit 3afe70fe5a
1529 changed files with 3053 additions and 3018 deletions

View File

@ -257,6 +257,7 @@ function! s:hunk_op(op, ...)
let g:gitgutter_async = async
call gitgutter#hunk#set_hunks(bufnr, gitgutter#diff#parse_diff(diff))
call gitgutter#diff#process_hunks(bufnr, gitgutter#hunk#hunks(bufnr)) " so the hunk summary is updated
if empty(s:current_hunk())
call gitgutter#utility#warn('cursor is not in a hunk')
@ -440,16 +441,24 @@ function! s:open_hunk_preview_window()
" Assumes cursor is in original window.
autocmd CursorMoved <buffer> ++once call s:close_hunk_preview_window()
if g:gitgutter_close_preview_on_escape
nnoremap <buffer> <silent> <Esc> :call <SID>close_hunk_preview_window()<CR>
endif
return
endif
if exists('*popup_create')
let s:winid = 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')
endif
let s:winid = popup_create('', opts)
call setbufvar(winbufnr(s:winid), '&filetype', 'diff')
@ -461,7 +470,8 @@ function! s:open_hunk_preview_window()
if &previewwindow
file gitgutter://hunk-preview
else
noautocmd execute g:gitgutter_preview_win_location &previewheight 'new gitgutter://hunk-preview'
noautocmd execute g:gitgutter_preview_win_location &previewheight 'new'
file gitgutter://hunk-preview
doautocmd WinEnter
set previewwindow
endif
@ -479,6 +489,15 @@ function! s:open_hunk_preview_window()
endfunction
function! s:close_popup_on_escape(winid, key)
if a:key == "\<Esc>"
call popup_close(a:winid)
return 1
endif
return 0
endfunction
" Floating window: does not care where cursor is.
" Preview window: assumes cursor is in preview window.
function! s:populate_hunk_preview_window(header, body)