fix(lsp): check if sig_help window is focusable when configuring cycle keymap

This commit is contained in:
Maria José Solano
2024-12-29 07:35:57 -08:00
committed by Lewis Russell
parent 0e880b5612
commit 02097e43c8

View File

@ -329,7 +329,6 @@ local sig_help_ns = api.nvim_create_namespace('vim_lsp_signature_help')
--- @class vim.lsp.buf.signature_help.Opts : vim.lsp.util.open_floating_preview.Opts --- @class vim.lsp.buf.signature_help.Opts : vim.lsp.util.open_floating_preview.Opts
--- @field silent? boolean --- @field silent? boolean
-- TODO(lewis6991): support multiple clients
--- Displays signature information about the symbol under the cursor in a --- Displays signature information about the symbol under the cursor in a
--- floating window. --- floating window.
--- @param config? vim.lsp.buf.signature_help.Opts --- @param config? vim.lsp.buf.signature_help.Opts
@ -356,6 +355,7 @@ function M.signature_help(config)
local ft = vim.bo[ctx.bufnr].filetype local ft = vim.bo[ctx.bufnr].filetype
local total = #signatures local total = #signatures
local can_cycle = total > 1 and config.focusable
local idx = 0 local idx = 0
--- @param update_win? integer --- @param update_win? integer
@ -371,7 +371,7 @@ function M.signature_help(config)
return return
end end
local sfx = total > 1 and string.format(' (%d/%d) (<C-s> to cycle)', idx, total) or '' local sfx = can_cycle and string.format(' (%d/%d) (<C-s> to cycle)', idx, total) or ''
local title = string.format('Signature Help: %s%s', client.name, sfx) local title = string.format('Signature Help: %s%s', client.name, sfx)
if config.border then if config.border then
config.title = title config.title = title
@ -402,7 +402,7 @@ function M.signature_help(config)
local fbuf, fwin = show_signature() local fbuf, fwin = show_signature()
if total > 1 then if can_cycle then
vim.keymap.set('n', '<C-s>', function() vim.keymap.set('n', '<C-s>', function()
show_signature(fwin) show_signature(fwin)
end, { end, {