DEV Community

jibundit
jibundit

Posted on

Undercurl Display on Neovim and tmux with iTerm2

As you may know, it can't enable an undercurl on any English word mispelled on iTerm2 with Neovim even if setting t_Cs and t_Ce.

This shared information are based on the dotfile from Takuya Matsuyama setting and zsh on your SHELL configuration.

First thing first, export your TERM on your ~/.zshrc. Source your .zshrc is necessary.

export TERM="xterm-256color"
[[ -n $TMUX ]] && export TERM="screen-256color"
Enter fullscreen mode Exit fullscreen mode

Your .vimrc or init.lua need to add these two options

vim.opt.spell = true
vim.opt.spelllang = { 'en_us' }
Enter fullscreen mode Exit fullscreen mode

Next, add Smulx=\E[4:%p1%dm, to your TERM.
For example smul=\E[4m, Smulx=\E[4:%p1%dm, tbc=\E[3g, tbc=\E[3g, ...

infocmp > /tmp/${TERM}.ti
Add Smulx=\E[4\:%p1%dm, after smul=\E[4m,
tic -x /tmp/${TERM}.ti
Enter fullscreen mode Exit fullscreen mode

Then edit any file you prefer. This example uses base.lua file. _vim ~/.config/nvim/lua/user/base.lua

Image description

Move to tmux, your tmux session should inherit the TERM from .zshrc setting by switching to use screen-256color instead of xterm-256color. Performing the same process of TERM reconfiguration.

infocmp > /tmp/${TERM}.ti
Add Smulx=\E[4\:%p1%dm, after smul=\E[4m,
tic -x /tmp/${TERM}.ti
Enter fullscreen mode Exit fullscreen mode

Image description

You can recheck your TERMINFO using the additional setting.

infocmp -l -x | grep Smulx
        vpa=\E[%i%p1%dd, Smulx=\E[4\:%p1%dm,
Enter fullscreen mode Exit fullscreen mode

Your tmux session can also display the undercurl line of each misspelled word.
Image description

Top comments (0)