From 0da302c28a08fe62c31c77ac854914affd2180b8 Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Thu, 30 Apr 2020 19:31:53 +0100 Subject: [PATCH] Do not adjust SignColumn highlight This was introduced in 07d7c9d4 because many colorschemes at the time had ugly sign columns, and people kept asking how to deal with it. These days there are many more plugins which use the sign column and consequently more colorschemes pay attention to the SignColumn highlight group. Therefore it no longer makes sense for vim-gitgutter to adjust the sign column's appearance. To restore the previous behaviour, add this to your vimrc: highlight! link SignColumn LineNr See #696. --- README.mkd | 15 +++++---------- autoload/gitgutter/highlight.vim | 8 -------- doc/gitgutter.txt | 22 +++++----------------- plugin/gitgutter.vim | 12 +++++++++--- 4 files changed, 19 insertions(+), 38 deletions(-) diff --git a/README.mkd b/README.mkd index 19bc556..810cf2d 100644 --- a/README.mkd +++ b/README.mkd @@ -290,19 +290,14 @@ Please note that vim-gitgutter won't override any colours or highlights you've s #### Sign column -By default vim-gitgutter will make the sign column look like the line number column. - -To customise your sign column's background color, first tell vim-gitgutter to leave it alone: +Set the `SignColumn` highlight group to change the sign column's colour. For example: ```viml -let g:gitgutter_override_sign_column_highlight = 0 -``` +" vim-gitgutter used to do this by default: +highlight! link SignColumn LineNr -And then either update your colorscheme's `SignColumn` highlight group or set it in your vimrc: - -```viml -highlight SignColumn ctermbg=whatever " terminal Vim -highlight SignColumn guibg=whatever " gVim/MacVim +" or you could do this: +highlight SignColumn guibg=whatever ctermbg=whatever ``` 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: diff --git a/autoload/gitgutter/highlight.vim b/autoload/gitgutter/highlight.vim index bdac712..b2da79c 100644 --- a/autoload/gitgutter/highlight.vim +++ b/autoload/gitgutter/highlight.vim @@ -64,14 +64,6 @@ function! gitgutter#highlight#linenr_toggle() abort endfunction -function! gitgutter#highlight#define_sign_column_highlight() abort - if g:gitgutter_override_sign_column_highlight - highlight! link SignColumn LineNr - else - highlight default link SignColumn LineNr - endif -endfunction - function! gitgutter#highlight#define_highlights() abort let [guibg, ctermbg] = s:get_background_colors('SignColumn') diff --git a/doc/gitgutter.txt b/doc/gitgutter.txt index 01e1365..a5c3576 100644 --- a/doc/gitgutter.txt +++ b/doc/gitgutter.txt @@ -306,7 +306,6 @@ Signs:~ |g:gitgutter_sign_removed| |g:gitgutter_sign_removed_first_line| |g:gitgutter_sign_modified_removed| - |g:gitgutter_override_sign_column_highlight| Hunk previews:~ @@ -450,20 +449,6 @@ Defaults: You can use unicode characters but not images. Signs must not take up more than 2 columns. - *g:gitgutter_override_sign_column_highlight* -Default: 1 - -Controls whether to make the sign column look like the line-number column (i.e. -the |hl-LineNr| highlight group). - -To customise your sign column's background color, first tell vim-gitgutter to -leave it alone: -> - let g:gitgutter_override_sign_column_highlight = 0 -< - -And then either update your colorscheme's |hlSignColumn| highlight group or set -it in your |vimrc|: Desired appearance Command ~ Same as line-number column highlight clear SignColumn @@ -596,8 +581,11 @@ c. Why can't I unstage staged changes? d. Why are the colours in the sign column weird? Your colorscheme is configuring the |hl-SignColumn| highlight group weirdly. - Please see |g:gitgutter_override_sign_column_highlight| on customising the - sign column. + Here are two ways you could change the colours: +> + highlight! link SignColumn LineNr + highlight SignColumn guibg=whatever ctermbg=whatever +< e. What happens if I also use another plugin which uses signs (e.g. Syntastic)? diff --git a/plugin/gitgutter.vim b/plugin/gitgutter.vim index 1a24998..f4f48c2 100644 --- a/plugin/gitgutter.vim +++ b/plugin/gitgutter.vim @@ -22,6 +22,13 @@ function! s:set(var, default) abort endif endfunction +function! s:obsolete(var) + if exists(a:var) + call gitgutter#utility#warn(a:var.' is obsolete and has no effect.') + endif +endfunction + + call s:set('g:gitgutter_preview_win_location', 'bo') if exists('*nvim_open_win') call s:set('g:gitgutter_preview_win_floating', 1) @@ -44,7 +51,7 @@ if (has('nvim-0.4.0') || exists('*sign_place')) && !exists('g:gitgutter_sign_all let g:gitgutter_sign_allow_clobber = 1 endif call s:set('g:gitgutter_sign_allow_clobber', 0) -call s:set('g:gitgutter_override_sign_column_highlight', 1) +call s:obsolete('g:gitgutter_override_sign_column_highlight') call s:set('g:gitgutter_sign_added', '+') call s:set('g:gitgutter_sign_modified', '~') call s:set('g:gitgutter_sign_removed', '_') @@ -90,7 +97,6 @@ if !empty(g:gitgutter_grep) endif endif -call gitgutter#highlight#define_sign_column_highlight() call gitgutter#highlight#define_highlights() call gitgutter#highlight#define_signs() @@ -267,7 +273,7 @@ augroup gitgutter autocmd VimResume * call gitgutter#all(1) endif - autocmd ColorScheme * call gitgutter#highlight#define_sign_column_highlight() | call gitgutter#highlight#define_highlights() + autocmd ColorScheme * call gitgutter#highlight#define_highlights() " Disable during :vimgrep autocmd QuickFixCmdPre *vimgrep* let g:gitgutter_enabled = 0