Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for inlay hints in go files #4357

Open
Gavinok opened this issue Mar 5, 2024 · 1 comment
Open

Support for inlay hints in go files #4357

Gavinok opened this issue Mar 5, 2024 · 1 comment

Comments

@Gavinok
Copy link

Gavinok commented Mar 5, 2024

I tried implementing this myself but had no luck adding this to the lsp-mode code base but from what I can see from lsp-go.el it's simply adding a ("gopls.hints" lsp-go-hints) to lsp-register-custom-settings and a definition similar to:

(defcustom lsp-go-hints `(assignVariableTypes t
                                              compositeLiteralFields t
                                              compositeLiteralTypes t
                                              constantValues t
                                              functionTypeParameters t
                                              parameterNames t
                                              rangeVariableTypes t)
                                              ""
  :type '(alist :key-type (symbol :tag "hint type") :value-type (boolean :tag "value"))
  :group 'lsp-go
  :risky t
  :package-version '(lsp-mode "6.2"))

https://github.com/golang/tools/blob/master/gopls/doc/settings.md#inlayhint

Describes the functionality however no matter what I have tried I still get this error after enabling lsp-inlay-hints-mode

Error running timer ‘lsp--on-idle’: (error "The connected server(s) does not support method textDocument/inlayHint.
To find out what capabilities support your server use ‘M-x lsp-describe-session’
and expand the capabilities section")
@Souheab
Copy link

Souheab commented Mar 9, 2024

This is what I use in my init.el to get inlay hints in go files, maybe it could be of help to what you're trying to do

   (lsp-register-custom-settings
    '(("gopls.hints" ((assignVariableTypes . t)
                      (compositeLiteralFields . t)
                      (compositeLiteralTypes . t)
                      (constantValues . t)
                      (functionTypeParameters . t)
                      (parameterNames . t)
                      (rangeVariableTypes . t)))))

Also fyi currently there is a bug in lsp-mode where if you have this set in your early-init.el

  (setenv "LSP_USE_PLISTS" "true")
  (setq lsp-use-plists t)

then despite registering the settings with lsp-register-custom-settings you will still get the error message that inlay hints are not supported by the connected server (See #4325). So that also might possibly be the cause of the error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants