SmiteshP / nvim-navbuddy

A simple popup display that provides breadcrumbs feature using LSP server
Apache License 2.0
770 stars 30 forks source link

bug: auto_attach compatibility with lazy.nvim #30

Closed sf8193 closed 1 year ago

sf8193 commented 1 year ago

with these configs

return {
      'SmiteshP/nvim-navbuddy',
      dependencies = {
          'neovim/nvim-lspconfig',
          'SmiteshP/nvim-navic',
          'MunifTanjim/nui.nvim'
      },
      event = 'LspAttach',
      config = {
         lsp = {
            auto_attach = true,
          },
      }
    }
return {
  'SmiteshP/nvim-navic',
  dependencies = 'neovim/nvim-lspconfig',
  event = 'LspAttach',
  config = {
     lsp = {
        auto_attach = true,
      },
  }
}

using lazy, i get an error saying nav buddy doesn't exist. When I add


        if client.server_capabilities.documentSymbolProvider then
          require("nvim-navic").attach(client, bufnr)
          require("nvim-navbuddy").attach(client, bufnr)
        end

to my on attach function, it works fine.

pascalsiemsen commented 1 year ago

First of all: great plugin! I have been searching for something like this but did not find it! At least for me, much better than a sidebar TOC. And it works very well with Latex and the texlab LSP.

I have a similar problem as described above using lazy.vim.

This works (even without changing anything with the on attach function):

return {
  "SmiteshP/nvim-navbuddy",
  dependencies = {
    "neovim/nvim-lspconfig",
    "SmiteshP/nvim-navic",
    "MunifTanjim/nui.nvim",
  },
  -- keys = {
  --   { "<leader>nv", "<cmd>Navbuddy<cr>", desc = "Nav" },
  -- },
  config = function()
    local navbuddy = require("nvim-navbuddy")
 navbuddy.setup({
      lsp = { auto_attach = true, preference = { "nvim_lsp", "nvim-cmp", "nvim-lspconfig", "texlab", "lua_ls" } },
    })
  end,
}

But when I want to set the keybinding with:

return {
  "SmiteshP/nvim-navbuddy",
  dependencies = {
    "neovim/nvim-lspconfig",
    "SmiteshP/nvim-navic",
    "MunifTanjim/nui.nvim",
  },
  keys = {
    { "<leader>nv", "<cmd>Navbuddy<cr>", desc = "Nav" },
  },
  config = function()
    local navbuddy = require("nvim-navbuddy")
    navbuddy.setup({
      lsp = { auto_attach = true, preference = { "nvim_lsp", "nvim-cmp", "nvim-lspconfig", "texlab", "lua_ls" } },
    })
  end,
}

I get the error that the Navbuddy is not an editor command.

SmiteshP commented 1 year ago

Hi Guys! @sf8193 @pascalsiemsen I haven't yet explored how Lazy.nvim works or stuff. But this seems like something to do with lazy loading the plugin I guess. Looking at both the examples looks like some issue with lazy loading. Can you both try by explicitly asking lazy.nvim to not "lazy load" nvim-navbuddy. (Briefly skimming through the readme I think it can be done via this lazy = false, but you guys do check) If nvim-navbuddy is loading fine when not lazy loaded, then this might be issue with Lazy.nvim.

Still I will soon try to migrate my config from packer to lazy, will try to figure out then.

Jxstxs commented 1 year ago

Removing the lazy loading works! Thanks for the hint. I'll try to look into it and figure out if it could be fixed another way.

Also thanks for the plugin! It's adorable.

Jxstxs commented 1 year ago

Looks like when you define it as a dependencies it will work fine!

SmiteshP commented 1 year ago

Hi guys! @pascalsiemsen @sf8193 I hope the solution pointed out by @Jxstxs works for you guys. Can you confirm?

sf8193 commented 1 year ago

i think actually my issue was slightly different than the above. Mine works fine as long as i'm not using autoAttach, so i don't believe it's an issue with lazy loading (as mine wasn't being loaded lazily with config=true). having said that i just reverted to manually attaching during lspAttach with event='LspAttach and it worked well

pascalsiemsen commented 1 year ago

I can confirm that lazy=false works. Thanks a lot