module 'nvim-navic' not found
Integralist opened this issue Β· comments
ππ»
The below error is what I'm seeing when trying to run Navic (I was following the instructions in the README).
My dot files are here:
https://github.com/Integralist/dotfiles/tree/main/.config/nvim
Specifically, my main lua plugin function will load all plugin files:
https://github.com/Integralist/dotfiles/blob/main/.config/nvim/lua/plugins/init.lua#L48-L61
One of the files loaded will be gui.lua
which uses packer to install navic:
https://github.com/Integralist/dotfiles/blob/main/.config/nvim/lua/plugins/gui.lua#L106-L111
Every LSP server I configure, I make sure the on_attach
calls a shared file that does some LSP mappings, for example:
https://github.com/Integralist/dotfiles/blob/main/.config/nvim/lua/plugins/lsp.lua#L200-L201
Within that shared file is where I try to 'require' Navic, and if I do, then I'll see the below error (so you'll see in the following link I've commented out the require line):
https://github.com/Integralist/dotfiles/blob/main/.config/nvim/lua/settings/shared.lua#L28-L30
Any idea why I would be seeing this error?
Thanks.
Error executing vim.schedule lua callback: /Users/integralist/.config/nvim/lua/settings/shared.lua:29: module 'nvim-navic' not found:
no field package.preload['nvim-navic']
no file './nvim-navic.lua'
no file '/opt/homebrew/share/luajit-2.1.0-beta3/nvim-navic.lua'
no file '/usr/local/share/lua/5.1/nvim-navic.lua'
no file '/usr/local/share/lua/5.1/nvim-navic/init.lua'
no file '/opt/homebrew/share/lua/5.1/nvim-navic.lua'
no file '/opt/homebrew/share/lua/5.1/nvim-navic/init.lua'
no file '/Users/integralist/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/nvim-navic.lua'
no file '/Users/integralist/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/nvim-navic/init.lua'
no file '/Users/integralist/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/nvim-navic.lua'
no file '/Users/integralist/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/nvim-navic/init.lua'
no file './nvim-navic.so'
no file '/usr/local/lib/lua/5.1/nvim-navic.so'
no file '/opt/homebrew/lib/lua/5.1/nvim-navic.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no file '/Users/integralist/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/nvim-navic.so'
stack traceback:
[C]: in function 'require'
/Users/integralist/.config/nvim/lua/settings/shared.lua:29: in function 'on_attach'
/Users/integralist/.config/nvim/lua/plugins/lsp.lua:201: in function '_on_attach'
...ck/packer/start/nvim-lspconfig/lua/lspconfig/configs.lua:292: in function '_setup_buffer'
...ck/packer/start/nvim-lspconfig/lua/lspconfig/configs.lua:195: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>
Can't really say... Looks like some issue in your nvim configs. navic isn't loaded before lsp's on attach is called? Maybe you could try requires
, before
or after
keywords provided by packer. Maybe something like
use {
"nvim-lspconfig",
requires = "nvim-navic"
}
@SmiteshP thanks. I renamed my gui.lua
file to ui.lua
so it would be guaranteed to load after the LSP configuration in my lsp.lua file and the error disappeared.
BUT the plugin itself doesn't seem to do anything? π€
I tried running print(vim.opt.winbar)
and saw a table
was assigned. So my first thought was this treesitter context plugin (https://github.com/nvim-treesitter/nvim-treesitter-context) might be overriding Navic (I wasn't sure if the other plugin was using the winbar like Navic but I disabled the treesitter plugin anyway just to check and Navic still doesn't run).
I decided to 'dump' the table value to see what it was set to (I don't understand what it means but this is what the contents of the table was):
{ ["_value"] = ,["_name"] = winbar,["_info"] = { ["last_set_linenr"] = 0,["last_set_chan"] = 0,["default"] = ,["name"] = winbar,["metatype"] = string,["was_set"] = false,["type"] = string,["last_set_sid"] = 0,["allows_duplicates"] = true,["shortname"] = wbr,["commalist"] = false,["global_local"] = true,["flaglist"] = false,["scope"] = win,} ,}
I tried to manually override the winbar and that worked fine and didn't conflict with the treesitter context plugin I had...
:lua vim.opt.winbar = "example"
OK, I managed to get it working by going back and reading over the README, as I noticed you have to manually set the winbar yourself (Navic doesn't do it for you!) I thought Navic automatically set the winbar.
if client.server_capabilities.documentSymbolProvider then
-- WARNING: ../plugins/lsp.lua must be loaded first to avoid error loading navic plugin.
require("nvim-navic").attach(client, bufnr)
vim.o.winbar = "%{%v:lua.require'nvim-navic'.get_location()%}"
end
Now when I open a file that has an LSP attached and running I see...
I just need to figure out why there are no colours (I'm guessing I need some highlights defined that aren't in my chosen colourscheme).