ray-x / lsp_signature.nvim

LSP signature hint as you type
Apache License 2.0
2.03k stars 58 forks source link

Need help in understanding `on_attach` vs `setup` config #341

Open sbushmanov opened 5 days ago

sbushmanov commented 5 days ago

I've setup lsp_signature with the following in my lsp_signature.lua (lazy):

return {
  "ray-x/lsp_signature.nvim",
  event = "LspAttach",
  lazy = true,
  config = function()
    require("lsp_signature").setup {
      hint_enable = true
    }
  end
}

However, this doesn't work at all.

After a bit of experimenting I succeeded in showing up signature help (still without a panda) with the following:

return {
  "ray-x/lsp_signature.nvim",
  event = "LspAttach",
  lazy = true,
  config = function()
    require("lsp_signature").on_attach {
      hint_enable = true
    }
  end
}

Can somebody please guide me on the proper way on setting up the plugin (lazy) and explaining the difference between the 2?

ray-x commented 3 days ago

With latest lazy.nvim You should be able to use

{
    'ray-x/lsp_signature.nvim',
    event = { 'InsertEnter' },
    opts = {
      ...
    }
  }
sbushmanov commented 3 days ago

Sorry, does't work with the suggested setup.

And even when I tried to restore the previous setup that used to work Im getting:

Error detected while processing CursorHold Autocommands for "<buffer=1>":
Error executing lua callback: ...vim/lazy/lsp_signature.nvim/lua/lsp_signature/helper.lua:756: attempt to c
all field 'empty' (a nil value)
stack traceback:
        ...vim/lazy/lsp_signature.nvim/lua/lsp_signature/helper.lua:756: in function 'check_lsp_cap'
        .../nvim/lazy/lsp_signature.nvim/lua/lsp_signature/init.lua:669: in function 'signature'
        .../nvim/lazy/lsp_signature.nvim/lua/lsp_signature/init.lua:907: in function 'on_UpdateSignature'
        ...vim/lazy/lsp_signature.nvim/lua/lsp_signature/helper.lua:28: in function <...vim/lazy/lsp_signat
ure.nvim/lua/lsp_signature/helper.lua:27>
Press ENTER or type command to continue

And even though lua vim.lsp.buf.signature_help() does produces signature (accompanied with some error messages) lua require'lsp_signature'.signature() only produces error message

ray-x commented 3 days ago

The error you saw was fixed. Also, use the attach method making sure the setup is after lsp_config.