ray-x / navigator.lua

Code analysis & navigation plugin for Neovim. Navigate codes like a breeze🎐 Exploring LSP and 🌲Treesitter symbols a piece of 🍰 Take control like a boss 🦍
MIT License
1.28k stars 55 forks source link

Keymaps not working. LspKeymaps shows empty list #154

Closed lynndylanhurley closed 2 years ago

lynndylanhurley commented 2 years ago

I'm trying to use the following keymap config:

keymaps = {
  { key = "gr", func = "require('navigator.reference').reference()" },
  { key = "gD", func = "declaration({ border = 'rounded', max_width = 80 })" },
  { key = 'gd', func = "require('navigator.definition').definition()" },
  { key = "ga", func = "code_action()" },
  { key = 'K', func = "hover({ popup_opts = { border = single, max_width = 80 }})" },
  { key = "gi", func = "implementation()" },
  { key = "<leader>d", func = "type_definition()" },
  { key = "gL", func = "require('navigator.diagnostics').show_diagnostics()" },
  { key = "gG", func = "require('navigator.diagnostics').show_buf_diagnostics()" },
  { key = "]d", func = "diagnostic.goto_next({ border = 'rounded', max_width = 80})" },
  { key = "[d", func = "diagnostic.goto_prev({ border = 'rounded', max_width = 80})" },
  { key = "]r", func = "require('navigator.treesitter').goto_next_usage()" },
  { key = "[r", func = "require('navigator.treesitter').goto_previous_usage()" },
  { key = '<leader>f', func = 'formatting()', mode='n' },
},

This used to work, but since I ran PackerSync the other day none of my navigator keymaps seem to be working anymore.

This is what I get when I run LspKeymaps:

Screen Shot 2022-03-09 at 10 46 01 AM

When I run LspInfo:

Screen Shot 2022-03-09 at 10 46 27 AM

From the 'which key' interface when I get g:

Screen Shot 2022-03-09 at 10 47 16 AM

^ in this case it's not showing entries for several maps. For example gL, gG are not there at all, and gi is still set to the default vim mapping.

Full neovim config here: https://github.com/lynndylanhurley/nvim/blob/d02211f5bb4bda2d8d2a92718e4338105c2bf44c/lua/plugins/navigator.lua

lynndylanhurley commented 2 years ago

I have this working now. I think the lsp_installer example linked to from the readme may not be completely working. This code seems to need to be called by every server's on_attach callback:

require('navigator.lspclient.mapping').setup({
  client = client,
  bufnr = bufnr,
  cap = capabilities,
})

My full working config with lsp_installer integration is up here: https://github.com/lynndylanhurley/nvim/blob/51d4372e13a38e2847654c45e9ea09a7c5afa405/lua/plugins/navigator.lua

ray-x commented 2 years ago

I am not sure if call mapping.setup() is the best way.
I updated my sample vimrc for lsp_installer you can also take a look. https://github.com/ray-x/navigator.lua/blob/master/playground/init_lsp_installer.lua