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 for go-mode / gopls #3618

Closed
asg0451 opened this issue Jul 8, 2022 · 10 comments
Closed

Support for inlay hints for go-mode / gopls #3618

asg0451 opened this issue Jul 8, 2022 · 10 comments
Assignees

Comments

@asg0451
Copy link

asg0451 commented Jul 8, 2022

Inlay hints just landed in gopls 0.9, but don't seem to work out of the box with lsp-mode. Ideally they would work similarly to rust-analyzer's inlays.

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

@jakejx
Copy link
Contributor

jakejx commented Aug 29, 2022

hi @asg0451 , just wanted to share that I started some work to implement inlay hints and I have tested them with gopls. You can try it out at my branch: https://github.com/jakejx/lsp-mode/tree/inlay-hints. It's still very beta, so please let me know if you encounter any weird issues. It should "just work" when you start lsp-mode.

@yyoncho
Copy link
Member

yyoncho commented Aug 29, 2022

@jakejx you know that there is already implementation rust-analyzer and clangd, right?

@jakejx
Copy link
Contributor

jakejx commented Aug 30, 2022

@yyoncho oh are those using the official spec? If so I was not aware.

@yyoncho
Copy link
Member

yyoncho commented Aug 30, 2022

I think that they were using the same structure but a different method name (or something like that). I am failing to find the issue in which we discussed the unification of the implementations.

@jakejx
Copy link
Contributor

jakejx commented Aug 30, 2022

I see. I took quite abit of inspiration from the lap-javascript implementation for my changes. Let me know how I can help to get inlay hints into LSP mode.

One thing I have noticed already is gopls returns an empty object for the inlay hint capability which is treated as nil in elisp.

@yyoncho
Copy link
Member

yyoncho commented Aug 30, 2022

One thing I have noticed already is gopls returns an empty object for the inlay hint capability which is treated as nil in elisp.

This is what we do for now until we have core support for fixing this: https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-mode.el#L7403

@jakejx
Copy link
Contributor

jakejx commented Aug 30, 2022

I see. Let me take a look at that and the current rust-analzyer implementation and see which useful parts I can bring over.

@geza-herman
Copy link
Contributor

I tried @jakejx 's branch (I applied the "Initial inlay hint support for gopls" commit to current lsp-mode), and it works with clangd. The only modification I had to make is to change a line in lsp-inlay-hints--update-overlay:

-                     ('string label)
+                     ((cl-type string) label)

(I'm a lisp noob, not sure this is a correct modification, but it works)

@yyoncho you said in your first comment here that lsp-mode already has an implementation for clangd, but I think that's not the case (at least I cannot find it). So jakejx's work is valuable, because it adds inlay hint support not just for go, but for C/C++ as well (and supposedly for all language servers which support the inlay hint protocol).

@yyoncho
Copy link
Member

yyoncho commented Feb 23, 2023

@geza-herman I will handle this report

@yyoncho yyoncho self-assigned this Feb 23, 2023
@yyoncho
Copy link
Member

yyoncho commented Feb 23, 2023

Draft PR at #3970

I have tested only with javascript/rust analyzer but it should fine.

@yyoncho yyoncho closed this as completed Apr 22, 2023
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

4 participants