ray-x / lsp_signature.nvim

LSP signature hint as you type
Apache License 2.0
2.01k stars 56 forks source link

Typing quotes in insert mode breaks floating window and inline prompt #261

Open smitropoulos opened 1 year ago

smitropoulos commented 1 year ago

I managed to replicate it using the minimum config posted in the readme

https://user-images.githubusercontent.com/21141766/224518524-0c574791-ff4f-4a2a-a3de-fd87707fe89a.mov

smitropoulos commented 1 year ago

Managed to do a little debugging.


שׁ .../nvim/lazy/lsp_signature.nvim/lua/lsp_signature/init.lua:801 |1: changed
שׁ ...vim/lazy/lsp_signature.nvim/lua/lsp_signature/helper.lua:599 |1: {
  triggerCharacters = { "(", "," }
}
 |2:   fmt.Println("
שׁ ...vim/lazy/lsp_signature.nvim/lua/lsp_signature/helper.lua:235 |1: ( |2: true
שׁ ...vim/lazy/lsp_signature.nvim/lua/lsp_signature/helper.lua:237 |1: (
שׁ ...vim/lazy/lsp_signature.nvim/lua/lsp_signature/helper.lua:235 |1: , |2: false
שׁ ...vim/lazy/lsp_signature.nvim/lua/lsp_signature/helper.lua:241 |1: not special |2: ,
שׁ ...vim/lazy/lsp_signature.nvim/lua/lsp_signature/helper.lua:252 |1: [%(,][^%(,%)]*$ |2: %(, |3: ^%(,%)
שׁ ...vim/lazy/lsp_signature.nvim/lua/lsp_signature/helper.lua:265 |1: last trigger char |2: (
שׁ ...vim/lazy/lsp_signature.nvim/lua/lsp_signature/helper.lua:634 |1: lsp cap:  |2: true |3: true |4: 14
שׁ .../nvim/lazy/lsp_signature.nvim/lua/lsp_signature/init.lua:610 |1: delta |2: (" |3:   fmt.Println(" |4:   fmt.Println( |5: {}

שׁ .../nvim/lazy/lsp_signature.nvim/lua/lsp_signature/init.lua:685 |1: Triggered
שׁ .../nvim/lazy/lsp_signature.nvim/lua/lsp_signature/init.lua:195 |1: signature handler
שׁ .../nvim/lazy/lsp_signature.nvim/lua/lsp_signature/init.lua:212 |1: no valid signatures
שׁ ...vim/lazy/lsp_signature.nvim/lua/lsp_signature/helper.lua:341 |1: stack traceback:
        ...vim/lazy/lsp_signature.nvim/lua/lsp_signature/helper.lua:341: in function 'cleanup_async'
        .../nvim/lazy/lsp_signature.nvim/lua/lsp_signature/init.lua:216: in function 'handler'
        /usr/share/nvim/runtime/lua/vim/lsp.lua:1383: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>
שׁ ...vim/lazy/lsp_signature.nvim/lua/lsp_signature/helper.lua:350 |1: async cleanup:  |2: i
שׁ ...vim/lazy/lsp_signature.nvim/lua/lsp_signature/helper.lua:321 |1: cleanup vt |2: 7
שׁ ...vim/lazy/lsp_signature.nvim/lua/lsp_signature/helper.lua:325 |1: bufnr, ns |2: 4 |3: 38
שׁ ...vim/lazy/lsp_signature.nvim/lua/lsp_signature/helper.lua:332 |1: closing winnr |2: 1003

This is a small portion of the debug log, the moment I hit the quotes in the parentheses. It seems like the gopls LSP cannot really understand that a quoted string is a string, which leads to

local signature_handler = function(err, result, ctx, config)
  log('signature handler')
  if err ~= nil then
    print(err)
    return
  end

  -- log("sig result", ctx, result, config)
  -- if config.check_client_handlers then
  --   -- this feature will be removed
  --   if helper.client_handler(err, result, ctx, config) then
  --     return
  --   end
  -- end
  local client_id = ctx.client_id
  local bufnr = ctx.bufnr
  if result == nil or result.signatures == nil or result.signatures[1] == nil then
    -- only close if this client opened the signature
    log('no valid signatures', result)

    status_line = { hint = '', label = '' }
    if _LSP_SIG_CFG.client_id == client_id then
      helper.cleanup_async(true, 0.2, true)
      -- need to close floating window and virtual text (if they are active)

which will cleanup the floating window and the inline one just like in the desc.

stormherz commented 1 year ago

having the same issue, with the same language (Go). Tried on Rust - didn't seem to happen there