Languages and Tools:
ray-x / lsp_signature.nvim Goto Github PK
View Code? Open in Web Editor NEWLSP signature hint as you type
License: Apache License 2.0
LSP signature hint as you type
License: Apache License 2.0
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
}
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.
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.
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.
<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.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.
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
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.
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
Title
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.
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).
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
Please see this screenshot:
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:
Similarily, the signature window will hide the main editor itself when the cursor moves to a position that overlaps the signature window:
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 ?
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.
sometimes signature triggers sometimes not
this only happens with tabnine suggestions
see attached video:
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"
} }
} }
}
} }
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
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)
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
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:
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.
The plugin is working fine on the first file opened:
but opening a new file, whether via Telescope or :e, it stops working:
lua vim.lsp.buf.signature_help()
shows the signature on the second file.lua require'lsp_signature'.signature()
does not.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.
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
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.
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
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
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.
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
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
.
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
First off, awesome plugin.
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.
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
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
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
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:
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.
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.
This error message will appear when I enter a method without any parameter.
Reproduce steps:
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
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:
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:
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!
Greetings, I have noticed that this plugin override the default vim.lsp.buf.signature_help()
and now I wonder if there is any way to have virtual text only while I am typing and trigger the floating window without typing (with keystrokes)?
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)
lsp_signature.nvim/lua/lsp_signature.lua
Line 175 in 94eb5ca
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.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"):
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:
How do I use this plugin?
this only occurs when the cursor is on a function argument and the only way to get rid of the floating window is to enter insert mode
I can record a video if it's not clear enough
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.