sindrets / diffview.nvim

Single tabpage interface for easily cycling through diffs for all modified files for any git rev.
Other
3.85k stars 105 forks source link

The 'untracked' git status uses the wrong highlight #322

Closed charbelnicolas closed 1 year ago

charbelnicolas commented 1 year ago

It looks like the DiffviewStatusUntracked highlight has no effect on untracked files:

20230316_213612

colors[7] here is supposed to be pink, not green:

20230316_213627

wal --preview shows color 7 as pink:

20230316_213656

Am I doing something wrong here? Any help is appreciated.

sindrets commented 1 year ago

I'm guessing that your color scheme or something else changes it after you call nvim_set_hl(). These sort of highlight tweaks should be performed in a :h ColorScheme auto command callback such that they are applied after your color scheme.

Another thing to keep in mind: I've seen an anti-pattern of color schemes that use scheduling or similar to set some of their hl groups at some later time. This makes the ColorScheme auto command much less useful, as then the color scheme might override your tweaks at some arbitrary point you have no control over. So if you're having trouble figuring out what is overriding the hl, check the source code of your color scheme.

Finally: you can always see the current values of any hl group with:

:hi DiffviewStatusUntracked
charbelnicolas commented 1 year ago

20230317_101839 20230317_101854 20230317_100940 20230317_100848 20230317_100920

Unless the ? means something else other than untracked, I think somewhere in the plugin DiffviewStatusAdded is overriding DiffviewStatusUntracked.

If I change DiffviewStatusAdded to the color I want for the untracked, it works (but now I have pink As all over the place):

20230317_101334 20230317_101404

20230317_101310 20230317_101450 20230317_101509

charbelnicolas commented 1 year ago

Or maybe it's just that I don't know what the untracked color is for...

sindrets commented 1 year ago

Okay, my bad, I see now that I've actually mapped the untracked status to the wrong hl and just never noticed....

https://github.com/sindrets/diffview.nvim/blob/ebcbe90401555272025006db00da0972f7e0db63/lua/diffview/hl.lua#L354

I'll fix it soon.