Open septemhill opened 12 months ago
Hello! Where would we show these hints?
Moving this to the compiler repo as this is a language server feature rather than a vscode feature.
Edit: it won't let me move it from my phone, I'll have to do this later
Hi @lpil, I'm not pretty sure which repo should I put this issue, thanks for ur help.
Currently, as I knew, there're two hints would be shown on VSCode
Here I used Go
as example
The L154 and L155 are belong to first type (Variable assignment). We can see the variable user
with type []*User
and err
with type error
.
And L156, L157, L159 are belong to second type (Function call with argument). So we can also see parameters query
and arg...
with corresponding values "name = ? AND age < ?"
and "Septem", 10
and so on.
Are there any other places we might want them? The language server can put them anywhere.
Seeing as Gleam has labels does it still make sense to show the argument names in function calls?
We would also need to decide what hints we would have on by default. We don't want to introduce too much noise, and we want the code to be as readable even when not using the language server.
I'd like this a lot IF it is something I can toggle globbally/per project via vscode settings.
Are there any other places we might want them? The language server can put them anywhere.
This proposal is all I can think of now.
Seeing as Gleam has labels does it still make sense to show the argument names in function calls?
Agree. For this case, I think we could ignore. But another question is, if the function without named arguments how do we display, may be just show the type ?
I understand we don't want to make whole UI with too much noise. So here I provide Go inlay-hint features in LSP settings.
There're many hints in Go and we could decide which hint would be enabled in a language rather than a project.
But the config could be created under .vscode/setting
in different projects.
Thanks.
Fab! Ok so the next steps are to determine how to send these hints via the language server protocol, and to turn them on and off with the language server protocol, and to design some hints to support.
Are there any other places we might want them? The language server can put them anywhere.
This proposal is all I can think of now.
Seeing as Gleam has labels does it still make sense to show the argument names in function calls?
Agree. For this case, I think we could ignore. But another question is, if the function without named arguments how do we display, may be just show the type ?
I understand we don't want to make whole UI with too much noise. So here I provide Go inlay-hint features in LSP settings. There're many hints in Go and we could decide which hint would be enabled in a language rather than a project. But the config could be created under
.vscode/setting
in different projects.
Thanks.
would we want the comments around it, i think the rust lsp skips those. just grey and some opacity, and maybe (not sure) you cannot select them ever with the cursor
We don't have an inline comment syntax so we couldn't wrap them like Go does.
I'm currently working on this https://github.com/jamesbirtles/gleam/tree/feat/inlay-hints along with some code actions to add in the types when clicked
https://github.com/gleam-lang/gleam/assets/3743418/e019bc91-2d5e-4db5-a8c9-d2a8fc467f3a
https://github.com/gleam-lang/gleam/assets/3743418/b8a83b38-18ab-449a-9f8b-969c5e2ebae7
Currently working for top level functions and constants, its a little trickier for things inside functions like calls and variable assignment as I don't think theres a generic visitor/walker(?) to get at all expressions without manually recursing through them
Very exciting!
Let's start with the MVP feature-set and we can add more over time. That way it is easier to review and merge.
Also another thing inlay hints could be used for is inferred types for arguments and return-types, since those might not be obvious in certain cases
For sure!!
I'm currently working on this https://github.com/jamesbirtles/gleam/tree/feat/inlay-hints along with some code actions to add in the types when clicked
CleanShot.2023-11-02.at.20.59.20.mp4 CleanShot.2023-11-02.at.21.44.31.mp4 Currently working for top level functions and constants, its a little trickier for things inside functions like calls and variable assignment as I don't think theres a generic visitor/walker(?) to get at all expressions without manually recursing through them
I get a panic when using your feat/inlay-hints: /home/shane/dev/rust/gleam/compiler-core/src/language_server/server.rs:565 Unable to parse configuration: invalid type: null, expected struct Configuration
Hi gleam team,
I would like to suggest support
inlay hint
feature in vscode-gleam. This feature be supported in most of popular programming languages (e.g. Rust, Go, etc.) It would save us much time to hover over the variables/functions to check the types.Looking forward to hearing from your reply !