Commit Graph

38 Commits

Author SHA1 Message Date
Yuxin Wu
3475e974d6 Link highlight of GitGutterChangeDeleteLine to GitGutterChangeLine 2023-04-27 14:01:12 +01:00
Andy Stewart
e9871cf952 Capitalise NONE for consistency
Although group names are case-insensitive:

- Vim's docs use NONE;
- the code already uses NONE elsewhere.
2022-02-02 08:49:44 +00:00
Mateusz Piotrowski
6039b37440 Always pass some group name to sign arguments
E.g., passing an empty group name to the sign argument linehl (e.g.,
"linehl=") causes the following error:

```
Error detected while processing /usr/home/0mp/.vim/plugged/vim-gitgutter/plugin/gitgutter.vim[96]..function gitgutter#highlight#define_signs[10]..<SNR>56_define_sign_line_highlights:
line    9:
E1249: Group name missing for linehl
```

This patch makes the those errors go away by passing "None" when no
group name is needed.
2022-02-02 08:49:12 +00:00
naohiro ono
4adaa7adaa Make intra-highlights customizable 2021-08-06 16:13:14 +01:00
Andy Stewart
82f3ea6a40 Fix typo in highlight group name
See #727.
2020-08-05 12:19:08 +01:00
Andy Stewart
642cef87f4 Treat cleared highlight groups as not set
Setting a colorscheme often clears all existing highlight groups.  When
the plugin subsequently sets up its colours, it sees that the GitGutter*
groups exist and leaves them alone - even though they have been cleared.

This change means cleared groups do get their colours set up again.

See #727.
2020-08-05 12:15:27 +01:00
Andy Stewart
b356cc9a7d Set background colour on GitGutterChangeDelete 2020-05-01 16:13:53 +01:00
Andy Stewart
76d1cf609d Do not set background on existing GitGutter* highlights unless requested
If GitGutter* highlight groups already exist, they were declared
deliberately (either by the colorscheme maintainer or the user).  So do
not adjust them.

However if you would like to make the signs' backgrounds match the sign
column, you can do this:

    let g:gitgutter_set_sign_backgrounds = 1
2020-04-30 19:43:02 +01:00
Andy Stewart
0da302c28a 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.
2020-04-30 19:41:09 +01:00
Andy Stewart
f458f43cf2 Fall back to sensible sign colours
Do this when there are no existing GitGutter* highlight groups and the
Diff* highlight groups have the same foreground colours.
2020-04-28 17:50:54 +01:00
Andy Stewart
f411d8680e Do not override existing diff* highlight groups
See #701.
2020-04-25 20:00:24 +01:00
Andy Stewart
3fb9a59a06 Handle existing GitGutter* highlight groups which are links
Fixes #701.
2020-04-25 13:51:29 +01:00
Andy Stewart
8a380e2f90 Ensure good diff syntax highlighting in preview
Specifically, make it match the signs' foreground colours; and clear the
backgrounds so the GitGutter{Add,Delete}IntraLine highlights' "reverse"
colours work properly.
2020-04-25 13:33:05 +01:00
Andy Stewart
3cb5cbfd18 Revert preview window diff colours 2020-04-25 11:38:46 +01:00
Andy Stewart
f34ce3aa6b Set default diff colours for the preview window
Some colourschemes forget this.
2020-04-25 11:27:58 +01:00
Andy Stewart
8db2fc5da0 Set correct background on existing GitGutter* highlight groups
Previously if the user or the colourscheme had already defined
GitGutter* highlight groups, the plugin would leave their backgrounds
alone.  This pushed the responsibility for figuring out and specifying
the correct backgrounds onto the user or colourscheme maintainer.

With this change the plugin now sets the correct background on existing
GitGutter* highlight groups.

Also, the documentation was simplified so it is clearer how to set your
own colours for the signs.
2020-04-25 11:17:34 +01:00
Andy Stewart
178764e9a1 Whitespace 2019-09-30 13:17:23 +01:00
Andy Stewart
54eff3e545 Clarify variable name 2019-09-30 12:56:10 +01:00
Andy Stewart
92deed378d Add cterm value for intra-line highlights 2019-09-18 15:54:21 +01:00
Andy Stewart
fdecc23368 Hunk previews highlight intra-line changes.
Closes #577.
2019-09-18 11:55:01 +01:00
Andy Stewart
afe94ede1b 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.
2019-08-16 12:06:28 +01:00
delphinus
f2bf8376ae Fix #639: Use more careful way to enable numhl
The development versions of v0.3.2 also report `has('nvim-0.3.2')` to be
true even if they do not support the `numhl` feature. So here it catches
and ignores the possible errors.
2019-08-12 12:08:47 +01:00
delphinus
67b3ed65e3 Enable to toggle numhl 2019-08-08 16:40:35 +01:00
delphinus
78876150ae Add logic for sign with numhl 2019-08-08 16:40:35 +01:00
Jonny Bylsma
25f3c56335 Make conditional style consistent with codebase 2019-06-04 11:42:20 +01:00
Jonny Bylsma
8696c880df In get_hl(), discard returned synIDattr values of -1 2019-06-04 11:42:20 +01:00
Daniel Hahler
9f21e3dbba Simplify getting highlight fg/bg 2019-06-03 11:32:09 +01:00
Andy Stewart
fd834e48ee Combine Diff* foreground colours with SignColumn's background.
For default sign colours.

It seems the Diff* highlight groups are generally designed for line
highlighting so they have background colours which differ from the main
background colour.  While desirable for line highlights, this isn't what
we want for the signs.
2019-02-04 14:45:58 +00:00
Andy Stewart
afa4f2ddf0 Use the Diff* highlight groups by default.
This change makes the plugin default to using the highlight groups
defined by the colorscheme instead of hardcoding its own foreground
colours.

If you liked the previous colours you can restore them by adding these
lines to your vimrc:

highlight GitGutterAdd    guifg=#009900 guibg=<X> ctermfg=2 ctermb=<Y>
highlight GitGutterChange guifg=#bbbb00 guibg=<X> ctermfg=3 ctermb=<Y>
highlight GitGutterDelete guifg=#ff2222 guibg=<X> ctermfg=1 ctermb=<Y>

– where you should replace <X> and <Y> are the background colour of your
SignColumn in the gui and the terminal respectively.

For example, with the solarized colorscheme and a dark background,
guibg=#073642 and ctermbg=0.

Closes #545, #560.
2019-01-25 17:27:08 +00:00
Andy Stewart
6f8acdcea1 Whitespace. 2018-10-18 09:48:57 +01:00
Andy Stewart
89c34f74cb Display unambiguous sign when hunks overlap.
See #556.
2018-10-18 09:45:55 +01:00
Andy Stewart
5bfe5b9209 Big refactor.
- Hunk stage/undo/preview no longer saves the buffer.
- Hunk undo no longer makes locations go out of sync.
- Grep can be opted out of (grep output with ansi escapes is number one cause
  of issues).
- Replaced g:gitgutter_grep_command with g:gitgutter_grep.
- Always runs git-diff the same way instead of in two possible ways.
- Separated detection of git tracking from diffing.
- Simplified path handling.
- Removed support for xolox shell: Windows taskbar does not flash with async
  jobs.
- Removed g:gitgutter_{eager,realtime}.
- Simplified implementation generally.
2018-02-12 14:25:11 +00:00
Lucas Hoffmann
f2ff2321cd Fix small typo in highlight group name 2017-10-16 08:37:47 +02:00
Andy Stewart
cae4f72aa1 Abort functions at first error. 2016-05-13 14:14:41 +01:00
Andy Stewart
b18e23cdfa Fix broken highlight link for GitGutterChangeDeleteLine.
Thanks to @JacobLeach for pointing this out.
2015-10-21 09:43:35 +01:00
Andy Stewart
07d7c9d478 Override SignColumn highlight group by default.
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
2015-03-31 16:23:55 +02:00
Andy Stewart
39f0119096 Whitespace. 2014-10-17 09:24:52 +02:00
Andy Stewart
fed2dbad34 Move every function into gitgutter namespace.
This makes profiling much easier.
2014-06-26 11:09:29 +02:00