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.
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.
In neovim, has('patch1596') returns true, but there is no TerminalOpen event. So, it shows an error everytime neovim is launched. This commit aims to fix that
Closes#3
ingo#fs#path#Canonicalize() returns the absolute path to the directory, with is inconsistent with expand('%:p'). For consistency, always check the buffer name.
Offer public functions to implement custom commands or mappings for blacklist management.
Document optional dependency to ingo-library, add s:GetFilespec() compatibility shim, and use ingo#buffer#IsPersisted() if we have it.
But too late; the terminal buffer is first created as a normal empty buffer ([No Name], with empty 'buftype'). Only later :setlocal buftype=terminal happens (and the OptionSet event also isn't triggered for it, so we cannot use that to hook into). Fortunately, a separate TerminalOpen event was created.
As the default filter is defined in a separate autoload script, we can simply define the autocmd during sourcing of the script.