Update 2026-01-25 09:38 OpenBSD/amd64-t14
This commit is contained in:
4
.vim/pack/plugins/start/vim-gitgutter/.github/issue_template.md
vendored
Normal file
4
.vim/pack/plugins/start/vim-gitgutter/.github/issue_template.md
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
> What is the latest commit SHA in your installed vim-gitgutter?
|
||||
|
||||
> What vim/nvim version are you on?
|
||||
|
||||
5
.vim/pack/plugins/start/vim-gitgutter/.gitignore
vendored
Normal file
5
.vim/pack/plugins/start/vim-gitgutter/.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/doc/tags
|
||||
/misc
|
||||
/test/*.actual
|
||||
*.log
|
||||
|
||||
@@ -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
|
||||
@@ -490,16 +490,6 @@ let g:gitgutter_map_keys = 0
|
||||
|
||||
See above for configuring maps for hunk-jumping and staging/undoing.
|
||||
|
||||
|
||||
#### Use a custom `grep` command
|
||||
|
||||
If you use an alternative to grep, you can tell vim-gitgutter to use it here.
|
||||
|
||||
```viml
|
||||
" Default:
|
||||
let g:gitgutter_grep = 'grep'
|
||||
```
|
||||
|
||||
#### To turn off vim-gitgutter by default
|
||||
|
||||
Add `let g:gitgutter_enabled = 0` to your `~/.vimrc`.
|
||||
@@ -533,6 +523,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
|
||||
|
||||
@@ -717,7 +709,6 @@ You can configure whether GitGutter preserves or clobbers other signs using `g:g
|
||||
|
||||
Here are some things you can check:
|
||||
|
||||
* Try adding `let g:gitgutter_grep=''` to your vimrc. If it works, the problem is grep producing non-plain output; e.g. ANSI escape codes or colours.
|
||||
* Verify `:echo system("git --version")` succeeds.
|
||||
* Verify your git config is compatible with the version of git returned by the command above.
|
||||
* Verify your Vim supports signs (`:echo has('signs')` should give `1`).
|
||||
|
||||
@@ -41,7 +41,7 @@ function! gitgutter#process_buffer(bufnr, force) abort
|
||||
|
||||
let diff = 'NOT SET'
|
||||
try
|
||||
let diff = gitgutter#diff#run_diff(a:bufnr, g:gitgutter_diff_relative_to, 0)
|
||||
let diff = gitgutter#diff#run_diff(a:bufnr, g:gitgutter_diff_relative_to)
|
||||
catch /gitgutter not tracked/
|
||||
call gitgutter#debug#log('Not tracked: '.gitgutter#utility#file(a:bufnr))
|
||||
catch /gitgutter assume unchanged/
|
||||
@@ -259,6 +259,10 @@ function! gitgutter#difforig()
|
||||
|
||||
vertical new
|
||||
set buftype=nofile
|
||||
if v:version >= 800
|
||||
setlocal bufhidden=wipe
|
||||
endif
|
||||
setlocal noswapfile
|
||||
let &filetype = filetype
|
||||
|
||||
if g:gitgutter_diff_relative_to ==# 'index'
|
||||
@@ -273,6 +277,7 @@ function! gitgutter#difforig()
|
||||
|
||||
0d_
|
||||
diffthis
|
||||
setlocal nomodifiable
|
||||
wincmd p
|
||||
diffthis
|
||||
endfunction
|
||||
|
||||
@@ -18,7 +18,6 @@ function! gitgutter#debug#debug()
|
||||
call s:git_version()
|
||||
call s:separator()
|
||||
|
||||
call s:grep_version()
|
||||
call s:separator()
|
||||
|
||||
call s:option('updatetime')
|
||||
@@ -41,14 +40,6 @@ function! s:git_version()
|
||||
call s:output( substitute(v, '\n$', '', '') )
|
||||
endfunction
|
||||
|
||||
function! s:grep_version()
|
||||
let v = system(g:gitgutter_grep.' --version')
|
||||
call s:output( substitute(v, '\n$', '', '') )
|
||||
|
||||
let v = system(g:gitgutter_grep.' --help')
|
||||
call s:output( substitute(v, '\%x00', '', 'g') )
|
||||
endfunction
|
||||
|
||||
function! s:option(name)
|
||||
if exists('+' . a:name)
|
||||
let v = eval('&' . a:name)
|
||||
|
||||
@@ -10,10 +10,6 @@ let s:counter = 0
|
||||
|
||||
" Returns a diff of the buffer against the index or the working tree.
|
||||
"
|
||||
" After running the diff we pass it through grep where available to reduce
|
||||
" subsequent processing by the plugin. If grep is not available the plugin
|
||||
" does the filtering instead.
|
||||
"
|
||||
" When diffing against the index:
|
||||
"
|
||||
" The buffer contents is not the same as the file on disk so we need to pass
|
||||
@@ -55,12 +51,9 @@ let s:counter = 0
|
||||
"
|
||||
" Arguments:
|
||||
"
|
||||
" bufnr - the number of the buffer to be diffed
|
||||
" from - 'index' or 'working_tree'; what the buffer is diffed against
|
||||
" preserve_full_diff - truthy to return the full diff or falsey to return only
|
||||
" the hunk headers (@@ -x,y +m,n @@); only possible if
|
||||
" grep is available.
|
||||
function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort
|
||||
" bufnr - the number of the buffer to be diffed
|
||||
" from - 'index' or 'working_tree'; what the buffer is diffed against
|
||||
function! gitgutter#diff#run_diff(bufnr, from) abort
|
||||
if gitgutter#utility#repo_path(a:bufnr, 0) == -1
|
||||
throw 'gitgutter path not set'
|
||||
endif
|
||||
@@ -116,7 +109,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,16 +123,11 @@ 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)
|
||||
let cmd .= ' | '.g:gitgutter_grep.' '.gitgutter#utility#shellescape('^@@ ')
|
||||
endif
|
||||
|
||||
" grep exits with 1 when no matches are found; git-diff exits with 1 when
|
||||
" differences are found. However we want to treat non-matches and
|
||||
" differences as non-erroneous behaviour; so we OR the command with one
|
||||
" git-diff exits with 1 when differences are found but we want to treat
|
||||
" differences as non-erroneous behaviour. So we OR the command with one
|
||||
" which always exits with success (0).
|
||||
let cmd .= ' || exit 0'
|
||||
|
||||
|
||||
@@ -263,7 +263,7 @@ function! s:hunk_op(op, ...)
|
||||
if gitgutter#utility#is_active(bufnr)
|
||||
" Get a (synchronous) diff.
|
||||
let [async, g:gitgutter_async] = [g:gitgutter_async, 0]
|
||||
let diff = gitgutter#diff#run_diff(bufnr, g:gitgutter_diff_relative_to, 1)
|
||||
let diff = gitgutter#diff#run_diff(bufnr, g:gitgutter_diff_relative_to)
|
||||
let g:gitgutter_async = async
|
||||
|
||||
call gitgutter#hunk#set_hunks(bufnr, gitgutter#diff#parse_diff(diff))
|
||||
@@ -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:]
|
||||
|
||||
@@ -312,11 +312,12 @@ function! s:obtain_file_renames(bufnr, base)
|
||||
endfunction
|
||||
|
||||
function! s:abs_path(bufnr, shellesc)
|
||||
let p = resolve(expand('#'.a:bufnr.':p'))
|
||||
|
||||
" Remove extra parts from fugitive's filepaths
|
||||
let p = substitute(substitute(p, '^fugitive:', '', ''), '\v\.git/\x{40,}/', '', '')
|
||||
|
||||
let p = expand('#'.a:bufnr.':p')
|
||||
if p =~ '\v^fugitive:/.*/(\x{40,})/'
|
||||
let p = FugitiveReal(expand('#'.a:bufnr.':p'))
|
||||
else
|
||||
let p = resolve(p)
|
||||
endif
|
||||
return a:shellesc ? gitgutter#utility#shellescape(p) : p
|
||||
endfunction
|
||||
|
||||
|
||||
@@ -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-
|
||||
@@ -348,10 +350,6 @@ Git:~
|
||||
|g:gitgutter_diff_relative_to|
|
||||
|g:gitgutter_diff_base|
|
||||
|
||||
Grep:~
|
||||
|
||||
|g:gitgutter_grep|
|
||||
|
||||
Signs:~
|
||||
|
||||
|g:gitgutter_signs|
|
||||
@@ -444,23 +442,6 @@ via :0Gclog), gitgutter sets the diff base to the parent of the current revision
|
||||
This setting is ignore when the diff is relative to the working tree
|
||||
(|g:gitgutter_diff_relative_to|).
|
||||
|
||||
*g:gitgutter_grep*
|
||||
Default: 'grep'
|
||||
|
||||
The plugin pipes the output of git-diff into grep to minimise the amount of data
|
||||
vim has to process. Set this option if grep is not on your path.
|
||||
|
||||
grep must produce plain-text output without any ANSI escape codes or colours.
|
||||
Use this option to turn off colours if necessary.
|
||||
>
|
||||
let g:gitgutter_grep = 'grep --color=never'
|
||||
<
|
||||
If you do not want to use grep at all (perhaps to debug why signs are not
|
||||
showing), set this option to an empty string:
|
||||
>
|
||||
let g:gitgutter_grep = ''
|
||||
<
|
||||
|
||||
*g:gitgutter_signs*
|
||||
Default: 1
|
||||
|
||||
@@ -732,33 +713,26 @@ TROUBLESHOOTING *gitgutter-troubleshooting*
|
||||
|
||||
When no signs are showing at all:~
|
||||
|
||||
1. Try bypassing grep with:
|
||||
>
|
||||
let g:gitgutter_grep = ''
|
||||
<
|
||||
If it works, the problem is grep outputting ANSI escape codes. Use this
|
||||
option to pass arguments to grep to turn off the escape codes.
|
||||
|
||||
2. Verify git is on your path:
|
||||
1. Verify git is on your path:
|
||||
>
|
||||
:echo system('git --version')
|
||||
<
|
||||
|
||||
3. Verify your git config is compatible with the version of git return by the
|
||||
2. Verify your git config is compatible with the version of git return by the
|
||||
command above.
|
||||
|
||||
4. Verify your Vim supports signs. The following should give 1:
|
||||
3. Verify your Vim supports signs. The following should give 1:
|
||||
>
|
||||
:echo has('signs')
|
||||
<
|
||||
|
||||
5. Check whether the plugin thinks git knows about your file:
|
||||
4. Check whether the plugin thinks git knows about your file:
|
||||
>
|
||||
:echo getbufvar('','gitgutter').path
|
||||
:echo b:gitgutter.path
|
||||
<
|
||||
If the result is -2, the plugin thinks your file is not tracked by git.
|
||||
|
||||
6. Check whether the signs have been placed:
|
||||
5. Check whether the signs have been placed:
|
||||
>
|
||||
:sign place group=gitgutter
|
||||
<
|
||||
|
||||
@@ -90,19 +90,8 @@ if !executable(g:gitgutter_git_executable)
|
||||
finish
|
||||
endif
|
||||
|
||||
let default_grep = 'grep'
|
||||
let g:gitgutter_grep = get(g:, 'gitgutter_grep', default_grep)
|
||||
if !empty(g:gitgutter_grep)
|
||||
if executable(split(g:gitgutter_grep)[0])
|
||||
if $GREP_OPTIONS =~# '--color=always'
|
||||
let g:gitgutter_grep .= ' --color=never'
|
||||
endif
|
||||
else
|
||||
if g:gitgutter_grep !=# default_grep
|
||||
call gitgutter#utility#warn('Cannot find '.g:gitgutter_grep.'. Please check g:gitgutter_grep.')
|
||||
endif
|
||||
let g:gitgutter_grep = ''
|
||||
endif
|
||||
if exists('g:gitgutter_grep')
|
||||
call gitgutter#utility#warn('g:gitgutter_grep is obsolete')
|
||||
endif
|
||||
|
||||
call gitgutter#highlight#define_highlights()
|
||||
@@ -341,8 +330,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