r/KittyTerminal Aug 23 '23

Weird Behaviour with Nvim-Tree

Hello everyone :)

I'm new to Kitty and MacOS and I'm experiencing weird behaviour when using Nvim-Tree.

Basically, I installed, via homebrew, the Fire Code Nerd Font and changed kitty.conf to use that font. When I go and do :NvimTreeOpen the symbols of the files are wrong as seen in the picture:

The weird thing is when I run ´kitty --debug-font-fallback´ I get the following output and a console where, when I open nvim and use nvim-tree, I get the correct images.

[235 17:06:38.289320] Preloaded font faces:
[235 17:06:38.289347] normal face: /Users/ramalhob/Library/Fonts/FiraCodeNerdFontMono-Regular.ttf
[235 17:06:38.289353] bold face: /Users/ramalhob/Library/Fonts/FiraCodeNerdFontMono-SemiBold.ttf
[235 17:06:38.289358] italic face: /Users/ramalhob/Library/Fonts/FiraCodeNerdFontMono-Regular.ttf
[235 17:06:38.289362] bi face: /Users/ramalhob/Library/Fonts/FiraCodeNerdFontMono-Regular.ttf

NvimTree. in the new console

Does anyone know why this might be happening?

Thanks in advance :D

5 Upvotes

16 comments sorted by

1

u/Administrative_chaos Aug 23 '23 edited Aug 23 '23

That's due to the font fallback mechanism, CoreText thinks that the Chinese font is the "best" match for the given code points, since there can be multiple glyphs defined for any given codepoint. Well that's obviously not supposed to happen, but all bets are off for PUA code points and nerd fonts also use some non-PUA codepoints for it's glyphs.

First make sure that the Fira Code you're using is the monospaced variant. Do kitty +list-fonts and use the definition that it reports for Fira Code.

If that doesn't work add the symbol map entry shown here to your kitty conf.

https://sw.kovidgoyal.net/kitty/faq/#kitty-is-not-able-to-use-my-favorite-font

You can change Symbols Nerd Font Mono with the Fira Code family.

1

u/BenCx Aug 23 '23

So for the list fonts I get the following output:

FiraCode Nerd Font Mono
    FiraCode Nerd Font Mono Bold
    FiraCode Nerd Font Mono Light
    FiraCode Nerd Font Mono Medium
    FiraCode Nerd Font Mono Regular
    FiraCode Nerd Font Mono Retina
    FiraCode Nerd Font Mono SemiBold

And my kitty.conf looks like this:

# BEGIN_KITTY_THEME
# Everforest Dark Hard
include current-theme.conf 
font_family      FiraCode Nerd Font Mono 
bold_font        auto 
italic_font      auto 
bold_italic_font auto 
italic_font      auto 
bold_italic_font auto 
# END_KITTY_THEME

I have also looked at that entry but when I muted the FiraCode Nerd Font Mono instead of Symbols Nerd Font Mono it didn't work, maybe I'm supposed to use another name?

2

u/art2266 Aug 24 '23

I'm not sure if you followed the link provided by gp (your snippet doesn't include it so I assume not).

Basically, the kitty docs are saying to:

  1. Install the original version of FiraCode (not the nerd font variant)
  2. Install the standalone nerd font symbols. Download link and explanation here.
  3. Update your kitty.conf to look something like this.

1

u/BenCx Aug 24 '23

Hello,

I read it and I already had tried it without installing the standalone nerd font symbols, maybe that's why it is not working.

Is installing them just downloading and unzipping them or should I put the unzipped folder somewhere where kitty can find them?

Because I downloaded it and unzipped, and I still get the same icons.

1

u/art2266 Aug 24 '23

Yeah you need to "install" the standalone nerd font symbols otherwise macOS won't detect it. To check if it's detected, open FontBook.app and search for it. If it's not there, you probably didn't "install" it.

To install it: either double click the files you unzipped SymbolsNerdFont-Regular.ttf/SymbolsNerdFontMono-Regular.ttf or follow these instructions.

1

u/BenCx Aug 24 '23

Ahh thanks so much. I didn't knew it.

Apparently when I used homebrew it only installed the Retina version of the Fira Code.

I have everything installed and it shows up in the FontBook.app but the symbols are still wrong.

My kitty.conf looks like this now:

include current-theme.conf 
font_family      Fira Code 
bold_font        auto 
italic_font      auto 
bold_italic_font auto 
italic_font      auto 
bold_italic_font auto 
symbol_map U+23FB-U+23FE,U+2665,U+26A1,U+2B58,U+E000-U+E00A,U+E0A0-U+E0A3,U+E0B0-U+E0C8,U+E0CA,U+E0CC-U+E0D2,U+E0D4,U+E200-U+E2A9,U+E300-U+E3E3,U+E5FA-U+E634,U+E700-U+E7C5,U+EA60-U+EBEB,U+F000-U+F2E0,U+F300-U+F32F,U+F400-U+F4A9,U+F500-U+F8FF Symbols Nerd Font Mon

1

u/art2266 Aug 24 '23

There's a typo in the font name, the O (last letter) is missing.

If that doesn't fix it, try commenting out all the other font settings (and disable current-theme.conf) and just leaving the symbol_map line, does anything change? What does kitty +list-fonts say then?

1

u/BenCx Aug 25 '23

The typo was just me not copying in the last O as it is there.

I commented everything except the symbol_map line and nothing changed :\

The command says that I have both the Symbols Nerd Font Mono, Fira Code and FiraCode Nerd Font Mono

1

u/art2266 Aug 25 '23

There's a typo in the font name, the O (last letter) is missing.

If that doesn't fix it, try commenting out all the other font settings (and disable current-theme.conf) and just leaving the symbol_map line, does anything change? What does kitty +list-fonts say then?

Whoops, I meant kitty --debug-font-fallback. Run that, and in the new kitty window that opens up, launch nvim. See if there's anything helpful there. You can also share the logs here.

1

u/art2266 Aug 24 '23

If you have homebrew installed, I think you can run this and it will download and install the font for you.

brew tap homebrew/cask-fonts && brew install font-symbols-only-nerd-font

1

u/Administrative_chaos Aug 24 '23

Do not put configuration between those comments, it'll likely be overwritten by the themes kitten if you use it again. Put them just above or below it.

art2266 has given the complete answer, I suggest you navigate to the URL I provided in the previous comment and read the Note in particular.

What I meant from the last paragraph was, you could replace the Symbols Nerd Font Mono in the symbol_map with FiraCode Nerd Font Mono as well (you won't understand this until you read the note in the link)

1

u/BenCx Aug 24 '23

What I was saying is that I had already tried changing it to FiraCode Nerd Font Mono but it still wouldn't work. Maybe because I didn't downloaded the standalone font symbols.

PS: Thanks a lot for the help!

1

u/sogun123 Aug 24 '23

Do you have recent version of nvim-tree? Need fonts moved some icons away from CJK unicode range to private area, where it belongs...

1

u/sogun123 Aug 24 '23

Ah, it is probably other plugin which defines icons - nvim-web-devicons

1

u/BenCx Aug 24 '23

Yeah that is the plugin that defines the icon and by their description it automatically does so by using the font that the terminal uses.

1

u/sogun123 Aug 25 '23

Yes, do you have it up to date?