neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 24d7debdfb779bbc4efcd911b9d49dffe4822c2b
parent 198a952c13a1f44c216d3e83b65295cf78802f30
Author: Shantanu Raj <s@sraj.me>
Date:   Sun,  9 Feb 2025 19:02:46 +0100

fix(lsp): signature_help highlights wrong parameter #32382

Problem:
With some LSP servers, `vim.lsp.buf.signature_help` (CTRL-s in insert-mode)
highlights the first parameter regardless of the current cursor position.

- On some lsps the `textDocument/signatureHelp` response only includes the
  `activeParameter` field on the `lsp.SignatureHelp` object.
  ```lua
  {
    {
      result = {
        activeParameter = 2,
        signatures = {
          {
            documentation = {
              kind = "markdown",
              value = ""
            },
            label = "getBuyers(ctx context.Context, orderDB boil.ContextExecutor, supplierID string) ([]*BuyerWithLocation, error)",
            parameters = {
              {
                label = "ctx context.Context"
              },
              {
                label = "orderDB boil.ContextExecutor"
              },
              {
                label = "supplierID string"
              }
            }
          }
        }
      }
    }
  }
  ```

Solution:
Ensure we retain this information before showing the signature information.

Closes #32381
Diffstat:
Mruntime/lua/vim/lsp/buf.lua | 1+
1 file changed, 1 insertion(+), 0 deletions(-)

diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua @@ -315,6 +315,7 @@ local function process_signature_help_results(results) local result = r.result --- @type lsp.SignatureHelp if result and result.signatures and result.signatures[1] then for _, sig in ipairs(result.signatures) do + sig.activeParameter = sig.activeParameter or result.activeParameter signatures[#signatures + 1] = { client, sig } end end