Skip to content

Commit

Permalink
Override SignColumn highlight group by default.
Browse files Browse the repository at this point in the history
Most colorschemes (e.g. solarized) don't give any thought to the
SignColumn highlight group so generally the sign column is ugly.

With this change vim-gitgutter defaults to making the sign column look
like the line number column.

Solarized users no longer need `highlight clear SignColumn` in their
vimrc :)

To stop vim-gitgutter from overriding the SignColumn highlight, add this
to your vimrc:

    let g:gitgutter_override_sign_column_highlight = 0
  • Loading branch information
airblade committed Mar 31, 2015
1 parent 8345c35 commit 07d7c9d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 27 deletions.
21 changes: 8 additions & 13 deletions README.mkd
Original file line number Diff line number Diff line change
Expand Up @@ -183,24 +183,19 @@ Please note that vim-gitgutter won't override any colours or highlights you've s

#### Sign column

The background colour of the sign column is controlled by the `SignColumn` highlight group. This will be either set in your colorscheme or Vim's default.
By default vim-gitgutter will make the sign column look like the line number column.

To find out where it's set, and to what it's set, use `:verbose highlight SignColumn`.
To customise your sign column's background color, first tell vim-gitgutter to leave it alone:

If your `SignColumn` is not set (`:highlight SignColumn` gives you `SignColumn xxx cleared`), vim-gitgutter will set it to the same as your line number column (i.e. the `LineNr` highlight group).

To change your sign column's appearance, update your colorscheme or `~/.vimrc` like this:

* For the same appearance as your line number column: `highlight clear SignColumn`
* For a specific appearance on terminal Vim: `highlight SignColumn ctermbg=whatever`
* For a specific appearance on gVim/MacVim: `highlight SignColumn guibg=whatever`
```viml
let g:gitgutter_override_sign_column_highlight = 0
```

If you use [solarized](https://github.com/altercation/vim-colors-solarized)-dark, try the following snippet in your `~/.vimrc`:
And then either update your colorscheme's `SignColumn` highlight group or set it in your vimrc:

```viml
set background=dark
colorscheme solarized
highlight clear SignColumn
highlight SignColumn ctermbg=whatever " terminal Vim
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. If you would always like the sign column to be there, add `let g:gitgutter_sign_column_always = 1` to your `~/.vimrc`.
Expand Down
6 changes: 5 additions & 1 deletion autoload/gitgutter/highlight.vim
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
function! gitgutter#highlight#define_sign_column_highlight()
highlight default link SignColumn LineNr
if g:gitgutter_override_sign_column_highlight
highlight! link SignColumn LineNr
else
highlight default link SignColumn LineNr
endif
endfunction

function! gitgutter#highlight#define_highlights()
Expand Down
20 changes: 7 additions & 13 deletions doc/gitgutter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,23 +130,17 @@ set in your colorscheme.

SIGN COLUMN

The background colour of the sign column is controlled by the |hlSignColumn|
highlight group. This will be either set in your colorscheme or Vim's default.
By default vim-gitgutter will make the sign column look like the line number
column (i.e. the |hl-LineNr| highlight group).

To find out where it's set, and to what it's set, use:
To customise your sign column's background color, first tell vim-gitgutter to
leave it alone:
>
:verbose highlight SignColumn
let g:gitgutter_override_sign_column_highlight = 0
<

If your `SignColumn` is not set, i.e if
>
:highlight SignColumn " gives you `SignColumn xxx cleared`
<
vim-gitgutter will set it to the same as your line number column (i.e. the
|hl-LineNr| highlight group).

To change your sign column's appearance, update your colorscheme or |vimrc|
like this:
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
Expand Down
1 change: 1 addition & 0 deletions plugin/gitgutter.vim
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ call s:set('g:gitgutter_max_signs', 500)
call s:set('g:gitgutter_signs', 1)
call s:set('g:gitgutter_highlight_lines', 0)
call s:set('g:gitgutter_sign_column_always', 0)
call s:set('g:gitgutter_override_sign_column_highlight', 1)
call s:set('g:gitgutter_realtime', 1)
call s:set('g:gitgutter_eager', 1)
call s:set('g:gitgutter_sign_added', '+')
Expand Down

0 comments on commit 07d7c9d

Please sign in to comment.