Giter VIP home page Giter VIP logo

lsp_signature.nvim's Introduction

lsp_signature.nvim

Show function signature when you type

  • This nvim plugin is made for completion plugins that do not support signature help. Need neovim-0.8+ and enable nvim-lsp. (check neovim-0.5/neovim-0.6/neovim-0.9 branch for earlier version support)

  • Inspired by completion-nvim, which does have lots of cool features.

  • Fully asynchronous lsp buf request.

  • Virtual text available

Golang with markdown

Highlight with "Search"

signature2.mov
Lua

lua

The plugin also re-write the builtin lsp signature allow the parameter highlight

signature_with_virtual_hint

Using virtual text to show the next parameter

virtual_hint

Virtual text only mode

(from @fdioguardi)

virtual_text_only

Multiple signatures

In case some of the languages allow function overload, the plugin will show all available signatures

multiple_signature

signature2

To switch between the signatures, use select_signature_key

Install:

" dein
dein#add('ray-x/lsp_signature.nvim')

" plug
Plug 'ray-x/lsp_signature.nvim'

" Packer
use {
  "ray-x/lsp_signature.nvim",
}

" Lazy
{
  "ray-x/lsp_signature.nvim",
  event = "VeryLazy",
  opts = {},
  config = function(_, opts) require'lsp_signature'.setup(opts) end
}

Setup / Attach the plugin

In your init.lua, call setup()

local cfg = {…}  -- add your config here
require "lsp_signature".setup(cfg)

Alternatively, call on_attach(cfg, bufnr) when the LSP client attaches to a buffer

e.g. gopls:

local golang_setup = {
  on_attach = function(client, bufnr)
    …
    require "lsp_signature".on_attach(signature_setup, bufnr)  -- Note: add in lsp client on-attachend,
  …
}

require'lspconfig'.gopls.setup(golang_setup)

Or use the newer LspAttach autocommands. The following example enables signatures for any attached language server:

vim.api.nvim_create_autocmd("LspAttach", {
  callback = function(args)
    local bufnr = args.buf
    local client = vim.lsp.get_client_by_id(args.data.client_id)
    if vim.tbl_contains({ 'null-ls' }, client.name) then  -- blacklist lsp
      return
    end
    require("lsp_signature").on_attach({
      -- ... setup options here ...
    }, bufnr)
  end,
})

Configure

Floating window borders

If you have a recent enough build of Neovim, you can configure borders in the signature help floating window(Thanks @Gabriel Sanches for the PR):

local example_setup = {
  on_attach = function(client, bufnr)
    …
    require "lsp_signature".on_attach({
      bind = true, -- This is mandatory, otherwise border config won't get registered.
      handler_opts = {
        border = "rounded"
      }
    }, bufnr)
    …
  end,
  …
}

Or:

require'lspconfig'.gopls.setup()
require "lsp_signature".setup({
  bind = true, -- This is mandatory, otherwise border config won't get registered.
  handler_opts = {
    border = "rounded"
  }
})

Keymap

No default keymaps are provided. There are two keymaps available in config:

  1. toggle_key: Toggle the signature help window. It manual toggle config.floating_windows on/off
  2. select_signature_key: Select the current signature when mulitple signature is avalible.

Customize the keymap in your config:

  • To toggle floating windows in Normal mode, you need either define a keymap to vim.lsp.buf.signature_help() or require('lsp_signature').toggle_float_win()

e.g.

    vim.keymap.set({ 'n' }, '<C-k>', function()       require('lsp_signature').toggle_float_win()
    end, { silent = true, noremap = true, desc = 'toggle signature' })

    vim.keymap.set({ 'n' }, '<Leader>k', function()
     vim.lsp.buf.signature_help()
    end, { silent = true, noremap = true, desc = 'toggle signature' })

Full configuration (with default values)

 cfg = {
  debug = false, -- set to true to enable debug logging
  log_path = vim.fn.stdpath("cache") .. "/lsp_signature.log", -- log dir when debug is on
  -- default is  ~/.cache/nvim/lsp_signature.log
  verbose = false, -- show debug line number

  bind = true, -- This is mandatory, otherwise border config won't get registered.
               -- If you want to hook lspsaga or other signature handler, pls set to false
  doc_lines = 10, -- will show two lines of comment/doc(if there are more than two lines in doc, will be truncated);
                 -- set to 0 if you DO NOT want any API comments be shown
                 -- This setting only take effect in insert mode, it does not affect signature help in normal
                 -- mode, 10 by default

  max_height = 12, -- max height of signature floating_window
  max_width = 80, -- max_width of signature floating_window, line will be wrapped if exceed max_width
                  -- the value need >= 40
  wrap = true, -- allow doc/signature text wrap inside floating_window, useful if your lsp return doc/sig is too long
  floating_window = true, -- show hint in a floating window, set to false for virtual text only mode

  floating_window_above_cur_line = true, -- try to place the floating above the current line when possible Note:
  -- will set to true when fully tested, set to false will use whichever side has more space
  -- this setting will be helpful if you do not want the PUM and floating win overlap

  floating_window_off_x = 1, -- adjust float windows x position.
                             -- can be either a number or function
  floating_window_off_y = 0, -- adjust float windows y position. e.g -2 move window up 2 lines; 2 move down 2 lines
                              -- can be either number or function, see examples

  close_timeout = 4000, -- close floating window after ms when laster parameter is entered
  fix_pos = false,  -- set to true, the floating window will not auto-close until finish all parameters
  hint_enable = true, -- virtual hint enable
  hint_prefix = "🐼 ",  -- Panda for parameter, NOTE: for the terminal not support emoji, might crash
  -- or, provide a table with 3 icons
  -- hint_prefix = {
  --     above = "↙ ",  -- when the hint is on the line above the current line
  --     current = "← ",  -- when the hint is on the same line
  --     below = "↖ "  -- when the hint is on the line below the current line
  -- }
  hint_scheme = "String",
  hint_inline = function() return false end,  -- should the hint be inline(nvim 0.10 only)?  default false
  -- return true | 'inline' to show hint inline, return 'eol' to show hint at end of line, return false to disable
  -- return 'right_align' to display hint right aligned in the current line
  hi_parameter = "LspSignatureActiveParameter", -- how your parameter will be highlight
  handler_opts = {
    border = "rounded"   -- double, rounded, single, shadow, none, or a table of borders
  },

  always_trigger = false, -- sometime show signature on new line or in middle of parameter can be confusing, set it to false for #58

  auto_close_after = nil, -- autoclose signature float win after x sec, disabled if nil.
  extra_trigger_chars = {}, -- Array of extra characters that will trigger signature completion, e.g., {"(", ","}
  zindex = 200, -- by default it will be on top of all floating windows, set to <= 50 send it to bottom

  padding = '', -- character to pad on left and right of signature can be ' ', or '|'  etc

  transparency = nil, -- disabled by default, allow floating win transparent value 1~100
  shadow_blend = 36, -- if you using shadow as border use this set the opacity
  shadow_guibg = 'Black', -- if you using shadow as border use this set the color e.g. 'Green' or '#121315'
  timer_interval = 200, -- default timer check interval set to lower value if you want to reduce latency
  toggle_key = nil, -- toggle signature on and off in insert mode,  e.g. toggle_key = '<M-x>'
  toggle_key_flip_floatwin_setting = false, -- true: toggle floating_windows: true|false setting after toggle key pressed
     -- false: floating_windows setup will not change, toggle_key will pop up signature helper, but signature
     -- may not popup when typing depends on floating_window setting

  select_signature_key = nil, -- cycle to next signature, e.g. '<M-n>' function overloading
  move_cursor_key = nil, -- imap, use nvim_set_current_win to move cursor between current win and floating window
  -- e.g. move_cursor_key = '<M-p>',
  -- once moved to floating window, you can use <M-d>, <M-u> to move cursor up and down
  keymaps = {}  -- relate to move_cursor_key; the keymaps inside floating window
  -- e.g. keymaps = { 'j', '<C-o>j' } this map j to <C-o>j in floating window
  -- <M-d> and <M-u> are default keymaps to move cursor up and down
}

-- recommended:
require'lsp_signature'.setup(cfg) -- no need to specify bufnr if you don't use toggle_key

-- You can also do this inside lsp on_attach
-- note: on_attach deprecated
require'lsp_signature'.on_attach(cfg, bufnr) -- no need to specify bufnr if you don't use toggle_key

Signature in status line

Sample config

API

require("lsp_signature").status_line(max_width)

return a table

{
  label = 'func fun_name(arg1, arg2…)'
  hint = 'arg1',
  range = {start = 13, ['end'] = 17 }
  doc = 'func_name return arg1 + arg2 …'
}

In your statusline or winbar

local current_signature = function(width)
  if not pcall(require, 'lsp_signature') then return end
  local sig = require("lsp_signature").status_line(width)
  return sig.label .. "🐼" .. sig.hint
end

signature in status line

set floating windows position based on cursor position

-- cfg = {…}  -- add you config here
local cfg = {
  floating_window_off_x = 5, -- adjust float windows x position.
  floating_window_off_y = function() -- adjust float windows y position. e.g. set to -2 can make floating window move up 2 lines
    local linenr = vim.api.nvim_win_get_cursor(0)[1] -- buf line number
    local pumheight = vim.o.pumheight
    local winline = vim.fn.winline() -- line number in the window
    local winheight = vim.fn.winheight(0)

    -- window top
    if winline - 1 < pumheight then
      return pumheight
    end

    -- window bottom
    if winheight - winline < pumheight then
      return -pumheight
    end
    return 0
  end,
}
require "lsp_signature".setup(cfg)

Should signature floating windows fixed

fix_pos can be a function, it took two element, first is the signature result for your signature, second is lsp client.

You can provide a function.

e.g.

fix_pos = function(signatures, lspclient)
   if signatures[1].activeParameter >= 0 and #signatures[1].parameters == 1 then
     return false
   end
   if lspclient.name == 'sumneko_lua' then
     return true
   end
   return false
end

Sample config with cmp, luasnipet and autopair

init.lua

Q&A:

Q: What is the default colorscheme in screenshot:

A: aurora

Q: I can not see border after enable border = "single"/"rounded"

A: Try another colorscheme (e.g. colorscheme aurora, or colorscheme luna). If issue persists, please submit an issue

Q: It is not working 😡

A: Here is some trouble shooting: #1

If you are using JDTLS, please read this: issue #97

Q:I do not like the pop window background highlight, how to change it?

A: Redefine your NormalFloat and FloatBorder, esp if your colorscheme dose not define it.

Q: How to change parameter highlight

A: By default, the highlight is using "LspSignatureActiveParameter" defined in your colorscheme, you can either override "LspSignatureActiveParameter" or define, e.g. use IncSearch setup({ hi_parameter = "IncSearch"})

Q: I can not see 🐼 in virtual text

A: It is emoji, not nerdfont. Please check how to enable emoji for your terminal.

Q: Working with cmp/coq. The floating windows block cmp/coq

A: A few options here, z-index, floating_window_above_cur_line, floating_window_off_x/y, toggle_key. You can find the best setup for your workflow.

lsp_signature.nvim's People

Contributors

dmbfm avatar fdioguardi avatar fildo7525 avatar fnune avatar gbrlsnchs avatar gelio avatar hanspinckaers avatar hungrybirder avatar k14lb3 avatar kair8m avatar kazu914 avatar korigamik avatar kulakilam avatar llllvvuu avatar ltratt avatar ngpong avatar notomo avatar pysan3 avatar ray-x avatar ray-xu-deltatre avatar remi-labbe avatar spflaumer avatar sublimeful avatar tusqasi avatar weypare avatar whynothugo avatar zeertzjq avatar zeioth avatar zoriya avatar zwodahs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lsp_signature.nvim's Issues

How to use this standalone?

If I use the built-in signature help

vim.api.nvim_set_keymap("n", "gk", "<cmd>lua vim.lsp.buf.signature_help()<CR>", {})

I see the markdown backticks, however since the built-in signature help doesn't actually render a markdown preview, this is not-so-useful (note the backticks around ("output"):
2021-04-30-120948_1873x724_scrot

If i use lspsaga to render the signature help

vim.api.nvim_set_keymap("n", "gk", "<cmd>lua require('lspsaga.signaturehelp').signature_help()<CR>", {})

I get a nicely rendered markdown help, however I dont see any highlighting of the current parameter:
2021-04-30-121119_1106x567_scrot

How do I use this plugin?

Doesn't work on insert event

I installed the plugin this way
use "ray-x/lsp_signature.nvim"
and my added it to my config as follows

local on_attach = function()
  require('completion').on_attach()
  require'virtualtypes'.on_attach()
  require "lsp_signature".on_attach()
end
require'lspconfig'.pyright.setup{on_attach = on_attach}

calling lua vim.lsp.buf.signature_help() does give proper output
calling lua require'lsp_signature'.signature() also gives proper output

Some error about "outside range"

Thanks for this plugin, I like it alot (quite useful to do check signature of a method with a shortcut).

When I try to make use of the feature which shows me which argument I need to type, I keep getting this error.

Error executing vim.schedule lua callback: ...ck/packer/start/lsp_signature.nvim/lua/lsp_signature.lua:195: end_col value outside range
Error executing vim.schedule lua callback: ...ck/packer/start/lsp_signature.nvim/lua/lsp_signature.lua:195: end_col value outside range
Error executing vim.schedule lua callback: ...ck/packer/start/lsp_signature.nvim/lua/lsp_signature.lua:195: col value outside range

Maybe I'm doing something wrong. The language I'm testing this is python with pyright lsp

Signature help only activating on the first file opened.

The plugin is working fine on the first file opened:
image

but opening a new file, whether via Telescope or :e, it stops working:
image

  1. lua vim.lsp.buf.signature_help() shows the signature on the second file.
  2. lua require'lsp_signature'.signature() does not.
  3. Manually running require "lsp_signature".on_attach() on the second file fixes the issue.

I have this section in my init.vim file:

Plug 'ray-x/lsp_signature.nvim'

lua << EOF
  require'lsp_signature'.on_attach({
    extra_trigger_chars = {"(", ","}
  })
EOF

I've tried replacing it with simply require'lsp_signature'.on_attach() but that also doesn't work. It seems the on_attach isn't being called for new files being opened?

I've also removed lspsaga to see if that's the issue but the problem remains.

Error on opening ( or start of signature help

Using latest version of neovim HEAD , lastest version of lsp_signature when it gets the signature help on lua/python code i receive the following error

Error executing vim.schedule lua callback: ...utoload/plugged/lsp_signature.nvim/lua/lsp_signature.lua:71: attempt to concatenate local 'hint' (a nil value)

Lock the position of preview popup

It is hard ATM. Because I am using focus preview API neovim has and it does not have a position option. I will need to use floating windows API instead. In that case, will need to copy and paste codes from neovim lsp to lsp signature. Or I should submit a PR in neovim to add the option.
Either way, it not a quick fix and I am parking the request for now.

compe completions popup appears on top of the signature popup

Hey, I appreciate the work put into this plugin 👍

I have begun experimenting with it and I have noticed that the compe completions popup appears on top of the signature popup, both are shown at the same time:
image

In the gif shown in https://www.reddit.com/r/neovim/comments/mzjxhq/lsp_signature_can_be_better/ the signature popup is hidden when the completions popup is shown. Is there something else I need to configure?

I have only followed the readme instructions. I am calling require'lsp_signature'.on_attach() inside the LSP's on_attach function for a given lsp config.

Disable print hover not supported

I find the printing of hover not supported slightly annoying if I am in a buffer that does not support signature help. It would be great if there was an option for disabling this print

Showed only on the first function of the session

I tried add seems that in my tests the modal is showed only on the first function.
If I move in insert mode to another one I don't get anything. If I restart neovim and move to that function in insert mode the modal is showed.

Also with opening other files the issue is still there.

My dotfiles are there https://github.com/mte90/dotfiles

I have this with php files.

Use backtick decorator doesn't highlight parameter

Here is my lsp-signature config

cfg = {
  bind = true, -- This is mandatory, otherwise border config won't get registered.
              -- If you want to hook lspsaga or other signature handler, pls set to false
  doc_lines = 10, -- only show one line of comment set to 0 if you do not want API comments be shown

  hint_enable = true, -- virtual hint enable
  hint_prefix = "🐼 ",  -- Panda for parameter
  hint_scheme = "String",

  handler_opts = {
    border = "single"   -- double, single, shadow, none
  },
  decorator = {"`", "`"}  -- or decorator = {"***", "***"}  decorator = {"**", "**"} see markdown help
}

I 've changed decorator to * and **, It output italic and bold parameter. But when change to backtick, parameter isn't highlighted
image

Getting "failed get highlight parameter 0 0"

Hello!

I am trying get highlight of the parameters in the pop-up, but as soon as I type ( to provide the parameters I get the error failed get highlight parameter 0 0.
This is using pyright and the following python code can be used to reproduce it:

import os

def bla(a: int, b: int, c: int, d: int):
    print(f"a #{a}, b #{b}, c #{c}, d #{d}")

def x(a):
    print("hey! %s" % a)
    bla(

Here is a screenshot:

image

Here is the debug output:

שׁ  |1: insert enter
שׁ  |1: insert enter
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: signature triggered
שׁ  |1: sig result |2: {
  activeParameter = 4,
  activeSignature = 0,
  signatures = { {
      activeParameter = 0,
      label = "(a: int, b: int, c: int, d: int) -> None",
      parameters = { {
          label = { 1, 7 }
        }, {
          label = { 9, 15 }
        }, {
          label = { 17, 23 }
        }, {
          label = { 25, 31 }
        } }
    } }
}
 |3: {
  border = "single",
  check_client_handlers = true,
  check_pumvisible = true,
  line_to_cursor = "    bla(",
  trigger_from_lsp_sig = true,
  triggered_chars = { "(", ",", ")" }
}

שׁ  |1: no next param
שׁ  |1: md lines |2: { "```python", "(a: int, b: int, c: int, d: int) -> None", "```" }

שׁ  |1: label: |2: (a: int, b: int, c: int, d: int) -> None |3: 0 |4: 1 |5: 4 |6: {
  activeParameter = 0,
  label = "(a: int, b: int, c: int, d: int) -> None",
  parameters = { {
      label = { 1, 7 }
    }, {
      label = { 9, 15 }
    }, {
      label = { 17, 23 }
    }, {
      label = { 25, 31 }
    } }
}

שׁ  |1: win config |2: {
  border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" },
  check_client_handlers = true,
  check_pumvisible = true,
  close_events = { "BufHidden", "InsertLeavePre" },
  focus_id = "textDocument/signatureHelplsp_signature795",
  line_to_cursor = "    bla(",
  max_height = 12,
  max_width = 120,
  offset_x = -1,
  stylize_markdown = true,
  trigger_from_lsp_sig = true,
  triggered_chars = { "(", ",", ")" },
  zindex = 200
}

שׁ  |1: extmark |2: 0 |3: 0
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: timer start
שׁ  |1: timer start

From a quick glance at the code, I couldn't figure out the issue. I got here:

local nextParameter = signature.parameters[activeParameter + 1]

Can't really tell why that is returning nil? Or perhaps I am following the code incorrectly. My lua skillz aren't that great.

Any ideas?

Thanks!

Doesn't seem to work

Hi! I am quite keen to get try out this plugin, but as of now it doesn't work. Tried lua file with sumneko's lsp, and python with pyright; didn't get any popups with argument once in () after function call for neither of filetypes.

Installed with packer like that:

use {
  "neovim/nvim-lspconfig",
  requires = {
    {
      "kosayoda/nvim-lightbulb",
      config = function()
        vim.api.nvim_command("highlight LightBulbVirtualText guifg=red")
      end
    },
    "nvim-lua/lsp-status.nvim",
    {"ojroques/nvim-lspfuzzy", config = require "lspfuzzy".setup {}},
    {
      "ray-x/lsp_signature.nvim",
      config = function()
        require "lsp_signature".on_attach()
      end
    }
  }
}

I also have nvim-compe if that makes any difference.

Solargraph: .vim/bundle/lsp_signature.nvim/lua/lsp_signature.lua:168: attempt to get length of field 'parameters' (a nil value)

Build info:

NVIM v0.5.0
Build type: Release
LuaJIT 2.0.5

I have lspconfig setup with https://github.com/hrsh7th/nvim-compe and solargraph
With a ruby script like so:

# frozen_string_literal: true

puts()

Trying to see the signature for puts returns

Error executing vim.schedule lua callback: ...ond/.vim/bundle/lsp_signature.nvim/lua/lsp_signature.lua:168: attempt to get length of field 'parameters' (a nil value)

I tried positioning the cursor after the ( and then doing lua require'lsp_signature'.signature(), and it gives me the same error.

hint not working when using lspsaga

When use_lspsaga is enabled I can't see the hint text above the cursor and lspsaga's window has no indication of what parameter I am editing

Nvim breaking changes

Latest nvim:

focusable_preview is deprecated. Please use open_floating_preview and pass focus_id = [unique_name] instead
Error executing vim.schedule lua callback: /usr/local/share/nvim/runtime/lua/vim/lsp/util.lua:1322: syntax: expected string, got table
stack traceback:
/usr/local/share/nvim/runtime/lua/vim/lsp/util.lua:1322: in function 'focusable_preview'
...ck/packer/start/lsp_signature.nvim/lua/lsp_signature.lua:139: in function 'handler'
/usr/local/share/nvim/runtime/lua/vim/lsp.lua:896: in function 'cb'
vim.lua:277: in function vim.lua:277

Why are we manually attaching?

The following snippet of code is what I use on my plugin lsp-rooter to attach automatically without having to attach it on the lspconfig config.

local on_attach = function(client, bufnr)
  -- Attach logic goes here
end
local _start_client = vim.lsp.start_client
vim.lsp.start_client = function(lsp_config)
  if lsp_config.on_attach == nil then
    lsp_config.on_attach = on_attach
  else
    local _on_attach = lsp_config.on_attach
    lsp_config.on_attach = function(client, bufnr)
      on_attach(client, bufnr)
      _on_attach(client, bufnr)
    end
  end
  return _start_client(lsp_config)
end

Would be great to stop the manual thing, and use the solution provided instead.

Signature window occludes popup menu for completion as well as text

Please see this screenshot:

image

when LSP signature popup window is open, it will occlude and hide the popup menu triggered for completion.

Here is what would be shown if there were no signature displayed:

image

Similarily, the signature window will hide the main editor itself when the cursor moves to a position that overlaps the signature window:

image

Popup closes on last parameter

I'm having a strange problem: the popup containing function signature hints stays open while I'm typing for all parameters but the last one. Last one gets closed as soon as I insert a character.

Excerpt from my config:

lua << EOF
  local custom_on_attach = function (client)
    require'lsp_signature'.on_attach()
  end

  require'lspconfig'.tsserver.setup{ on_attach = custom_on_attach }
EOF

lua << EOF
  require "lsp_signature".setup({
    bind = true, -- This is mandatory, otherwise border config won't get registered.
    handler_opts = {
      border = "rounded"
    }
  })
EOF

Malformed pattern

👋🏼

I'm primarily using javascript and typescript and I'm seeing this quite often:

image

I can replicate it with the default config and writing console.log('foo',.

Use a highlight instead of backtick for formatting the current parameter

First of all, thank you for this plugin, I think it's very useful I think that some parts of how we display the current parameter can be improved. My case is the following:

  • Functions with 1 parameter don't show backticks or any special color for the first and unique parameter (and thus, the current one)
  • Functions with more than 1 parameter show correctly with backticks. In my case, though, only the backticks themselves have a different color. The parameter name itself appears with the same color as the rest of the text. My markdown inline code blocks have the correct color, so not sure which file format it's getting to show it. I'm trying it with Rust and rust-analyzer LSP.

My proposal will be, if possible, to add a highlight to them, instead of adding the backticks. By default, it can be linked to some other like Keyword, or have a default color provided by the plugin.

pyright lsp signature issues

I am trying to set lsp signature for pyright lsp with the latest neovim nightly. I have noticed it does not automatically popup the signature for the modules like when I do "import pandas as pd" for pandas etc. Also when I try to do say "pd.read_" the signatures of the method are pretty slow .It only pops up when I press tab and cycle through the list of the autocomplete options and recycle to the top. Could you please help. I am new to this.

focusable_preview expected string, got table

Hi, I am getting this error, when I am hitting a ( to start the completion

Error executing vim.schedule lua callback: /usr/share/nvim/runtime/lua/vim/lsp/util.lua:1382: syntax: expected string, got table
stack traceback:
        /usr/share/nvim/runtime/lua/vim/lsp/util.lua:1382: in function 'focusable_preview'
        ...ig/nvim/plugged/lsp_signature.nvim/lua/lsp_signature.lua:46: in function 'handler'
        /usr/share/nvim/runtime/lua/vim/lsp.lua:896: in function 'cb'
        vim.lua:277: in function <vim.lua:277>
$ nvim --version                  
NVIM v0.5.0-dev+1405-g2f0e5e7e6
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3

failed get highlight parameter nil nil

Hi,

I use this config

local signature_help_cfg = {
  bind = true,
  doc_lines = 2,
  floating_window = true,
  hint_enable = false,
  hi_parameter = 'Constant',
  max_height = 4,
  max_width = 80,
  handler_opts = {border = 'none'},
}

Constant highlight group is

:hi Constant
Constant       xxx gui=bold guifg=#C5656B

When I write function parameter, the window with the signature help shows up, but I get no current parameter highlight and an error spawn failed get highlight parameter nil nil.

Extra_trigger_chars don't seem to work

Hi,

I'm trying to trigger lsp-signature by the character '{' rather than '(' for invoking the constructor of a C++ class but it doesn't work, I get no signature pop-up when trying to use '{'.

I've added the character to the extra_trigger_chars in the configuration like shown below:

-- Setup lsp-signature
require'lsp_signature'.on_attach({
  bind = true,
  doc_lines = 10,
  hint_enable = false,
  handler_opts = {
    border = "none", -- double, single, shadow, none
  },
  extra_trigger_chars = {"{"},
})

MRPE:

struct Example
{
    Example(int a, int b, std::string name)
        : m_a(a), m_b(b), m_name(std::move(name))
    {}

    int m_a, m_b;
    std::string m_name;
};

int main()
{
   Example ex{10, <-------- Here I do not get the floating window pop-up
}

Not changing selected param as I type

👋🏻

I am using this with ElixirLS and LSP and as I type new parameters to the function it is not moving with it. Also, the panda seems to disappear when moving to the second param. See example screenshot. Happy to help debug/fix the issue, just not sure where to start. Thanks!

image

Error while opening a file: E5108: Error executing lua vim.lua:63: .../.config/nvim/pack/minpac/start/lsp_signature.nvim/lua/lsp_signature.lua:225: '=' expected near 'continue'

I use minpac to install this plugin call minpac#add('ray-x/lsp_signature.nvim'). And I put this in my init.vim:

lua << EOF
require'lsp_signature'.on_attach()
EOF

Every time I open a file, this error appears:

E5108: Error executing lua vim.lua:63: .../.config/nvim/pack/minpac/start/lsp_signature.nvim/lua/lsp_signature.lua:225: '=' expected near 'continue'

The error line is goto continue. After I comment out that line, a similar error appears:

E5108: Error executing lua vim.lua:63: .../.config/nvim/pack/minpac/start/lsp_signature.nvim/lua/lsp_signature.lua:232: '=' expected near 'continue'

This error line is goto continue, too. After I comment out that line, another error appears:

E5108: Error executing lua vim.lua:63: .../.config/nvim/pack/minpac/start/lsp_signature.nvim/lua/lsp_signature.lua:260: unexpected symbol near ':'

This error line is ::continue::. After I comment out that line, no error appears.

I use the prebuilt neovim on github and its version is:

NVIM v0.5.0-dev+1398-gd09b8ad71
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3

Setup with rust_analyzer and rust_tools

First off, awesome plugin.

Rust Setup (Not Working)

Tried a normal setup with rust it does not work.

Minimal Not Working RC (look caveat below)

lua << EOF
require'lspconfig'.rust_analyzer.setup{}
require'lsp_signature'.on_attach({})
EOF

Though as mentioned in the readme if I add this in the rust_analyzer setup everything works perfectly fine.

There is a plugin called rust-tools which I use in my setup. I ran into an issue where this plugin was not working with rust_tools.

Rust Setup (Not Working)

Minimal Not Working RC (look caveat below)

lua << EOF
require'lspconfig'.rust_analyzer.setup{
    on_attach = function() require'lsp_signature'.on_attach({bind = true}) end
}
require'rust-tools'.setup()
EOF

Rust Setup (Working)

But if I change the ordering of these then it does work. Example -
Minimal Wokring RC (look caveat below)

lua << EOF
require'rust-tools'.setup()
require'lspconfig'.rust_analyzer.setup{
    on_attach = function() require'lsp_signature'.on_attach({bind = true}) end
}
EOF

Why report this issue if this is working?

  1. I would like to understand why this is happening and if you can provide any help in that regard would appreciate it.
  2. It might be helpful for someone else who stumbles on something similar. (Probably worthwhile to add this info in the Readme)

Caveat

Note: I am using NixOS and I have installed these with the nix pckage manager, so I don't have a vim/neovim installer. Don't really know how they work. But should be standard enough to set up.

Packages used here are

  1. nvim-lspconfig
  2. lsp_signature.nvim
  3. rust-tools.nvim

highlights

Is there a way to remove these ``` when highlighting a parameter?

Also is there a way to change fore/background of the signature since it doesn't really match anything:
image

As an example here is how Saga diagnostic looks like:
image

Feature request: Bold/recolor the current parameter in the popup

The textDocument/signatureHelp response includes an activeParameter field, which indicates where the cursor is in the list of parameters. It would be nice if this information could be use to bolden, or use a different color for the active parameter in the popup. Perhaps by using the parameter labels and changing the signature label based on that information.

{ {                                                                                                                                                                                                          
    result = {
      activeParameter = 1,
      activeSignature = 0,
      signatures = { {
          label = "SomeFunc(context.Context, string, string) error",
          parameters = { {
              label = "context.Context"
            }, {
              label = "string"
            }, {
              label = "string"
            } }
        } }
    }
  } }

Option to extend `triggered_chars`

Why? I want to improve the experience while typing.

For example my LS returned the chars ( and ,.

Now if I am typing in_array('test', _) (where _ is the cursor) there is no completion. Now I am just before starting the next parameter but there is no completion anymore. For me I want to add (space) to the trigger list event at this point.

Does not work with omnisharp

The equivalent VS Code feature works with the same version of omnisharp, but for lsp_signature I get nothing.

I'm installing omnisharp via lsp_install:

require'lspinstall'.setup()

then :LspInstall csharp to install the csharp language server (followed by restarting neovim).

Setting up my csharp lsp config the same way I'm setting up tsserver. Using treesitter for typescript and C#. Everything works great when it comes to typescript and csharp completion, but lsp_signature is only working for typescript.

The following shows the signature:

lua vim.lsp.buf.signature_help()

But the following does not:

lua require'lsp_signature'.signature()

Running this manually makes no difference:

lua require "lsp_signature".on_attach()

(although that's already set up in my configuration anyway).

I tried disabling my entire neovim config except for nvim-lspconfig, nvm-lspinstall and lsp_signature but it still didn't work (but continued to work for typescript).

Packer fails to update this plugin

Packer fails to update this plugin with the following error message:

 ✗ Failed to update ray-x/lsp_signature.nvim
  Errors:
    fatal: refusing to merge unrelated histories
    2dfeb79

I think this is related to this comment which specifies it will fail if the public branch has been rebased. The feature of allowing unrelated git histories from the side of packer is ongoing.

I also think it's best practice to not rebase a public branch which a lot of people rely on. This will also prevent someone to know which new commits were added since the last update and thus what are the new features/fixes for the plugin.

If rebasing is not the cause of this error, then please ignore this and close it.

Configuration is not read if signature_help handler defined

If i have this handler in my lsp configuration

["textDocument/signatureHelp"] = vim.lsp.with(
  vim.lsp.handlers.signature_help, {
    border = "rounded"
  }
)

the configuration of this plugin is not read, instead it is using the default one.

Is this expected ?

Floating window disappearing with snippets

Description

In the image below I start typing the function name, select the compe completion option from lsp. luasnip fills in the variable names for the arguments, and i can press <Tab> to move through the snippet positions.

Problem gif

  1. The floating signature initially appears while i enter the first argument.
  2. The floating signature disappears when i press tab to move to the second argument, and while i change it.
  3. I press <Tab> again to move to the third argument, enter normal mode, then enter insert mode with cw. On entering insert mode the floating window reappears as I would expect it.

Problem

I would expect the floating window to remain while I tab through the function arguments.

When I disable luasnip and set rust-analyzer to not send argument snippets (rust-analyzer.completion.AddCallArgumentSnippets=false), the signature float works fine with the rest of my config.

Setup

  • neovim 0.5
  • compe,
  • nvim-lspconfig
  • rust-tools

I set up lsp_signature like this:

  require'lsp_signature'.on_attach({
	  hint_enable=false,
  })

I have tab configured as described here: https://github.com/hrsh7th/nvim-compe#how-to-use-tab-to-navigate-completion-menu with an alteration for working with luasnp.

-- Example of modificaiton
_G.s_tab_complete = function()
	if vim.fn.pumvisible() == 1 then
		return t "<C-p>"
	elseif require("luasnip").jumpable(-1) then
		return t "<cmd>lua require'luasnip'.jump(-1)<Cr>"
	else
		return t "<S-Tab>"
	end
end

lsp_signature_helper.lua:97: attempt to get length of field 'parameters' (a nil value)

This error message will appear when I enter a method without any parameter.

Reproduce steps:

  1. Type any.MethodWithoutParam(

Lsp Info:

❯ go version
go version go1.16.5 darwin/amd64
❯ gopls version
golang.org/x/tools/gopls v0.7.0
    golang.org/x/tools/[email protected] h1:JQBHW81Gsyim6iDjUwGoPeSpXrSqwen3isPJLfDfaYU=

Env info:

NVIM v0.6.0-dev+1555-gc818d8df3
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/tmp/neovim-20210727-78977-ur3n3z/build/config -I/tmp/neovim-20210727-78977-ur3n3z/src -I/usr/local/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/usr/local/opt/gettext/include -I/tmp/neovim-20210727-78977-ur3n3z/build/src/nvim/auto -I/tmp/neovim-20210727-78977-ur3n3z/build/include
编译者 [email protected]

Features: +acl +iconv +tui
See ":help feature-compile"

     系统 vimrc 文件: "$VIM/sysinit.vim"
         $VIM 预设值: "/usr/local/Cellar/neovim/HEAD-c818d8d/share/nvim"

Run :checkhealth for more info

error on signature window open

Hi 👋🏾 ,

I'm trying this plugin whilst working with dartls and everytime the signature window opens I get a

Error executing vim.schedule lua callback: ...ck/packer/start/lsp_signature.nvim/lua/lsp_signature.lua:175: attempt to perform arithmetic on local 's' (a nil value)

vim.api.nvim_buf_set_extmark(bufnr, ns, 0, s - 1, {end_line = 0, end_col = l, hl_group = hi})

This seems to be coming from this line above, likely because the s value is returning nil when trying to match a the active parameter. Dart has labelled arguments like my_param: value so I don't know if this somehow breaks fetching the active parameter.

Empty lines in signature

Hi there, thanks for the cool plugin!

I see empty lines in my signature for when the signature is only one line:
Screenshot 2021-08-02 at 16 02 05

I have doc_lines=0 and max_height=3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.