Repository: neovim/neovim
File: runtime/lua/vim/lsp/buf.lua (Lua)

Code before:

    if not next(signatures) then
      if config.silent ~= true then
        print('No signature help available')
      end
      return
    end

    local ft = vim.bo[ctx.bufnr].filetype
    local total = #signatures
    local idx = active_signature - 1

    --- @param update_win? integer
    local function show_signature(update_win)
      idx = (idx % total) + 1
      local client, result = signatures[idx][1], signatures[idx][2]
      --- @type string[]?
      local triggers =
        vim.tbl_get(client.server_capabilities, 'signatureHelpProvider', 'triggerCharacters')
      local lines, hl =
        util.convert_signature_help_to_markdown_lines({ signatures = { result } }, ft, triggers)
      if not lines then
        return
      end

      local sfx = total > 1 and string.format(' (%d/%d) (<C-s> to cycle)', idx, total) or ''
      local title = string.format('Signature Help: %s%s', client.name, sfx)
      if config.border then
        config.title = title
      else
        table.insert(lines, 1, '# ' .. title)
        if hl then
          hl[1] = hl[1] + 1
          hl[3] = hl[3] + 1
        end
      end

      config._update_win = update_win

      local buf, win = util.open_floating_preview(lines, 'markdown', config)

      if hl then
        vim.api.nvim_buf_clear_namespace(buf, sig_help_ns, 0, -1)
        vim.hl.range(
          buf,
          sig_help_ns,
          'LspSignatureActiveParameter',
          { hl[1], hl[2] },
          { hl[3], hl[4] }
        )
      end

Review comment (suggestion):
I still think we should check that `config.focusable ~= false` here. The cycle keymap is irrelevant if you can't focus the signature help window.

Code after:

    if not next(signatures) then
      if config.silent ~= true then
        print('No signature help available')
      end
      return
    end

    local ft = vim.bo[ctx.bufnr].filetype
    local total = #signatures
    local can_cycle = total > 1 and config.focusable ~= false
    local idx = active_signature - 1

    --- @param update_win? integer
    local function show_signature(update_win)
      idx = (idx % total) + 1
      local client, result = signatures[idx][1], signatures[idx][2]
      --- @type string[]?
      local triggers =
        vim.tbl_get(client.server_capabilities, 'signatureHelpProvider', 'triggerCharacters')
      local lines, hl =
        util.convert_signature_help_to_markdown_lines({ signatures = { result } }, ft, triggers)
      if not lines then
        return
      end

      local sfx = total > 1
          and string.format(' (%d/%d)%s', idx, total, can_cycle and ' (<C-s> to cycle)' or '')
        or ''
      local title = string.format('Signature Help: %s%s', client.name, sfx)
      if config.border then
        config.title = title
      else
        table.insert(lines, 1, '# ' .. title)
        if hl then
          hl[1] = hl[1] + 1
          hl[3] = hl[3] + 1
        end
      end

      config._update_win = update_win

      local buf, win = util.open_floating_preview(lines, 'markdown', config)

      if hl then
        vim.api.nvim_buf_clear_namespace(buf, sig_help_ns, 0, -1)
        vim.hl.range(
          buf,
          sig_help_ns,
          'LspSignatureActiveParameter',
          { hl[1], hl[2] },