Compare commits

..

6 Commits

Author SHA1 Message Date
Peter Vandenberk
488c0555e4 Update README.mkd: offno for signcolumn
The valid values for `signcolumn` are '`auto`' ,'`no`', '`yes'` and '`number'` but not '`off'`:

```
E474: Invalid argument: signcolumn=off
```

Thanks!
2025-08-29 11:45:59 +01:00
Fred Hornsey
85ca3a0872 Use shellescape on paths in run_diff
In Neovim 0.11.1 within MSYS2 on Windows, gitgutter wasn't showing up.
After some flailing around, I found adding
`set shellcmdflag=-c shellxquote= shellxescape=`
[from here](https://github.com/neovim/neovim/issues/28384#issuecomment-2135921829),
got `:echo system('git --version')` working. The signs were still not
showing up, but there were files being dumped in my current working
directory that looked like corrupted Windows paths.

After using `let g:gitgutter_log=1` and looking at the log I found where
these temp files were made and I think I fixed it. I haven't tried the
non-msys2 Neovim (assuming that's different) or normal vim, but I
brought the change over and made sure it worked in Neovim on Linux.
2025-05-26 14:33:03 +01:00
Andy Stewart
a5ae0a5a18 Handle quickfix autocmd changing buffer
To keep things fast we turn off gitgutter in the current buffer during
quickfix commands, e.g. :vimgrep, and turn it back on afterwards.

However the user may have a quickfix autocmd which makes a different
buffer the current one, e.g. :cwindow. Previously this caused an error
because gitgutter expected the current buffer to remain current; now we
explicitly enable the original current buffer.

Fixes #904.
2025-05-05 15:15:44 +01:00
Andy Stewart
6620e5fbbe Document :write in preview window 2025-03-07 09:47:02 +00:00
Andy Stewart
33cb7744c3 Document re-preview moving into Nvim floating window
See #903.
2025-03-07 09:45:42 +00:00
Touko Hallasmaa
d3a9986fe8 Fix moving to floating window 2025-03-07 09:39:31 +00:00
5 changed files with 29 additions and 8 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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:]

View File

@@ -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-

View File

@@ -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
" }}}