mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-08 11:33:48 -05:00
Do not use a dummy sign to keep the sign column open.
This removes the g:gitgutter_sign_column_always option. Vim 7.4.2201 introduced the |signcolumn| option to configure when the signcolumn is visible, building in behaviour which the plugin provided manually. Although it would be good to maintain this feature for older Vims, the complexity added by the code outweighs the benefit of backward compatibility.
This commit is contained in:
@@ -159,7 +159,7 @@ With Neovim 0.3.2 or higher, you can turn line number highlighting on and off (d
|
||||
|
||||
Note that if you have line highlighting on and signs off, you will have an empty sign column – more accurately, a sign column with invisible signs. This is because line highlighting requires signs and Vim always shows the sign column even if the signs are invisible.
|
||||
|
||||
If you switch off both line highlighting and signs, you won't see the sign column. That is unless you configure the sign column always to be there (see Sign Column section).
|
||||
If you switch off both line highlighting and signs, you won't see the sign column.
|
||||
|
||||
To keep your Vim snappy, vim-gitgutter will suppress the signs when a file has more than 500 changes. As soon as the number of changes falls below the limit vim-gitgutter will show the signs again. You can configure the threshold with:
|
||||
|
||||
@@ -293,11 +293,8 @@ highlight SignColumn guibg=whatever " gVim/MacVim
|
||||
By default the sign column will appear when there are signs to show and disappear when there aren't. To always have the sign column, add to your vimrc:
|
||||
|
||||
```viml
|
||||
if exists('&signcolumn') " Vim 7.4.2201
|
||||
" Vim 7.4.2201
|
||||
set signcolumn=yes
|
||||
else
|
||||
let g:gitgutter_sign_column_always = 1
|
||||
endif
|
||||
```
|
||||
|
||||
GitGutter can preserve or ignore non-gitgutter signs. On Vim and Neovim < 0.4.0, gitgutter will default to preserving other signs; on Neovim >= 0.4.0 gitgutter defaults to ignoring them. You can control this with:
|
||||
|
||||
@@ -175,7 +175,6 @@ endfunction
|
||||
|
||||
function! s:clear(bufnr)
|
||||
call gitgutter#sign#clear_signs(a:bufnr)
|
||||
call gitgutter#sign#remove_dummy_sign(a:bufnr, 1)
|
||||
call gitgutter#hunk#reset(a:bufnr)
|
||||
call s:reset_tick(a:bufnr)
|
||||
call gitgutter#utility#setbufvar(a:bufnr, 'path', '')
|
||||
|
||||
@@ -4,7 +4,6 @@ function! gitgutter#highlight#line_disable() abort
|
||||
|
||||
if !g:gitgutter_signs
|
||||
call gitgutter#sign#clear_signs(bufnr(''))
|
||||
call gitgutter#sign#remove_dummy_sign(bufnr(''), 0)
|
||||
endif
|
||||
|
||||
redraw!
|
||||
@@ -37,7 +36,6 @@ function! gitgutter#highlight#linenr_disable() abort
|
||||
|
||||
if !g:gitgutter_signs
|
||||
call gitgutter#sign#clear_signs(bufnr(''))
|
||||
call gitgutter#sign#remove_dummy_sign(bufnr(''), 0)
|
||||
endif
|
||||
|
||||
redraw!
|
||||
@@ -113,7 +111,6 @@ function! gitgutter#highlight#define_signs() abort
|
||||
sign define GitGutterLineRemovedFirstLine
|
||||
sign define GitGutterLineRemovedAboveAndBelow
|
||||
sign define GitGutterLineModifiedRemoved
|
||||
sign define GitGutterDummy
|
||||
|
||||
call s:define_sign_text()
|
||||
call gitgutter#highlight#define_sign_text_highlights()
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
" Note also we currently never reset s:next_sign_id.
|
||||
let s:first_sign_id = 3000
|
||||
let s:next_sign_id = s:first_sign_id
|
||||
let s:dummy_sign_id = s:first_sign_id - 1
|
||||
" Remove-all-signs optimisation requires Vim 7.3.596+.
|
||||
let s:supports_star = v:version > 703 || (v:version == 703 && has("patch596"))
|
||||
|
||||
@@ -27,7 +26,6 @@ function! gitgutter#sign#disable() abort
|
||||
|
||||
if !g:gitgutter_highlight_lines
|
||||
call gitgutter#sign#clear_signs(bufnr(''))
|
||||
call gitgutter#sign#remove_dummy_sign(bufnr(''), 0)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
@@ -40,7 +38,7 @@ function! gitgutter#sign#toggle() abort
|
||||
endfunction
|
||||
|
||||
|
||||
" Removes gitgutter's signs (excluding dummy sign) from the buffer being processed.
|
||||
" Removes gitgutter's signs from the buffer being processed.
|
||||
function! gitgutter#sign#clear_signs(bufnr) abort
|
||||
call s:find_current_signs(a:bufnr)
|
||||
|
||||
@@ -65,21 +63,6 @@ function! gitgutter#sign#update_signs(bufnr, modified_lines) abort
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:add_dummy_sign(bufnr) abort
|
||||
if !gitgutter#utility#getbufvar(a:bufnr, 'dummy_sign')
|
||||
execute "sign place" s:dummy_sign_id "line=" . 9999 "name=GitGutterDummy buffer=" . a:bufnr
|
||||
call gitgutter#utility#setbufvar(a:bufnr, 'dummy_sign', 1)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! gitgutter#sign#remove_dummy_sign(bufnr, force) abort
|
||||
if gitgutter#utility#getbufvar(a:bufnr, 'dummy_sign') && (a:force || !g:gitgutter_sign_column_always)
|
||||
execute "sign unplace" s:dummy_sign_id "buffer=" . a:bufnr
|
||||
call gitgutter#utility#setbufvar(a:bufnr, 'dummy_sign', 0)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
"
|
||||
" Internal functions
|
||||
"
|
||||
@@ -90,7 +73,6 @@ function! s:find_current_signs(bufnr) abort
|
||||
if !g:gitgutter_sign_allow_clobber
|
||||
let other_signs = [] " [<line_number (number),...]
|
||||
endif
|
||||
let dummy_sign_placed = 0
|
||||
|
||||
redir => signs
|
||||
silent execute "sign place buffer=" . a:bufnr
|
||||
@@ -101,9 +83,6 @@ function! s:find_current_signs(bufnr) abort
|
||||
" We assume splitting is faster than a regexp.
|
||||
let components = split(sign_line)
|
||||
let name = split(components[2], '=')[1]
|
||||
if name =~# 'GitGutterDummy'
|
||||
let dummy_sign_placed = 1
|
||||
else
|
||||
let line_number = str2nr(split(components[0], '=')[1])
|
||||
if name =~# 'GitGutter'
|
||||
let id = str2nr(split(components[1], '=')[1])
|
||||
@@ -119,10 +98,8 @@ function! s:find_current_signs(bufnr) abort
|
||||
call add(other_signs, line_number)
|
||||
endif
|
||||
endif
|
||||
end
|
||||
endfor
|
||||
|
||||
call gitgutter#utility#setbufvar(a:bufnr, 'dummy_sign', dummy_sign_placed)
|
||||
call gitgutter#utility#setbufvar(a:bufnr, 'gitgutter_signs', gitgutter_signs)
|
||||
if !g:gitgutter_sign_allow_clobber
|
||||
call gitgutter#utility#setbufvar(a:bufnr, 'other_signs', other_signs)
|
||||
@@ -150,11 +127,7 @@ endfunction
|
||||
|
||||
function! s:remove_signs(bufnr, sign_ids, all_signs) abort
|
||||
if a:all_signs && s:supports_star && (g:gitgutter_sign_allow_clobber || empty(gitgutter#utility#getbufvar(a:bufnr, 'other_signs')))
|
||||
let dummy_sign_present = gitgutter#utility#getbufvar(a:bufnr, 'dummy_sign')
|
||||
execute "sign unplace * buffer=" . a:bufnr
|
||||
if dummy_sign_present
|
||||
execute "sign place" s:dummy_sign_id "line=" . 9999 "name=GitGutterDummy buffer=" . a:bufnr
|
||||
endif
|
||||
else
|
||||
for id in a:sign_ids
|
||||
execute "sign unplace" id
|
||||
|
||||
@@ -292,7 +292,6 @@ Signs:~
|
||||
|g:gitgutter_sign_removed|
|
||||
|g:gitgutter_sign_removed_first_line|
|
||||
|g:gitgutter_sign_modified_removed|
|
||||
|g:gitgutter_sign_column_always|
|
||||
|g:gitgutter_override_sign_column_highlight|
|
||||
|
||||
Terminal:~
|
||||
@@ -409,17 +408,6 @@ Defaults:
|
||||
You can use unicode characters but not images. Signs must not take up more than
|
||||
2 columns.
|
||||
|
||||
*g:gitgutter_sign_column_always*
|
||||
Default: 0
|
||||
|
||||
This legacy option controls whether the sign column should always be shown, even
|
||||
if there are no signs to display.
|
||||
|
||||
From Vim 7.4.2201, use 'signcolumn' instead:
|
||||
>
|
||||
set signcolumn=yes
|
||||
<
|
||||
|
||||
*g:gitgutter_override_sign_column_highlight*
|
||||
Default: 1
|
||||
|
||||
|
||||
@@ -32,13 +32,6 @@ if has('nvim-0.4.0') && !exists('g:gitgutter_sign_allow_clobber')
|
||||
let g:gitgutter_sign_allow_clobber = 1
|
||||
endif
|
||||
call s:set('g:gitgutter_sign_allow_clobber', 0)
|
||||
call s:set('g:gitgutter_sign_column_always', 0)
|
||||
if g:gitgutter_sign_column_always && exists('&signcolumn')
|
||||
" Vim 7.4.2201.
|
||||
set signcolumn=yes
|
||||
let g:gitgutter_sign_column_always = 0
|
||||
call gitgutter#utility#warn('please replace "let g:gitgutter_sign_column_always=1" with "set signcolumn=yes"')
|
||||
endif
|
||||
call s:set('g:gitgutter_override_sign_column_highlight', 1)
|
||||
call s:set('g:gitgutter_sign_added', '+')
|
||||
call s:set('g:gitgutter_sign_modified', '~')
|
||||
|
||||
Reference in New Issue
Block a user