Skip to content

erhickey/sig-window-nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

sig-window-nvim

Neovim plugin that displays available lsp signature help in a highly configurable floating window, and highlights active parameters.

This plugin was heavily inspired by lsp_signature. If you're looking for a more feature-rich signature window definitely check it out.

Installation

Install manually or with your favorite plugin manager and add the following line to your startup script:

require('sig-window-nvim').setup({})

or use on_attach to provide lsp client specific configurations:

require('sig-window-nvim').on_attach(client, bufnr, {})

Configuration

A configuration table can be passed to setup as its first argument, or to on_attach as its third argument. Example below uses the default values:

require('sig-window-nvim').setup({
  zindex = 50,                -- signature window z-index
  border = 'rounded',         -- signature window border, see ':help nvim_open_win' for possible values
  max_width = 80,             -- signature window max width
  max_height = 5,             -- signature window max height
  hl_active_param = true,     -- whether or not to highlight the active parameter
  hl_group = 'rainbowcol4',   -- highlight group used to highlight active parameter
})

Additionally, the configuration can contain a function that accepts five arguments:

  1. label: string to be displayed in the signature window
  2. config: configuration table passed to setup, plus omitted default values
  3. width: suggested width based on label length and max_width/max_height
  4. height: suggested height based on label length and max_width/max_height
  5. other_labels: overloaded function signatures that aren't the active signature

The expected return value is a table that will be passed to nvim_open_win as its configuration. See :help nvim_open_win for more details. The example below displays the default behavior:

require('sig-window-nvim').setup({
  window_config = function(label, config, width, height, other_labels)
    return {
      relative = 'editor',
      anchor = 'NE',
      width = width,
      height = height,
      row = 0,
      col = vim.api.nvim_win_get_width(0),
      focusable = false,
      zindex = config.zindex,
      style = 'minimal',
      border = config.border,
    }
  end
})

Caveats

This plugin sends a signatureHelp request to attached language servers on two events, when insert mode is entered, and whenever the cursor moves in insert mode. This is the easiest way to guarantee the window is always be up to date, but at the cost of an unnecessary amount of requests. I have no idea what a reasonable request rate is for most language servers. If you install this plugin, or have it installed and install a new language server, then find your performance has decreased a noticable amount, this plugin may be to blame.

About

neovim plugin for automatic display of LSP signature help in a floating window

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages