1
0
mirror of https://github.com/amix/vimrc synced 2025-06-29 02:55:01 +08:00

Updated plugins

This commit is contained in:
Amir
2021-06-23 11:57:12 +02:00
parent 2dc46c9a65
commit fd420a0521
26 changed files with 208 additions and 73 deletions

View File

@ -77,13 +77,16 @@ nvim -u NONE -c "helptags vim-gitgutter/doc" -c q
### Windows
I recommend configuring vim-gitgutter with the full path to your git executable. For example:
There is a potential risk on Windows due to `cmd.exe` prioritising the current folder over folders in `PATH`. If you have a file named `git.*` (i.e. with any extension in `PATHEXT`) in your current folder, it will be executed instead of git whenever the plugin calls git.
You can avoid this risk by configuring the full path to your git executable. For example:
```viml
" This path probably won't work
let g:gitgutter_git_executable = 'C:\Program Files\Git\bin\git.exe'
```
This is to avoid a problem which occurs if you have file named `git.*` (i.e. with any extension in `PATHEXT`) in your current folder. `cmd.exe` prioritises the current folder over folders in `PATH` and will try to execute your file instead of the `git` binary.
Unfortunately I don't know the correct escaping for the path - if you do, please let me know!
### Getting started

View File

@ -64,7 +64,7 @@ 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()
if gitgutter#hunk#is_preview_window_open()
call gitgutter#hunk#preview()
endif
return
@ -95,7 +95,7 @@ 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()
if gitgutter#hunk#is_preview_window_open()
call gitgutter#hunk#preview()
endif
return
@ -249,7 +249,7 @@ function! s:hunk_op(op, ...)
let hunk_diff = join(hunk_header + hunk_body, "\n")."\n"
call s:goto_original_window()
call s:close_hunk_preview_window()
call gitgutter#hunk#close_hunk_preview_window()
call s:stage(hunk_diff)
endif
@ -427,7 +427,7 @@ endfunction
function! s:open_hunk_preview_window()
if g:gitgutter_preview_win_floating
if exists('*nvim_open_win')
call s:close_hunk_preview_window()
call gitgutter#hunk#close_hunk_preview_window()
let buf = nvim_create_buf(v:false, v:false)
" Set default width and height for now.
@ -446,9 +446,15 @@ function! s:open_hunk_preview_window()
call nvim_buf_set_name(buf, 'gitgutter://hunk-preview')
" Assumes cursor is in original window.
autocmd CursorMoved <buffer> ++once call s:close_hunk_preview_window()
autocmd CursorMoved <buffer> ++once call gitgutter#hunk#close_hunk_preview_window()
if g:gitgutter_close_preview_on_escape
nnoremap <buffer> <silent> <Esc> :call <SID>close_hunk_preview_window()<CR>
" Map <Esc> to close the floating preview.
nnoremap <buffer> <silent> <Esc> :<C-U>call gitgutter#hunk#close_hunk_preview_window()<CR>
" Ensure that when the preview window is closed, the map is removed.
autocmd User GitGutterPreviewClosed silent! nunmap <buffer> <Esc>
autocmd CursorMoved <buffer> ++once silent! nunmap <buffer> <Esc>
execute "autocmd WinClosed <buffer=".winbufnr(s:winid)."> doautocmd" s:nomodeline "User GitGutterPreviewClosed"
endif
return
@ -584,7 +590,7 @@ function! s:goto_original_window()
endfunction
function! s:close_hunk_preview_window()
function! gitgutter#hunk#close_hunk_preview_window()
let bufnr = s:winid != 0 ? winbufnr(s:winid) : s:preview_bufnr
call setbufvar(bufnr, '&modified', 0)
@ -601,12 +607,17 @@ function! s:close_hunk_preview_window()
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
function gitgutter#hunk#is_preview_window_open()
if g:gitgutter_preview_win_floating
if win_id2win(s:winid) > 0
execute win_id2win(s:winid).'wincmd c'
endif
endfor
else
for i in range(1, winnr('$'))
if getwinvar(i, '&previewwindow')
return 1
endif
endfor
endif
return 0
endfunction

View File

@ -63,15 +63,20 @@ Neovim:~
===============================================================================
WINDOWS *gitgutter-windows*
I recommend configuring vim-gitgutter with the full path to your git executable.
There is a potential risk on Windows due to `cmd.exe` prioritising the current
folder over folders in `PATH`. If you have a file named `git.*` (i.e. with
any extension in `PATHEXT`) in your current folder, it will be executed
instead of git whenever the plugin calls git.
You can avoid this risk by configuring the full path to your git executable.
For example:
>
" This path probably won't work
let g:gitgutter_git_executable = 'C:\Program Files\Git\bin\git.exe'
<
This is to avoid a problem which occurs if you have file named "git.*" (i.e.
with any extension in "PATHEXT") in your current folder. "cmd.exe" prioritises
the current folder over folders in 'PATH' and will try to execute your file
instead of the "git" binary.
Unfortunately I don't know the correct escaping for the path - if you do,
please let me know!
===============================================================================
@ -190,6 +195,12 @@ Commands for operating on a hunk:~
the original window with |CTRL-W_p|. Alternatively set
|g:gitgutter_close_preview_on_escape| and use <Esc>.
Two functions are available for your own logic:
>
gitgutter#hunk#is_preview_window_open()
gitgutter#hunk#close_hunk_preview_window()
<
Commands for folds:~
*gitgutter-:GitGutterFold*