[gopls] Suggest function argument type

Hello,

I can’t seem to get Neovim with gopls to suggest a type’s template like vscode does.

For example, if you open a function parenthesis and immediately ask for suggestion/completion in vscode it ill template out a construction of the type for that argument.

For example lets say we have a function func X(a []int. When I go and write X( and ask for a suggestion vscode will output “int{}” giving you a nice template to construct the array.

Can neovim and gopls be configured to do this as well? I’m failing to find out how.

In my lspconfig on-attach function, I use the following:

(vim.keymap.set :n :<C-Space> vim.lsp.buf.signature_help {:desc "Signature help"})

Or the lua equivalent:

vim.keymap.set("n", "<C-Space", vim.lsp.buf.signature_help, { desc="Signature hint"})

Which then shows the following when I press ctrl+space after opening a function:

image

Might need some tweaks though to show the type of each property but it’s at least a good jumping off point to get there.