-
-
Notifications
You must be signed in to change notification settings - Fork 827
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
Support for undercurl #415
Comments
Here's the iTerm2 issue as well: https://gitlab.com/gnachman/iterm2/-/issues/6382 |
The biggest challenge is the non-standard use of I took a quick look at changing the vtparser logic; it's not impossible to accommodate but does require more state bits (unfortunately bumping us over from a pair of 4 bit nybbles and some clever lookup/mapping logic, which makes for a larger architectural change in that area), and representing the CSI expansion parameters as an array of either an integer or a sequence of colon separated integers, and then fanning that out through a lot of other code. The effort required for all of that is much higher than the rest of this feature! Even with that done, the parser would then be potentially prone to misbehaving with some invalid inputs, whereas the behavior today is well defined and conforming. |
These aren't currently rendered, but the parser and model now support recognizing expanded underline sequences: ``` CSI 24 m -> No underline CSI 4 m -> Single underline CSI 21 m -> Double underline CSI 60 m -> Curly underline CSI 61 m -> Dotted underline CSI 62 m -> Dashed underline CSI 58 ; 2 ; R ; G ; B m -> set underline color to specified true color RGB CSI 58 ; 5 ; I m -> set underline color to palette index I (0-255) CSI 59 -> restore underline color to default ``` The Curly, Dotted and Dashed CSI codes are a wezterm assignment in the SGR space. This is by no means official; I just picked some numbers that were not used based on the xterm ctrl sequences. The color assignment codes 58 and 59 are prior art from Kitty. refs: #415
``` printf "\x1b[4m\x1b[58;2;255;0;0mred underline\x1b[0m" ``` prints "red underline" in the foreground color, with an underline that is bright red `rgb(255, 0, 0)`. refs: #415
We now have too many permutations to pre-render in the initial texture size, so do this on the fly instead. refs: #415
``` $ printf "\x1b[58;2;255;0;0m\x1b[4msingle\x1b[21mdouble\x1b[60mcurly\x1b[61mdotted\x1b[62mdashed\x1b[0m" ``` refs: #415
As of master (which should show up in a nightly build within the next 1-2 hours), the following escape sequences relating to underline are supported:
wezterm uses You can exercise these from the command line: $ printf "\x1b[58;2;255;0;0m\x1b[4msingle\x1b[21mdouble\x1b[60mcurly\x1b[61mdotted\x1b[62mdashed\x1b[0m" which renders for me like this: You can teach vim about this; place this in " Inform vim how to enable undercurl in wezterm
let &t_Cs = "\e[60m"
" Inform vim how to disable undercurl in wezterm (this disables all underline modes)
let &t_Ce = "\e[24m"
hi SpellBad guisp=red gui=undercurl term=underline cterm=undercurl
hi SpellCap guisp=yellow gui=undercurl term=underline cterm=undercurl
hi SpellRare guisp=blue gui=undercurl term=underline cterm=undercurl
hi SpellLocal guisp=orange gui=undercurl term=underline cterm=undercurl
set spell
" A text with spellling mistake in vim. check that underline or undercurl are OK. Then |
Wow, this is incredible. Thank you. Already tested and is working as expected thus far. EDIT: I spoke too soon. When I tried sourcing the above in Neovim it had no effect. Misspelled words are still regular underline. I started searching through Neovim issues to see if I could find anything and came across the implementation issue here neovim/neovim#7479 |
(just chimin here, didn't test anything but this might help you) It works in vim (as @wez showed) but not in neovim, because the variables
The implementation of neovim's TUI changed a bit since that initial implementation, the current lines (in current neovim's master) are: |
There's some commentary in neovim/neovim#9270 on the preference of the use of As I mentioned above, it's a bit of a PITA, but not impossible. The tmux issue you linked has a discussion around advertising some of these capabilities in terminfo. Thus far, wezterm has been good to successfully run with |
Personally, I'm not as concerned with the tmux issue, with wezterm I won't be using a local tmux any longer. I really like the fact that I do not have to specify my term when ssh'ing into systems, or receiving error messages that my terminal is not fully functional. |
Yeah, not requiring special terminfo/TERM setup has been a soft goal of mine as part of this project (although: I do end up with installing a current xterm terminfo in my remote shell setup anyway to ensure that I get working italics when running vim remotely). This line in nvim: https://github.com/neovim/neovim/blob/2ea3127697692b0b2c480d585ef6529e90a72b0e/src/nvim/tui/tui.c#L2030 appears to require that the terminfo have an If that isn't present it falls back to looking up a different boolean property to identify kitty by its terminfo, and finally falls back to probing to see if the terminal is vte-based. If you can configure nvim to override The default That's a string that takes an integer parameter to specify the number after the colon. Two values are important; 0 to disable underline and 3 to enable curly underline. Looking at
breaking that down:
That might be sufficient. Technically, that first parameter should be tested against If you could give that a try before I come back to this a bit later, that could save me a bit of time this evening! |
This allows us to support the kitty style underline sequence, or the : separated form of the true color escape sequences. refs: #415
You can install this into your $TERMINFO directory (default is `$HOME/.terminfo`) by running: `tic -x wezterm.terminfo` from this data directory. Once installed, you can set `TERM=wezterm`. refs: #415
Well, good news and bad news. Good news: master now supports the kitty style colon-based sequences for underlines. The 60, 61, 62 sequences I mentioned above no longer function in master; I didn't see the need to preserve something that I made up for this! My earlier example for vim needs a small change: " Inform vim how to enable undercurl in wezterm
let &t_Cs = "\e[4:3m"
let &t_Ce = "\e[4:0m" Bad news: For I've added a $ curl https://raw.githubusercontent.com/wez/wezterm/master/termwiz/data/wezterm.terminfo | tic -x - Then you can set I need to put a little bit of thought into properly versioning the terminfo file(s) as they evolve. As I mentioned above, I'd love for these to not need to change often, or even be required, but for software like |
Thank you. I explicitly set the I haven't looked yet at if I can add the terminal configuration directly within Neovim so that I don't have to set it on the command line, but I think I saw something yesterday suggesting that it could be done. The
In case someone else stumbles across this problem. |
I think the only thing left to do here now is add some docs for this. Did you find a way to get nvim to use this feature without needing to install the terminfo file? |
I made an FAQ entry here: https://wezfurlong.org/wezterm/faq.html#how-do-i-enable-undercurl-curly-underlines |
Thank you. I was digging through Neovim documentation and libraries to see if there's another way that the terminal info could be set, including looking at using |
@rawhat if you use |
It seems like with Gnome Terminal on Ubuntu 22.04, undercurl works out of the box in neovim without needing the terminfo database. |
@kiyoon neovim must have some built-in logic to decide whether it can use undercurl independently from what is in the terminfo file for xterm. I would suggest opening an issue with the neovim folks to see if they can extend it to recognize wezterm as well. |
Thank you for your reply. I just made a request there. |
@wez I use westerm mac and window wsl. And follow this, I can see undercurl from neovim with my mac. But with windows (WSL2) I try this same thing not working.... It is relaction with this? Also I attach my settings. Thank you so much. |
Ah I think I see all comment.. thank you reply and clear explain |
I'm doing something which may turn out to be silly. I have wezterm installed natively on Windows, and Edit: The underlines/curlies do work with |
try using |
Thank you @wez |
@wez sorry for the stupid question, but how do I connect to a wsl2 instance over ssh? The docs say that it only works over WSL1, but I am struggling to find an example. Thank you :) |
@jackfranklin if you want to connect from native Windows to WSL2, I think you can do |
@jackfranklin you'd start an ssh server inside the WSL2 instance, determine its ip (using either |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Neovim (and maybe others but this is where I notice it) has support for undercurl, a wavy underline that appears, with my configuration underneath spelling mistakes. I'm making the migration from kitty to wezterm and this is one thing that I've noticed is missing.
Attaching images to better demonstrate the wanted behaviour and what currently exists.
kitty:
wezterm:
Both are using the same version of Neovim and the same configuration (running on one computer).
I was missing undercurl in tmux and ended up finding this issue which describes the problem and the solutions that others (including kitty) have used to support undercurl
tmux/tmux#1492
The text was updated successfully, but these errors were encountered: