Change text underline positions in Kitty terminal emulator
I think Kitty is the best Terminal emulator available. This opinion was re-enforced when I discovered that Kitty now has the option to modify fonts. Why would anyone care about that?
I have wrote in the past how Kitty provides a facility to set a font for unicode characters, so you never need to patch a font again. This is not that.
I’m talking about the ability to amend things like the position of underlines. The thing is, I use Kitty to run Neovim so much of my day is spent in Kitty. I use Victor Mono currently and when using the indent-blankline plugin, when you hover on a suitable section, it reveals the relevant indent. But this is what is looks like ordinarily.
Which is not terrible but that gap can be fixed to look like this:
How to modify the font
You will need to look at the modify_font section of the Kitty documentation. Here you can see a bunch of magical properties. The ones I added to my config were:
modify_font underline_position 9
modify_font underline_thickness 150%
modify_font strikethrough_position 2px
And that gives me nice thick underlines in the position I want them. There are other settings but these are the only ones I needed. So far so good. That gives me this:
But still that gap at the side. Thankfully that can be changed in the indent-blankline settings.
Changing the line in indent-blankline
We can set a different glyph for the line. The default one sits in the center of the glyph so we can change to one that sits at the left:
require("indent_blankline").setup({
space_char_blankline = " ",
show_current_context = true,
show_current_context_start = true,
use_treesitter = true,
use_treesitter_scope = true,
char = "▎",
})
The char
being the relevant part there. And with that set I have underlines exactly where I want them in normal text and nicely aligned lines in Neovim. And I don’t wake up in the dead of night screaming “ALIGNMMMENNNNTTTTTTTTTT!”.
Summary
This is a level of pedantry that isn’t for everyone but the level of customisation and power possible in Kitty never ceases to surprise me.
I am going to leave a comment here saying that this is the only page on the internet that had the exact solution to the exact problem i am facing (exact same font, exact same terminal emulator, exact same text editor, and the same plugin). Thanks for showing the way.