Skip to content
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

using t_Cs to set undercurl works in vim but not neovim #27801

Closed
Jiyangson opened this issue Mar 10, 2024 · 7 comments
Closed

using t_Cs to set undercurl works in vim but not neovim #27801

Jiyangson opened this issue Mar 10, 2024 · 7 comments
Labels
bug issues reporting wrong behavior tui

Comments

@Jiyangson
Copy link

Jiyangson commented Mar 10, 2024

Problem

The cterm=undercurl command is not working in nvim. I searched for some solutions and had some progress.

  1. when setting cterm=undercurl in neovim, it will fall back to underline; but in vim, nothing is shown.
  2. set let &t_Cs = "\e[4:3m" in neovim, it still fall back to underline; but in vim, undercurl occurs.
    what should I do to make undercurl occur in neovim. Thanks.

Steps to reproduce

nvim --clean
# type `asdf`
:se spell 
:let &t_Cs = "\e[4:3m"
:hi SpellBad     gui=undercurl guisp=red term=undercurl cterm=undercurl
# underline is shown under `asdf`

vim --clean
# type `asdf`
:se spell 
:let &t_Cs = "\e[4:3m"
:hi SpellBad     gui=undercurl guisp=red term=undercurl cterm=undercurl
# **undercurl** is shown under `asdf`

Expected behavior

nvim shows undercurl

Neovim version (nvim -v)

0.10.0-dev

Vim (not Nvim) behaves the same?

no, 8.1.3741

Operating system/version

20.04.1-Ubuntu

Terminal name/version

bash, version 5.0.17

$TERM environment variable

xterm

Installation

appimage

@Jiyangson Jiyangson added the bug issues reporting wrong behavior label Mar 10, 2024
@zeertzjq
Copy link
Member

t_Cs is not supported

@zeertzjq zeertzjq added bug issues reporting wrong behavior tui and removed bug issues reporting wrong behavior labels Mar 10, 2024
@Jiyangson
Copy link
Author

Is there a way to work around that do the t_Cs thing in neovim? Or what method should I try? change a terminal or something?

@zeertzjq
Copy link
Member

What terminal are you using? Bash is not a terminal and XTerm doesn't supoort undercurl.

@zeertzjq zeertzjq added the needs:response waiting for reply from the author label Mar 10, 2024
@Jiyangson
Copy link
Author

Jiyangson commented Mar 10, 2024

I use kitty and it works fine (it shows undercurl as usual). But when I open nvim in a docker container, it has this problem.

@github-actions github-actions bot removed the needs:response waiting for reply from the author label Mar 10, 2024
@zeertzjq
Copy link
Member

Hmm, the value of $TERM should be xterm-kitty inside kitty, not xterm.

@JCallicoat
Copy link

I have the same issue with st 0.9 (with undercurl patch) and tmux next-3.5 built from git head like a week ago. I have TERM=screen-256color inside of tmux (which I need to use for key compatibility with old terminfo databases shipped on servers I administer via ssh). Undercurl works fine outside of tmux (TERM=st-256color) in neovim, but shows only an underline inside tmux.

I have the following overrides in tmux.conf just to ensure the feature is enabled.

set -as terminal-overrides ',*:Smulx=\E[4::%p1%dm'  # undercurl support
set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m'  # underscore colours - needs tmux-3.0

And outside of neovim undercurl is displayed correctly inside of tmux with, e.g., printf '\e[4:3mUndercurl\e[0m\n'. But inside neovim running inside tmux I only get an underline.

I assume there is some kind of feature detection based on the value of TERM? Is there any way to override that to force the feature to be enabled?

@Jiyangson
Copy link
Author

For anyone who has a similar problem, I asked chatgpt and got a solution. Here is the answer from gpt

When you use docker exec to enter a Docker container, the $TERM environment variable is set to xterm by default because it is a widely recognized and compatible setting for most programs. This environment variable informs programs running on the terminal about the type and capabilities of the terminal so that they can adjust their behavior accordingly, such as how to interpret colors and handle cursor movements.
xterm-kitty is specifically for the Kitty terminal emulator, and Kitty uses it to enable additional features that may not be available in other terminal environments. When you start a Docker container terminal from Kitty, you need to explicitly set the terminal type to retain some of the underlying features of Kitty.
To set the $TERM variable in the container to xterm-kitty, you can pass the environment variable when connecting to the container:

docker exec -it -e TERM=xterm-kitty [container-id] /bin/bash

Note that to fully utilize the features provided by xterm-kitty, your container needs to have the appropriate terminal information files (terminfo). If they are not present, some features specific to xterm-kitty may not work as expected. If the base image of the container does not include the Kitty terminfo file, you may need to copy this file from the host machine to the corresponding location in the container, which is usually /usr/share/terminfo/x/xterm-kitty.

For me, I just copy xterm-kitty in my kitty install path and it works.

docker cp ~/.local/kitty.app/share/terminfo/x/xterm-kitty container_id:/usr/share/terminfo/x/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issues reporting wrong behavior tui
Projects
None yet
Development

No branches or pull requests

3 participants