6 Commits

Author SHA1 Message Date
Ingo Karkat 2b4f8f4ebf Reorg: Move s:GetColorModes() into ingo-library
As ingo#hlgroup#GetApplicableColorModes().
2021-06-09 08:12:01 +02:00
Ingo Karkat 62cee68ef9 Color: Reuse Get{Fore,Back]groundColor() from ingo-library
Now that we have a hard dependency on it, anyway.
2021-06-09 08:06:40 +02:00
Ingo Karkat 73969f24e2 Comments: Add note about ingo-library function availability 2020-12-21 08:37:07 +01:00
Ingo Karkat a12144ae80 FIX: Subsequent automatic background adaptations only work in recent Vim and :hi def link
Vim 8.2.2034 somehow restores a :hi def link after a colorscheme change, so the override of the adapted ShowTrailingWhitespace highlight group is automatically undone. But this does not happen in Vim 7.4.1689 and also not with :hi link (what a customization would use), so it cannot be relied on.
Instead, check for a linked highlight group only once on plugin startup and store a linked ID in g:ShowTrailingWhitespace_LinkedSyntaxId.
ShowTrailingWhitespace#Color#EnsureVisibleBackgroundColor() then reuses that original ID. It also sets a s:didAutomaticBackground flag if it had modified the ShowTrailingWhitespace highlight group, and restores the link if for a changed colorscheme this adaptation is no longer necessary.
2020-12-20 11:08:07 +01:00
Subhaditya Nath da39ee9c51 Compatibility: Neovim doesn't have gui_running
Neither has('gui_running') nor has('gui') return 1 in Neovim, even if a
gui is running.
2020-12-20 10:06:01 +01:00
Ingo Karkat bcc0c109d0 ENH: Check whether a linked highlight group has a background color, and use foreground color instead if not
The plugin links to the existing Error highlight group, assuming that this employs a (often red) background color. Some colorschemes (e.g. "koehler") only define a foreground color, though. That is of no use for the plugin's use case, though, because the trailing whitespace has no foreground, so only a background color can be used here. (Well, with :set list and 'listchars' having a "space" or "trail" setting, there would be some foreground to highlight, but it would be flimsy and the setting usually is off.)
To address this issue, we need to build in some intelligence: If the ShowTrailingWhitespace highlight group is not linked to another, the user has defined their own colors, and we expect them to know what they're doing. If it is linked, check for the existence of a background color (considering the "reverse" attribute, and that the background color may be equal to the default background, but explicitly set). If there's no effective background coloring, fall back to using the foreground color instead.
2020-12-19 22:18:10 +01:00