Error underlines and helpfile tweaks #203
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TL;DR:
s:ft_undercurl
helpStar
s andhelpBar
s properly #161 that I closed for some reason I don't remember) default-linking toIgnore
now highlight properly. This is only relevant for helpfile writers, and makes no change for helpfile readers.Changes
Underlines
One of the problems with most of the current error highlighting is that it disappears when that line is active, at least with
set cursorline
.This screenshot demonstrates the current solution:
(Note that the cursor colour is not the default for papercolour; that change is in my vimrc, and not part of this PR)
Note that the behaviour of the background for both warning and error has not changed; without the underline, it's impossible to tell where the error is in a line without first leaving the line. This is annoying while writing code with an LSP
Note that the warning underline being black is not fully intentional, but I couldn't find a colour that worked well with yellow. Using the same colour as the background colour makes the underline have far too little contrast - same with the error undercurl, but
s:fg_red
exists, so that's a non-issue.Terminal caveats
In terminal vim,
cterm=underline
is used instead ofundercurl
. This is an intentional decision because, for reasons I don't fully understand, settingcterm=undercurl
results in no underline of any kind in gnome terminal. Same with ignoringcterm
fully and only settinggui
. According to the docs,undercurl
is supposed to fall back to underline whenundercurl
isn't available, but I was unable to get this to work within a few minutes, so I didn't bother looking deeper into it. I assume I'm missing something obvious, but I'm leaving this as an exercise for someone else with the patience to figure it out. In either case, the error visibility problem is still fixed even though the type of underline isn't quite right.Non-GUI and non-256 terminals have also not been handled, and instead gets a blank
s:ft_undercurl
. I'm not sure whether or not it supportscterm=underline
at all, and I'd rather not break anything.Affected groups
Only coc.nvim's highlight groups have been given underlines. The Error and WarningMsg groups have such wide-spread use elsewhere that underlining them causes multiple theming problems. With
s:ft_undercurl
, it's easier to add underlines where it makes sense rather than doing the opposite, and removing them from anywhere that didn't expect them.Ctermul support (... in Vim)
guisp
was already implemented, but the equivalent cterm command was left blank. At the time, no alternatives existed. As of Vim 8.2.0863,ctermul
exists. This PR adds support for it, with a conditional enable for compatibility usinghas
. This also means ctermul isn't enabled for nvim, which I won't be doing in this PR anyway, because I don't use nvim and I have no clue if it has it, much less how to check if it's present in the current version.helpBar, helpStar, helpBacktick, and helpIgnore
This change is primarily aimed at anyone writing help documents. Prior to this change (as per #161), these characters were fully hidden. While that is irrelevant for anyone reading help documents, if you write them, it's incredibly annoying to work with nearly invisible characters.
After this change, helpStar, helpBar, and helpBacktick, as well as helpIgnore for the
Headers~
and><
blocks are actually visible. For some reason, I couldn't find dedicated syntax highlight groups for~
and><
- they seem to just be part ofhelpIgnore
, which is whyhelpIgnore
has been highlighted. I've been unable to find any unintentional consequences of this so far.Note that this screenshot was taken with
conceallevel=0
for screenshot reasons. They're still otherwise hidden for anyone reading the helpfile. IIRC, helpfiles have conceallevel set to something non-zero by default, at least when using the:help
command1, so this change is only visible when editing helpfiles. This is also when it's useful to have these characters visible.Footnotes
In addition to conceallevel, concealcursor appears to be reset to
nc
inside a help document opened with:help
, so I'm pretty sure this won't be visible to anyone reading help files. ↩