13 Commits

Author SHA1 Message Date
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
Ingo Karkat 51c33feeff Allow to disable the new logic via g:ShowTrailingWhitespace_IsAutomaticBackground configuration flag 2020-12-19 22:31:11 +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
Ingo Karkat 3cfd997a4a Refactoring: Redefine s:HlGroupName as autoload variable and use in the :hi def link command as well 2020-12-19 19:05:38 +01:00
Ingo Karkat a4eac0f60e Cosmetics: Simplify dependencies, remove changelogs from ftplugin scripts 2020-07-11 19:54:26 +02:00
Ingo Karkat 5afb9081e1 Cosmetics: Delete changelogs 2018-12-15 21:55:54 +01:00
Ingo Karkat 7834ad9476 Move functions to autoload script 2018-12-15 20:39:47 +01:00
Ingo Karkat 6cfc9c9632 2018-12-15 20:38:55 +01:00
Ingo Karkat 64ad00f9fc 2018-12-15 20:38:17 +01:00
Ingo Karkat 36c06e6608 2018-12-15 20:38:06 +01:00
Ingo Karkat f6cc26e951 2018-12-15 20:38:06 +01:00
Ingo Karkat 2a53dbaf15 Move functions to autoload script
Rewrite example commands with new autoload functions.
2018-12-15 20:37:52 +01:00
Ingo Karkat 382f42b316 file creation 2018-12-15 20:37:52 +01:00