DEV Community

jibundit
jibundit

Posted on

3 1

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

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay