lsp_signature.nvim icon indicating copy to clipboard operation
lsp_signature.nvim copied to clipboard

Floating window disappearing with snippets

Open sophacles opened this issue 4 years ago • 7 comments

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

sophacles avatar Jul 27 '21 03:07 sophacles

I saw that at the start of the video, it was showing the LSP signature. For me, it only shows it if I disable lsp snippets in clangd. Would you mind sharing your lspconfig and compe configurations?

ancientstraits avatar Aug 05 '21 02:08 ancientstraits

It is kind of expected. The reason is you are in selection mode instead of insert mode when you enabled snippets I added some supports for the selection mode. But it will not the same as what I did for insert mode. Vim does not have an event for SelectionModeEnter.

ray-x avatar Aug 05 '21 06:08 ray-x

It is kind of expected. The reason is you are in selection mode instead of insert mode when you enabled snippets I added some supports for the selection mode. But it will not the same as what I did for insert mode. Vim does not have an event for SelectionModeEnter.

That makes sense yes. I have this same issue with my snippets, sometimes lsp_signature will recognize them and often not. It seems to work more often with the snippets in C files than in Rust files too which is an odd observation.

Are you keeping this issue open to wait for an neovim update to Selection mode or do you think there would be a decent work-around for this?

Shadorain avatar Sep 10 '21 17:09 Shadorain

I've ran into the same problem. I'm using vsinp as snipping engine. And popup with signature is not show when I'm in select mode inside of snippet.

It is not an ideal solution, but I added a call of vim.lsp.buf.signature_help to vsnip keymapings. This way I'm able to see popup with signature after the first jump to snipet template.

" Jump forward or backward
imap <expr> <Tab>   vsnip#jumpable(1)   ? '<Plug>(vsnip-jump-next)<cmd>lua vim.lsp.buf.signature_help()<cr>' : '<Tab>'
smap <expr> <Tab>   vsnip#jumpable(1)   ? '<Plug>(vsnip-jump-next)<cmd>lua vim.lsp.buf.signature_help()<cr>' : '<Tab>'
imap <expr> <S-Tab> vsnip#jumpable(-1)  ? '<Plug>(vsnip-jump-prev)<cmd>lua vim.lsp.buf.signature_help()<cr>' : '<S-Tab>'
smap <expr> <S-Tab> vsnip#jumpable(-1)  ? '<Plug>(vsnip-jump-prev)<cmd>lua vim.lsp.buf.signature_help()<cr>' : '<S-Tab>'

antosha417 avatar Nov 09 '21 16:11 antosha417

Thanks @antosha417 . I am not using vsnip. But this seems to be something I should add into README.

ray-x avatar Nov 09 '21 21:11 ray-x

Just to be clear, signature will be shown only after you press <Tab> or <S-Tab> to navigate to another snippet placeholder.

So the very first placeholder which vsnip selects still going to be without signature while in selection mode.

antosha417 avatar Nov 09 '21 22:11 antosha417

As the signature only show in insert mode. I can add new mode. But it may mess up the logic. It is heavily dependent on the InsertLeave event currently. The workaround is using the keymaps mentioned in earlier post

I've ran into the same problem. I'm using vsinp as snipping engine. And popup with signature is not show when I'm in select mode inside of snippet.

It is not an ideal solution, but I added a call of vim.lsp.buf.signature_help to vsnip keymapings. This way I'm able to see popup with signature after the first jump to snipet template.

" Jump forward or backward
imap <expr> <Tab>   vsnip#jumpable(1)   ? '<Plug>(vsnip-jump-next)<cmd>lua vim.lsp.buf.signature_help()<cr>' : '<Tab>'
smap <expr> <Tab>   vsnip#jumpable(1)   ? '<Plug>(vsnip-jump-next)<cmd>lua vim.lsp.buf.signature_help()<cr>' : '<Tab>'
imap <expr> <S-Tab> vsnip#jumpable(-1)  ? '<Plug>(vsnip-jump-prev)<cmd>lua vim.lsp.buf.signature_help()<cr>' : '<S-Tab>'
smap <expr> <S-Tab> vsnip#jumpable(-1)  ? '<Plug>(vsnip-jump-prev)<cmd>lua vim.lsp.buf.signature_help()<cr>' : '<S-Tab>'

ray-x avatar Jul 13 '22 02:07 ray-x