nvim-tree / nvim-web-devicons

lua `fork` of vim-web-devicons for neovim
MIT License
2.02k stars 181 forks source link

Issue with file extension matching #483

Open sethen opened 1 month ago

sethen commented 1 month ago

Looks like nvim-web-devicons gets confused with you use more than one period for the extension in a file name. I would expect it to know that it should apply the same icon to .ts files as it does for test.ts files, but it doesn't. You have to add test.ts to the config or it will not apply. To make it work I have to do something like this:

return {
   'nvim-tree/nvim-web-devicons',
   dependencies = {
      'catppuccin/nvim',
   },
   config = function()
      local icons = require('nvim-web-devicons')
      local palette = require('catppuccin.palettes').get_palette('mocha')

      icons.setup({
         override = {
            ts = {
               color = palette.blue,
               icon = '',
               name = 'Ts',
            },
            ['test.ts'] = {
               color = palette.blue,
               icon = '',
               name = 'Test.ts',
            },
         }
      })
      icons.set_default_icon('')
   end,
}

Here's what it looks like if I would take the test.ts configuration out: Screenshot from 2024-07-21 00-07-02

hasecilu commented 2 weeks ago

Are you sure it's a glyph from NF? Seems you're using a faulty codepoint.

sethen commented 2 weeks ago

Are you sure it's a glyph from NF? Seems you're using a faulty codepoint.

Guess I don't understand how that would be a faulty codepoint? How does it work with .ts extensions but when test.ts is in the file it doesn't work?

hasecilu commented 2 weeks ago

I meant that in your snippet you used codepoint EA55 and in NerdFonts there is no associated glyph. If you got a "square" there it's because there is no glyph there.

I tried replacing the icons and works:

image

sethen commented 2 weeks ago

I meant that in your snippet you used codepoint EA55 and in NerdFonts there is no associated glyph. If you got a "square" there it's because there is no glyph there.

I tried replacing the icons and works:

image

You're correct, there is no code point in NerdFonts. I use my own custom icon font and define the codepoints in Kitty (Terminal).

sethen commented 2 weeks ago

What you're seeing with the code point (EA55) is the same code point for the .ts files. So I am confused why it won't load the same icon for the same file extension.

hasecilu commented 2 weeks ago

I tried changing both extensions to the same char and also works. Not sure what could be happening on your end, maybe using override_by_extension makes a change.