DaikyXendo / nvim-material-icon

Nvim material icon
MIT License
111 stars 8 forks source link

Module 'nvim-material-icon' not found #6

Closed Drogglbecher closed 4 months ago

Drogglbecher commented 5 months ago

Hi, I did an update this morning and since then I get this error message:

Failed to run `config` for nvim-web-devicons

/Users/user/.config/nvim/lua/plugins/init.lua:9: module 'nvim-material-icon' not found:
^Ino field package.preload['nvim-material-icon']
cache_loader: module nvim-material-icon not found
cache_loader_lib: module nvim-material-icon not found
^Ino file './nvim-material-icon.lua'
^Ino file '/opt/homebrew/share/luajit-2.1/nvim-material-icon.lua'
^Ino file '/usr/local/share/lua/5.1/nvim-material-icon.lua'
^Ino file '/usr/local/share/lua/5.1/nvim-material-icon/init.lua'
^Ino file '/opt/homebrew/share/lua/5.1/nvim-material-icon.lua'
^Ino file '/opt/homebrew/share/lua/5.1/nvim-material-icon/init.lua'
^Ino file './nvim-material-icon.so'
^Ino file '/usr/local/lib/lua/5.1/nvim-material-icon.so'
^Ino file '/opt/homebrew/lib/lua/5.1/nvim-material-icon.so'
^Ino file '/usr/local/lib/lua/5.1/loadall.so'

# stacktrace:
  - ~/.config/nvim/lua/plugins/init.lua:9 _in_ **config**

Changing to your version of nerd-tree or nvim-web-devicons doesn't change the behaviour. The part of plugins/init.lua looks like this:

{
  "DaikyXendo/nvim-web-devicons",
  dependencies = { "DaikyXendo/nvim-material-icon" },
  config = function()
    require("nvim-web-devicons").setup({
      override = require("nvim-material-icon").get_icons(),
    })
  end,
},

Do I do anything wrong here? The only thing I'm not 100% sure with is the latest nerd font. I use the brew cask and update it on a daily base, so basically this shouldn't be the problem, should it?

DaikyXendo commented 5 months ago

So sorry! Currently I am upgrading the project. Currently this project is compatible with nvim-tree, lualine, bufferline... so you don't need to overwrite icons anymore. Now the project is running fine on my machine. If you still get the error, please let me know more details about your plugins/init.lua file. Thank!

Drogglbecher commented 5 months ago

Thanks for your quick repsonse :)

If I got you correct, I just need the standard nvim-tree (not your fork) and nvim-material-icon, right? So I plainly put

  "DaikyXendo/nvim-material-icon"

in the plugins/init.lua file without further config as described in the readme, removed DaikyXendo/nvim-web-devicons and use the nvim-tree/nvim-tree plugin.

However when opening the nvim-tree I get

Error executing Lua callback: ...vim-tree.lua/lua/nvim-tree/renderer/components/icons.lua:68: attempt to call fiel
d 'get_default_icon' (a nil value)
stack traceback:
        ...vim-tree.lua/lua/nvim-tree/renderer/components/icons.lua:68: in function 'get_file_icon'
        ...im/lazy/nvim-tree.lua/lua/nvim-tree/renderer/builder.lua:186: in function 'build_file'
        ...im/lazy/nvim-tree.lua/lua/nvim-tree/renderer/builder.lua:338: in function 'build_line'
        ...im/lazy/nvim-tree.lua/lua/nvim-tree/renderer/builder.lua:385: in function 'build_lines'
        ...im/lazy/nvim-tree.lua/lua/nvim-tree/renderer/builder.lua:438: in function 'build'
        .../nvim/lazy/nvim-tree.lua/lua/nvim-tree/renderer/init.lua:57: in function 'draw'
        ...ocal/share/nvim/lazy/nvim-tree.lua/lua/nvim-tree/lib.lua:195: in function 'open_view_and_draw'
        ...ocal/share/nvim/lazy/nvim-tree.lua/lua/nvim-tree/lib.lua:259: in function 'open'
        ...lazy/nvim-tree.lua/lua/nvim-tree/actions/tree/toggle.lua:48: in function 'toggle'
        ...share/nvim/lazy/nvim-tree.lua/lua/nvim-tree/commands.lua:98: in function <...share/nvim/lazy/nvim-tree.
lua/lua/nvim-tree/commands.lua:97>
DaikyXendo commented 5 months ago

I went back to my lazy-nvim file and found the problem. Previously I had an error with nvim-tree so I placed it in the specified commit. Now both nvim-tree and nvim-web-devicons have been upgraded. I'm trying my best to make it compatible with the latest nvim-tree. In the meantime you can use my nvim-tree repo or use:

    { "nvim-tree/nvim-tree.lua", commit = "c3c6544ee00333b0f1d6a13735d0dd302dba4f70" },
Drogglbecher commented 5 months ago

So I took your nvim-tree implementation. However, I don't see any icons but this plain file thingies:

Screenshot 2024-05-28 at 12 49 10

The icons in the tabline and lualine are shown correctly btw.

FotiadisM commented 5 months ago

What I ended up doing was forking the project in order to rename the Lua module lua/nvim-web-devicons.lua -> lua/nvim-material-devicons.lua

This way I could have all my plugins using their normal dependencies, example:

{
    "nvim-tree/nvim-tree.lua",
    dependencies = { "nvim-tree/nvim-web-devicons" }
}

And all I had to do was overwire the nvim-web-devicons with the material ones:

{
    "nvim-tree/nvim-web-devicons",
    dependencies = { "FotiadisM/nvim-material-icon" },
    config = function()
        require("nvim-web-devicons").setup({
            override = require("nvim-material-devicons").get_icons(),
        })
    end,
},

This is a much easier approach to me, there is no need to use a forked version of nvim-tree or specific commits on plugins. Not sure if my method is 100% correct but I haven't encountered a bad icon so far. Of course the downside is that you have to import both plugins

DaikyXendo commented 5 months ago

In the latest version my project supported nvim-tree latest version. I plan to close this issue tomorrow. Thank!