mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-14 14:23:52 -05:00
Compare commits
6 Commits
7b0b5098e3
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
488c0555e4 | ||
|
|
85ca3a0872 | ||
|
|
a5ae0a5a18 | ||
|
|
6620e5fbbe | ||
|
|
33cb7744c3 | ||
|
|
d3a9986fe8 |
@@ -81,7 +81,7 @@ Second, ensure your `updatetime` and `signcolumn` options are set appropriately.
|
||||
|
||||
When you make a change to a file tracked by git, the diff markers should appear automatically after a short delay. The delay is governed by vim's `updatetime` option; the default value is `4000`, i.e. 4 seconds, but I suggest reducing it to around 100ms (add `set updatetime=100` to your vimrc). Note `updatetime` also controls the delay before vim writes its swap file (see `:help updatetime`).
|
||||
|
||||
The `signcolumn` option can have any value except `'off'`.
|
||||
The `signcolumn` option can have any value except `'no'`.
|
||||
|
||||
|
||||
### Windows
|
||||
@@ -533,6 +533,8 @@ let g:gitgutter_async = 0
|
||||
|
||||
Add `let g:gitgutter_preview_win_floating = 1` to your `~/.vimrc`. Note that on Vim this prevents you staging (partial) hunks via the preview window.
|
||||
|
||||
On Neovim, the preview hunk command will move the cursor into the floating window if it is already open.
|
||||
|
||||
|
||||
#### The appearance of a floating/popup window for hunk previews
|
||||
|
||||
|
||||
@@ -116,7 +116,8 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort
|
||||
|
||||
" Write file from index to temporary file.
|
||||
let index_name = gitgutter#utility#get_diff_base(a:bufnr).':'.gitgutter#utility#base_path(a:bufnr)
|
||||
let cmd .= gitgutter#git(a:bufnr).' --no-pager show --textconv '.index_name.' > '.from_file.' || exit 0) && ('
|
||||
let cmd .= gitgutter#git(a:bufnr).' --no-pager show --textconv '.index_name
|
||||
let cmd .= ' > '.gitgutter#utility#shellescape(from_file).' || exit 0) && ('
|
||||
|
||||
elseif a:from ==# 'working_tree'
|
||||
let from_file = gitgutter#utility#repo_path(a:bufnr, 1)
|
||||
@@ -129,7 +130,8 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort
|
||||
let cmd .= ' -c "diff.noprefix=false"'
|
||||
let cmd .= ' -c "core.safecrlf=false"'
|
||||
endif
|
||||
let cmd .= ' diff --no-ext-diff --no-color -U0 '.g:gitgutter_diff_args.' -- '.from_file.' '.buff_file
|
||||
let cmd .= ' diff --no-ext-diff --no-color -U0 '.g:gitgutter_diff_args
|
||||
let cmd .= ' -- '.gitgutter#utility#shellescape(from_file).' '.gitgutter#utility#shellescape(buff_file)
|
||||
|
||||
" Pipe git-diff output into grep.
|
||||
if !a:preserve_full_diff && !empty(g:gitgutter_grep)
|
||||
|
||||
@@ -359,6 +359,11 @@ endfunction
|
||||
|
||||
|
||||
function! s:preview(hunk_diff)
|
||||
if g:gitgutter_preview_win_floating && exists('*nvim_set_current_win') && s:winid != 0
|
||||
call nvim_set_current_win(s:winid)
|
||||
return
|
||||
endif
|
||||
|
||||
let lines = split(a:hunk_diff, '\r\?\n')
|
||||
let header = lines[0:4]
|
||||
let body = lines[5:]
|
||||
|
||||
@@ -201,11 +201,13 @@ Commands for operating on a hunk:~
|
||||
:GitGutterUndoHunk Undo the hunk the cursor is in.
|
||||
|
||||
*gitgutter-:GitGutterPreviewHunk*
|
||||
:GitGutterPreviewHunk Preview the hunk the cursor is in.
|
||||
:GitGutterPreviewHunk Preview the hunk the cursor is in or, if you are using
|
||||
floating preview windows in Neovim and the window is
|
||||
already open, move the cursor into the window.
|
||||
|
||||
To stage part of the hunk, move to the preview window,
|
||||
delete any lines you do not want to stage, and
|
||||
|GitGutterStageHunk|.
|
||||
delete any lines you do not want to stage, and |write|
|
||||
or |GitGutterStageHunk|.
|
||||
|
||||
To close a non-floating preview window use |:pclose|
|
||||
or |CTRL-W_z| or |CTRL-W_CTRL-Z|; or normal window-
|
||||
|
||||
@@ -341,8 +341,18 @@ augroup gitgutter
|
||||
autocmd BufFilePre * call s:on_buffilepre(expand('<abuf>'))
|
||||
autocmd BufFilePost * call s:on_buffilepost(expand('<abuf>'))
|
||||
|
||||
autocmd QuickFixCmdPre *vimgrep* let b:gitgutter_was_enabled = gitgutter#utility#getbufvar(expand('<abuf>'), 'enabled') | GitGutterBufferDisable
|
||||
autocmd QuickFixCmdPost *vimgrep* if b:gitgutter_was_enabled | GitGutterBufferEnable | endif | unlet b:gitgutter_was_enabled
|
||||
autocmd QuickFixCmdPre *vimgrep*
|
||||
\ if gitgutter#utility#getbufvar(expand('<abuf>'), 'enabled') |
|
||||
\ let s:gitgutter_was_enabled = expand('<abuf>') |
|
||||
\ else |
|
||||
\ let s:gitgutter_was_enabled = 0 |
|
||||
\ endif |
|
||||
\ GitGutterBufferDisable
|
||||
autocmd QuickFixCmdPost *vimgrep*
|
||||
\ if s:gitgutter_was_enabled |
|
||||
\ call gitgutter#buffer_enable(s:gitgutter_was_enabled) |
|
||||
\ endif |
|
||||
\ unlet s:gitgutter_was_enabled
|
||||
augroup END
|
||||
|
||||
" }}}
|
||||
|
||||
Reference in New Issue
Block a user