kakoune-lsp / kakoune-lsp

Kakoune Language Server Protocol Client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gopls inlay hints

mlhhqh opened this issue · comments

I am using kakoune with kak-lsp and inlay hints do work under rust (rust-analyzer).
Using gopls though I get no inlay hints (even after explicitly enabling them multiple times).
Looking at the debug buffer I see no inlayHints requests anywhere for gopls.

On Emacs you need to set this additional config:

(add-to-list 'eglot-server-programs '((go-mode go-ts-mode) .
    ("gopls" :initializationOptions
      (:hints (:parameterNames t
               :rangeVariableTypes t
               :functionTypeParameters t
               :assignVariableTypes t
               :compositeLiteralFields t
               :compositeLiteralTypes t
               :constantValues t)))))

So maybe there is additional config required for gopls?

right, they need to be turned on as described here

A working config is

[language_server.gopls]
filetypes = ["go"]
roots = ["Gopkg.toml", "go.mod", ".git", ".hg"]
command = "gopls"
[language_server.gopls.settings.gopls]
# See https://github.com/golang/tools/blob/master/gopls/doc/settings.md
# "build.buildFlags" = []
hints.assignVariableTypes = true
hints.compositeLiteralFields = true
hints.compositeLiteralTypes = true
hints.constantValues = true
hints.functionTypeParameters = true
hints.parameterNames = true
hints.rangeVariableTypes = true
"ui.completion.usePlaceholders" = true

which I just made the default. Thanks for reporting!

please report back if there are some specific inlay hints that the average users does not want to enable, so we can update the default config - I don't really use Go these days

Built kak-lsp from git and works exactly as expected. Thanks!