nvim-tree / nvim-tree/nvim-web-devicons

Issue with file extension matching

Open
#483 16 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lua
Stars
2.7k
Forks
239
Avg merge
3d 16h
Merged PRs (30d)
3

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Use the reported ts and test.ts configuration as the reproduction, then trace the extension-matching entry point in the nvim-web-devicons source. Look for existing tests covering filename and extension matching. Done means a multi-period filename such as test.ts receives the same icon as a .ts file without a separate filename override.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.