Issafalcon / lsp-overloads.nvim

Extends the native nvim-lsp handlers to allow easier navigation through method overloads.
MIT License
88 stars 4 forks source link

What have I done wrong? #38

Closed NullVoxPopuli closed 2 weeks ago

NullVoxPopuli commented 3 months ago

I have this:

  if client.server_capabilities.signatureHelpProvider then
    require('lsp-overloads').setup(client, {
      -- UI options are mostly the same as those passed to vim.lsp.util.open_floating_preview
      ui = {
        -- Events that will close the signature popup window: use {"CursorMoved", "CursorMovedI", "InsertCharPre"} to hide the window when typing
        close_events = { "CursorMoved", "BufHidden", "InsertLeave" },
        focusable = true,                     -- Make the popup float focusable
        focus = false,                        -- If focusable is also true, and this is set to true, navigating through overloads will focus into the popup window (probably not what you want)
        offset_x = 0,                         -- Horizontal offset of the floating window relative to the cursor position
        offset_y = 0,                         -- Vertical offset of the floating window relative to the cursor position
        floating_window_above_cur_line = false, -- Attempt to float the popup above the cursor position
      },
      keymaps = {
        next_signature = "<C-j>",
        previous_signature = "<C-k>",
        next_parameter = "<C-l>",
        previous_parameter = "<C-h>",
        close_signature = "<A-s>"
      },
      display_automatically = true -- Uses trigger characters to automatically display the signature overloads when typing a method signature
    })
    vim.api.nvim_buf_set_keymap(bufnr, "n", "<A-s>", ":LspOverloadsSignature<CR>", { noremap = true, silent = true })
    vim.api.nvim_buf_set_keymap(bufnr, "i", "<A-s>", ":LspOverloadsSignature<CR>", { noremap = true, silent = true })

but maybe I don't know what key A is? I've been pressing alt-s, and it doesn't seem to show the signature. Screencast from 2024-04-03 23-55-21.webm

also left alt seems to behave differently from right alt? is there a way to inspect what these are bound to so I can see if I can unbind them?

drumenov commented 3 months ago

Hello.

According to tho provided configuration, the signatures should be shown automatically (display_automatically = true). I assume that after it gets closed (by pressing <A-s>), pressing <A-s> does not show the signature again.

Trying your configuration, the signature gets shown automatically, pressing (in insert mode) <A-s> closes it, pressing again (in insert mode) <A-s> I get the :LspOverloadsSignature put in the file at the cursor's position and then a new line.

Changing

vim.api.nvim_buf_set_keymap(bufnr, "i", "<A-s>", ":LspOverloadsSignature<CR>", { noremap = true, silent = true })

to

vim.api.nvim_buf_set_keymap(bufnr, 'i', "<A-s>", "<C-o>:LspOverloadsSignature<CR>", { noremap = true, silent = false })

makes it so that the signature is shown again.

Not sure whether that suffices as an answer.

P.S. This was done on Windows 11, nvim 0.9.5, plugin's version 1.3.1

Issafalcon commented 3 months ago

Hi @NullVoxPopuli - <A-s> is specific for the left alt key, so yes, the right alt key (ALTGR on most keyboards I believe) will be a different mapping altogether.

As for why it isn't working for you, I have a couple of suggestions based on what I can and can't see from your supplied config:

  1. Is the mapping done inside the on_attach function of the LSP server config? If it isn't then this would explain why you are seeing this behaviour.
  2. For the i keymap for insert mode, change the mapping command to be <cmd>LspOverloadsSignature<CR>. Assuming this is in the on_attach function, this should work better for insert mode to show and hide the signature popup.

If the above don't work, then you can log out the client.server_capabilities and see if your LSP capabilities actually include the signatureHelpProvider at the point at which you perform the check for it.

To check what is mapped to <A-s> you can use command mode - :nmap <A-s> which should display your current mapping in normal mode for Alt-s. It will be displayed as <M-s> in the command output though.

Issafalcon commented 1 month ago

@NullVoxPopuli - Just checking if you managed to sort your issue out in the end? There have been a couple of plugin updates since your question, so potentially, a recent fix may have resolved your problem.