If you're using Neovim as your default code editor or IDE, you've likely encountered the concept of undercurl. But what exactly is undercurl? Let's dive in!
What is Undercurl?
Think of the red squiggly lines you see in VS Code to highlight code errors or typos:
Undercurl brings that same functionality to your terminal-based Neovim setup. It's a visual cue for spelling or code errors—right inside your terminal.
Setting Up Undercurl in Neovim (Terminal)
Step 1: Use a True Color Terminal
To enable undercurl, you'll need a True Color Terminal, such as:
To check if your terminal supports undercurl, run the following command:
echo -e "\e[4:3mThis text has an undercurl\e[0m"
If your terminal supports undercurl, you'll see the text undercurled.
Step 2: Enable Undercurl in Neovim
Add the following lines to your Neovim configuration (options.lua
or init.vim
):
-- Undercurl
vim.cmd([[let &t_Cs = "\e[4:3m"]])
vim.cmd([[let &t_Ce = "\e[4:0m"]])
-- Enable spell check
vim.opt.spell = true
vim.opt.spelllang = { "en_us" }
This setup enables undercurl for spelling errors.
Don't forget to reload neovim after config changes above.
You can see below the word undercurl
is undercurled.
Step 3: Configure Terminal for Undercurl
If undercurl still doesn’t work, follow these steps:
- Identify Your Terminal
Run echo $TERM
to find your terminal type (e.g., xterm-256color
or xterm-ghostty
depending on your terminal).
- Check for Smulx Support
Run:
infocmp -l -x | grep Smulx
If it produces no output, proceed.
- Generate a Terminfo File
infocmp > /tmp/${TERM}.ti
Replace ${TERM}
with your terminal type (e.g., xterm-256color
).
Here in this case
infocmp > /tmp/xterm-256color.ti
- Edit the Terminfo File
Open /tmp/${TERM}.ti
in your editor:
nvim /tmp/xterm-256color.ti
Add the following line after smul=\E[4m,
:
Smulx=\E[4:%p1%dm,
- Reload the Terminfo
tic -x /tmp/${TERM}.ti
Replace ${TERM}
with your terminal type which is the output from echo $TERM
. Here in this case
tic -x /tmp/xterm-256color.ti
- Verify Smulx Support Run:
infocmp -l -x | grep Smulx
You should now see output confirming Smulx
.
Open Neovim and enjoy undercurl support for spelling and code errors.
BTW, if you love my neovim
and tmux
setup above, do check my dotfiles on GitHub.
Enabling Undercurl in Neovim with Tmux
Undercurl may not work out of the box in Tmux. Here’s how to fix that:
Step 1: Update Your tmux.conf
Add the following lines to your ~/.tmux.conf
or ~/.config/tmux/tmux.conf
:
set -g default-terminal "screen-256color"
# Undercurl support
set -as terminal-overrides ',*:Smulx=\E[4::%p1%dm'
set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m'
Check if you are able to see undercurl in Neovim
inside tmux
session. If not follow the below steps.
Step 2: Configure the Terminfo
- Run
echo $TERM
(should returnscreen-256color
). - Follow the terminal configuration steps. Remember your
$TERM
is nowscreen-256color
so replace${TERM}
withscreen-256color
from step 3 onwards.
Step 3: Verify Smulx in Tmux
Run:
infocmp -l -x | grep Smulx
If successful, you’ll see the correct Smulx configuration.
Step 4: Test Undercurl in Tmux
Open Neovim inside a Tmux session, and voilà! Undercurl now works in Neovim + Tmux.
With these steps, you've unlocked the power of undercurl in Neovim, both in standalone terminals and Tmux sessions. Happy coding!
Questions or Feedback?
Feel free to leave a comment or ask any questions if you have doubts! I’d love to hear your thoughts or help you out. 😊
Top comments (0)