Closed andregpss closed 3 years ago
If you use CoC, then bind coc-codelens-action
and that command will insert the inferred type signature of something at the top-level.
I noticed you can also do :: _
and use coc-codeaction
on the underscore and get the option to fill it in too.
Thanks @eddiemundo
Both solutions worked for me (after some research :-))
On first solution, i added the following code to my vim.rc
file:
vmap <leader>p <Plug>(coc-codelens-action)
nmap <leader>p <Plug>(coc-codelens-action)
On last solution, i added a fake signature like myFunction :: _
, selected the _
character and then pressed \a
.
Two additional questions: is there a command to apply the codelens actions on the selected code? and a command to navigate on the codelens actions?
I don't know of any way of applying code lens actions to a selection, or a way of navigating to them. I guess that could be a feature request...
You can navigate to places with a type signature hole (among other things) using <plug>(coc-diagnostic-next)
and <plug>(coc-diagnostic-prev)
but that's probably not what you're looking for.
The rest of the commands can be found https://github.com/neoclide/coc.nvim/blob/master/doc/coc.txt , or :h cocnvim
if you haven't found that already.
I also set "codeLens.enable": true
on Coc configuration file so it is possible to view code lens suggestions.
Your environment
Which OS do you use: Windows 11 Which lsp-client do you use: Neovim v0.4.3
Question
How can i insert the signature of a function on neovim? When i use 'K' coc command for viewing the function documentation, it shows the function signature. What command should i use to insert that signature on the code? Doing this on Visual Studio Code is easy because it suggests doing it, and i must only click on the proposed signature. But i do not know how to do it on neovim.