1
0
mirror of https://github.com/amix/vimrc synced 2025-06-16 09:35:01 +08:00

Updated plugins

This commit is contained in:
Amir
2021-05-05 10:25:00 +02:00
parent 8e54cbc92e
commit a7a471a207
265 changed files with 7773 additions and 1880 deletions

View File

@ -64,6 +64,9 @@ function! gitgutter#hunk#next_hunk(count) abort
if g:gitgutter_show_msg_on_hunk_jumping
redraw | echo printf('Hunk %d of %d', index(hunks, hunk) + 1, len(hunks))
endif
if s:is_preview_window_open()
call gitgutter#hunk#preview()
endif
return
endif
endif
@ -92,6 +95,9 @@ function! gitgutter#hunk#prev_hunk(count) abort
if g:gitgutter_show_msg_on_hunk_jumping
redraw | echo printf('Hunk %d of %d', index(hunks, hunk) + 1, len(hunks))
endif
if s:is_preview_window_open()
call gitgutter#hunk#preview()
endif
return
endif
endif
@ -257,9 +263,10 @@ 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')
call gitgutter#utility#warn('Cursor is not in a hunk')
elseif s:cursor_in_two_hunks()
let choice = input('Choose hunk: upper or lower (u/l)? ')
" Clear input
@ -269,7 +276,7 @@ function! s:hunk_op(op, ...)
elseif choice =~ 'l'
call a:op(gitgutter#diff#hunk_diff(bufnr, diff, 1))
else
call gitgutter#utility#warn('did not recognise your choice')
call gitgutter#utility#warn('Did not recognise your choice')
endif
else
let hunk_diff = gitgutter#diff#hunk_diff(bufnr, diff)
@ -293,7 +300,7 @@ function! s:stage(hunk_diff)
\ gitgutter#utility#cd_cmd(bufnr, g:gitgutter_git_executable.' '.g:gitgutter_git_args.' apply --cached --unidiff-zero - '),
\ diff)
if v:shell_error
call gitgutter#utility#warn('patch does not apply')
call gitgutter#utility#warn('Patch does not apply')
else
if exists('#User#GitGutterStage')
execute 'doautocmd' s:nomodeline 'User GitGutterStage'
@ -440,16 +447,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')
@ -457,14 +472,12 @@ function! s:open_hunk_preview_window()
endif
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'
silent! wincmd P
if &previewwindow
file gitgutter://hunk-preview
else
noautocmd execute g:gitgutter_preview_win_location &previewheight 'new gitgutter://hunk-preview'
doautocmd WinEnter
set previewwindow
endif
setlocal statusline=%{''}
doautocmd WinEnter
if exists('*win_getid')
let s:winid = win_getid()
else
@ -474,11 +487,21 @@ function! s:open_hunk_preview_window()
" 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>
" Ensure cursor goes to the expected window.
nnoremap <buffer> <silent> <Esc> :<C-U>wincmd p<Bar>pclose<CR>
endif
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)
@ -530,7 +553,8 @@ function! s:populate_hunk_preview_window(header, body)
setlocal nomodified
normal! G$
let height = min([winline(), &previewheight])
let hunk_height = max([body_length, winline()])
let height = min([hunk_height, &previewheight])
execute 'resize' height
1
@ -575,3 +599,14 @@ function! s:close_hunk_preview_window()
let s:winid = 0
let s:preview_bufnr = 0
endfunction
" Only makes sense for traditional, non-floating preview window.
function s:is_preview_window_open()
for i in range(1, winnr('$'))
if getwinvar(i, '&previewwindow')
return 1
endif
endfor
return 0
endfunction