Skip to content

An alternate signature help request handler for neovim

Notifications You must be signed in to change notification settings

aattoa/nvim-everysig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

nvim-everysig

A tiny neovim plugin that provides an alternate textDocument/signatureHelp request handler that displays every signature returned by the language server.

This is helpful in languages that support function overloading, such as C++.

This should be usable in any language, as when only one signature is available, the behavior should match the built-in default vim.lsp.handlers.signature_help.

Screenshots

Every signature visible:

Only viable signature visible:

C++23 std::print with signature numbering enabled:

Regarding empty lines

With neovim 0.10, signatures are surrounded by empty lines. This should be fixed when vertical conceal is implemented.

Optional setup

require('everysig').setup(options)

The options table may contain the following keys:

  • override: boolean (default false), whether to override the default signature help handler.
  • silent: boolean (default false), whether to silence "No signature help available" notifications.
  • number: boolean (default false), whether to append number comments to displayed signatures.

Example plugin spec for lazy.nvim:

{
    'aattoa/nvim-everysig',
    opts = { override = true }, -- Options passed to `setup`.
    lazy = true,                -- Lazy-load the plugin ...
    event = 'LspAttach',        -- ... when an LSP client attaches to a buffer.
}

If overridden, the signature help request is triggered with the usual vim.lsp.buf.signature_help. For example, to get signature help with ctrl+space in normal mode and insert mode:

vim.keymap.set({ 'n', 'i' }, '<C-Space>', vim.lsp.buf.signature_help)

The handler

The signature help handler can be accessed without any setup.

For example, manually override the default handler, which is equivalent to setup({ override = true }):

vim.lsp.handlers['textDocument/signatureHelp'] = require('everysig').signature_help_handler

About

An alternate signature help request handler for neovim

Topics

Resources

Stars

Watchers

Forks

Languages