33 Commits

Author SHA1 Message Date
Ingo Karkat 66beaf216c Adapt: Directly use ingo-library functions
Now that we have a hard dependency, anyway. Remove the fallback implementations, and inline s:IsPersistedBuffer().
2021-06-09 08:14:54 +02:00
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 386b75ad61 s:DetectAll(): Replace :windo with ingo#window#iterate#All() 2021-06-09 07:53:56 +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
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 44d0e795fb Cosmetics: Add missing scope, forgotten restore of &cpo 2020-12-19 19:01:15 +01:00
subnut 2b794708a0 Compatibility: Neovim does not have the TerminalOpen event
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
2020-07-13 15:08:45 +02:00
Ingo Karkat 72174fd591 FIX: Avoid creating jump when enabling / setting a local extra pattern 2019-02-22 22:12:45 +01:00
Ingo Karkat 78220a2e0a Minor: Use bufname('') for unnamed buffer check
ingo#fs#path#Canonicalize() returns the absolute path to the directory, with is inconsistent with expand('%:p'). For consistency, always check the buffer name.
2019-02-05 14:53:07 +01:00
Ingo Karkat 1e235a1f43 ENH: Make the default filter also consider session-local and persistent blacklists for files where highlighting should be off
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.
2019-02-04 17:03:20 +01:00
Ingo Karkat 5afb9081e1 Cosmetics: Delete changelogs 2018-12-15 21:55:54 +01:00
Ingo Karkat b7a6fa7999 Workaround: Terminal windows are highlighted, even though 'buftype' is set
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.
2018-12-15 21:51:25 +01:00
Ingo Karkat 1319c65a8d ENH: Keep previous (last accessed) window on :windo 2018-12-15 20:39:44 +01:00
Ingo Karkat 5b345a84f3 Also exclude quickfix and help buffers from detection 2018-12-15 20:39:42 +01:00
Ingo Karkat 325ab10f01 Make ShowTrailingWhitespace#IsSet() also handle Vim 7.0/1 where the g:ShowTrailingWhitespace variable is not set
Return 0 instead of causing a function abort.
2018-12-15 20:39:27 +01:00
Ingo Karkat a9fa91e0e8 Toggle to value 2 when enabled but the buffer is 2018-12-15 20:39:25 +01:00
Ingo Karkat c6f8835f86 Modularize conditionals 2018-12-15 20:39:02 +01:00
Ingo Karkat 9ee1ce31ad Toggle to value 2 when enabled but the buffer is filtered from showing trailing whitespace 2018-12-15 20:38:52 +01:00
Ingo Karkat bf037a4a41 Modularize conditionals
Also do not normally show 'binary' buffers.
2018-12-15 20:38:49 +01:00
Ingo Karkat 6724de30f0 Introduce g:ShowTrailingWhitespace_FilterFunc to disable highlighting for non-persisted and nomodifiable buffers 2018-12-15 20:38:17 +01:00
Ingo Karkat d2b1e31fb6 file creation 2018-12-15 20:38:17 +01:00
Ingo Karkat 7dcca8a9ae 2018-12-15 20:38:06 +01:00
Ingo Karkat f6694d3354 2018-12-15 20:38:06 +01:00
Ingo Karkat 5e20a920dd 2018-12-15 20:38:06 +01:00
Ingo Karkat 7e609242be 2018-12-15 20:37:58 +01:00
Ingo Karkat 1462312bf5 Introduce b:ShowTrailingWhitespace_ExtraPattern to be able to avoid some matches (e.g. a <Space> in column 1 in a buffer with filetype=diff) and ShowTrailingWhitespace#SetLocalExtraPattern() to set it 2018-12-15 20:37:55 +01:00
Ingo Karkat 41a433c7a9 2018-12-15 20:37:55 +01:00
Ingo Karkat 56736eb8fd file creation 2018-12-15 20:37:55 +01:00
Ingo Karkat cdba0fad67 file creation 2018-12-15 20:37:52 +01:00