Nvim: Configuring Tokyonight for Visibility
- 2 minutes read - 354 wordsAs an elder technologist, there’s the danger of sinking into old habits and
never updating them. I didn’t see anything wrong with tmux, and there
still really isn’t. But some (younger) colleagues told me about some of
zellij’s features, and I adopted it. I saw ghostty and thought it was
terminal emulation done right. And while the blood and tears I paid the git
gods are the definition of sunk cost, Jujutsu (jj) has become my daily driver
revision control solution.
And even some of the oldest and most venerable parts of my toolkit got a
freshening. I have been using nvim happily after over two decades on vim.
But something was troubling: I couldn’t get the color theme to be readily
readable. Read on to find out how I got the color scheme in the featured image.
I guess every generation has its own programming color theme, Ethan
Schoonover’s Solarized defined my latest era; I’d never seen much reason
to try something else out. nvim’s default, though, is a palette called
tokyonight. But the theme makes certain text hard to see: line numbers in the
gutter, tab headings, backtick-wrapped words that Markdown converts to
monospace, etc. Here are my modifications to nvim’s init.lua that make me
happy alongside a diagram of my server-based development environment.
`ghostty` => server (running) => multiple `zellij` sessions
=> running `nvim`
=> and commits being made in `jj` before
=> being pushed to my own git repository
The problem: on tokyonight’s dark background, line numbers were nearly invisible, inactive
tabs blended into nothing, and backtick-wrapped inline code barely registered. These are
the relevant lines from init.lua:
-- Get inspiration from https://github.com/folke/tokyonight.nvim/blob/cdc07ac78467a233fd62c493de29a17e0cf2b2b6/extras/lua/tokyonight_night.lua
-- https://github.com/folke/tokyonight.nvim/blob/cdc07ac78467a233fd62c493de29a17e0cf2b2b6/extras/opencode/tokyonight_night.json#L207
-- Visibility
vim.api.nvim_set_hl(0, 'LineNr', { fg='#768df5' }) -- Brighten up the set number line numbers!
vim.api.nvim_set_hl(0, 'TabLine', { fg='#768df5' }) -- All tabs
vim.api.nvim_set_hl(0, 'TabLineSel', { fg='yellow', underline=true }) -- Active tab
-- Make the backtick `offsets` pop by linking to CurSearch constant
vim.api.nvim_set_hl(0, 'markdownCode', { link='CurSearch' })
-- Indented code blocks
vim.api.nvim_set_hl(0, 'markdownCodeBlock', { link='diffAdded' })
-- Spelling
vim.api.nvim_set_hl(0, 'SpellBad', { bg='red', fg='white', undercurl=true}) -- Spelling errors should be obvious
-- vim: shiftwidth=2 expandtab