-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow independent coloring of underline in supported terminals #2405
Conversation
This uses the new option `termguiul` and the new (proposed) termcap option `t_8u` which should behave analogously to `t_8f` and `t_8b`. I set the default termcap option to empty as this is not a widely supported feature, so most terminals will not support it.
@avernan Cool, thx, implementing this in vim was on my TODO list. Just to note, it's possible the code for selecting the underline style might change based on feedback from the VTE developers. See neovim/neovim#7479 for discussion. |
@kovidgoyal That discussion is part of the reason why I haven't set a default code. |
Stefano Guazzotti wrote:
This uses the new option `termguiul` and the new (proposed) termcap
option `t_8u` which should behave analogously to `t_8f` and `t_8b`.
This is supported (and inspired) from
[kitty](https://github.com/kovidgoyal/kitty) (by @kovidgoyal), as
mentioned in #1306 .
Since most terminals will not support this at the moment, I left the
default value of `t_8u` as an empty string.
To test this feature in kitty, you can use the following minimal .vimrc
```vim
let &t_8u = "\<Esc>[58;2;%lu;%lu;%lum"
set spell
hi SpellBad cterm=underline ctermbg=NONE guisp=#AB3434
set termguiul
```
I don't think this should be an option. Instead, the underline color
should be defined with the highlight group. Then it's possible to have
some text underlined as before, while other text gets a colored
underline. This hould then also apply to the GUI, there is no need for
a "termgui" specific flag.
It makes sense to have the underline color defined separately from the
'special" color, since in most cases underline is expected to be the
same color as the test, while in some cases underlining with a different
color is useful. E.g. to highlight syntax warnings.
…--
hundred-and-one symptoms of being an internet addict:
73. You give your dog used motherboards instead of bones
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
FYI: VTE has just received this feature in git, using the same SGR 58 and 59 as Kitty. |
Closing, since there was no progress for a long time. The solution I requested is different anyway. |
Terminals have only recently started supporting undercurls, due to the xterm extensions advanced by the Kitty terminal emulator. So clearing the terminal defaults for the Spell* groups (per ccaf8de) just left them with no highlighting whatsoever in the terminal. I found this was the only case where gui and guisp weren't translating over as I wanted. First off, you have to use cterm=undercurl, not just gui=undercurl. Even then you have to make Vim output the right escape sequences to the terminal with let &t_Cs = "\e[4:3m" let &t_Ce = "\e[4:0m" I of course won't set those directly from the color scheme, since it's not a given that your terminal will support the escape codes. Though to their credit, most terminals seem to at least gracefully fallback to straight underlines. But even with curly underlines, it doesn't seem like many macOS terminals actually support coloring the underline separately from the foreground. Although Kitty supports it just fine (and I should hope so, being the project that promoted this feature), I've found that neither iTerm2, Alacritty, nor Hyper could render differently-colored undercurls in Vim. And I can't really find any other high-profile macOS terminals, so in my mind Kitty is the only one where this works! (There seems to be some evidence floating around that neovim does something different to get undercurls right, maybe? But I don't really understand it, and I'm not about to go down that rabbit hole.) There also doesn't seem to be a good way to automatically detect if a terminal supports colored undercurls. So, I'm just going with the better safe than sorry approach, which at least works in my current terminal of choice (iTerm2). Namely: 1. Make sure to set cterm=undercurl as well as gui=undercurl. As a general extension, I think it's true that we want to set cterm to whatever attributes I use for the gui (across the whole color scheme, I only use undercurl and bold), so it's natural to just stick this in s:hi directly. 2. As a compromise, the terminal will use guifg instead of guisp for the Spell* groups. That way, we'll get *some* sort of color onto the screen, albeit for the whole word + the undercurl instead of only for the undercurl. I can't do this in a single call to s:hi, though, because I don't want to use guifg when the GUI is running (it can just can make proper use of guisp). So I wrap the Spell* groups in a gui_running check. This is the only case I found in the whole scheme that needed a fallback plan for terminal support. Otherwise, termguicolors seems to take care of the rest. Further reading: * https://sw.kovidgoyal.net/kitty/protocol-extensions.html * https://gitlab.com/gnachman/iterm2/-/issues/6382 * vim/vim#1306 * vim/vim#6687 * vim/vim#2405 * neovim/neovim#7479 * alacritty/alacritty#1628 (comment)
This uses the new option
termguiul
and the new (proposed) termcap optiont_8u
which should behave analogously tot_8f
andt_8b
. This is supported (and inspired) from kitty (by @kovidgoyal), as mentioned in #1306 .Since most terminals will not support this at the moment, I left the default value of
t_8u
as an empty string.To test this feature in kitty, you can use the following minimal .vimrc