-
Notifications
You must be signed in to change notification settings - Fork 118
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
Add client support for inlay hints #168
Conversation
Corresponding server-side patch for reference: https://reviews.llvm.org/D98748. There's some discussion there about the choices made about the protocol as well. |
2a5d5f8
to
fc84055
Compare
fc84055
to
542f0cd
Compare
Sam, perhaps you would be interested in reviewing the client-side patch as well? |
542f0cd
to
c98bd27
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely. Looks like there are three paths though:
- a client impl based on decorations, as in rust-analyzer (current state in this patch)
- a client impl based on vscode inlay hints (only works in insiders)
- adding this to lsp + vscode-languageclient instead (we've been invited to do this in Feature: Inlay Hints microsoft/language-server-protocol#956)
We can take multiple of these paths, though of course that has costs.
It looks like the LSP bit may not happen soon unless we push on it, and we could speed it up a lot.
Do you want to stick with approach 1 for this patch, or try 2?
Do you want to push on LSP standardization, or should I, or should we wait and see?
I'm not fully clear on how Insiders works. Are things that are in Insiders now going to be in the next vscode release, or some unspecified (possibly distant) future one? In the first case (which, IIUC, would mean the API would arrive to vscode stable within the next ~4 weeks), I think it makes sense to go straight for (2). In the second case, my preference would be to stick to (1) so that we can make the feature available to users without too much delay.
I'm open to this, but perhaps as a follow-up to whichever of the above options we choose? |
I'd suggest sticking with option 1 right now. Some features stay in insiders for a long time before they are merged into the main branch. |
Yeah, there's plenty of value in us being able to use this regularly now. At least it'll motivate & inform work on the server impl and LSP effort. There's value in getting it to "real" users, but also costs: a custom protocol in client + released server (clangd 13?) needs to be supported for a long time (like semantic highlighting). Some costs start early: as soon as we add these options to the vscode plugin, they're going to cause confusion (for users whose clangd doesn't have the feature). And there are mostly no benefits until the next release. So:
I don't see a good way to make the settings conditional on clangd version. What do you think about hiding the server capability behind a We'd lose the ability to toggle categories independently, but I'm not sure that's terribly important right now. WDYT? |
I think that would be fine for now. (Presumably, we could bring back the client-side settings once clangd 13 is released?) Your comment made me ponder something which is perhaps off-topic for this bug, but here goes: if most users are using the latest official clangd release, and clangd releases are tied to LLVM releases which are every 6 months, does that make the velocity at which new features are rolled out to clangd users a bit on the slow side (compared to, say, other components of the tooling ecosystem like VSCode which get a release every month)? |
We could, there's a long-term cost to that (c.f. confusion about the semantic highlighting setting that doesn't control standard semantic highlighting)... So options would include changing the server protocol to match the standard or likely standard before the 13 release, making this a public non-standard feature and maintaining it for a few release cycles, or leaving the feature flag off by default for 13 and hope to get it standardized by 14. I really hope the first option looks feasible by then...
My response got too long and is obviously a bit offtopic here. I dumped my thoughts into the wiki: https://github.com/clangd/clangd/wiki/Release-cycle. That's no good for discussion though - I've been meaning to try out https://github.com/clangd/clangd/discussions, feel free to start a thread there if we should get further into this... |
This is a feature that I anticipated to see for some time now, is this useable in its current state (I'd like to test / use it)? |
Good point.
One thought is: if vscode support for inlay hints hits stable in time for 13, but the protocol piece isn't there yet, we could use vscode's setting for the feature (rather than introducing our own setting), and have the client and server negotiate which impl. they use via capabilities? |
Thanks for the detailed thoughts. I don't have much to add so I'll risk your ire by making two minor comments here:
No easy answers, I suppose. |
It is if you're willing to use a nightly or snapshot build of clangd, and apply this client-side PR locally. |
AIUI we have a plan at least for the near term, and this is waiting on updates from @HighCommander4 (earlier review comments & ripping out settings for now). Nathan please let me know if I'm mistaken!
Yes, this sounds good!
|
c07d3bd
to
f4d6f05
Compare
I've addressed the review comments so far, with this server-side patch adding the command-line flag. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Possible this may require type tweaks after #178 (strict TS)
(I'm not good at github, but I think you have permissions to commit here right?!)
src/inlay-hints.ts
Outdated
conv: vscodelc.Protocol2CodeConverter): vscode.DecorationOptions; | ||
} | ||
|
||
const beforeHintStyle = createHintStyle('before'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather set up a map here from HintType -> HintStyle.
Otherwise we're adding afterHintStyle which is currently unused, and setting up an expectation that the only difference between kinds will be before vs after (I think we should do colors too, later)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went with a parameterHintStyle
variable for now, to keep things simple.
That's clearly a real bug and needs to be tracked and fixed. Is it reproducible/minimizable? However deltas won't fix this, neither delta-encoding nor requests. They may be good ideas, but we don't need to have them in the first patch. Reasoning: This feature requires exactly two things of clients:
Adding delta requests and/or encoding obviously doesn't fix #1, because we're not going to have fresh data for every keystroke. Delta-encoding the inlay sequence, and supporting a /delta request variant, may help with efficiency in various ways, but optimizing and compressing incorrect data is just going to lead to confusion, so let's wait :-) |
Honestly from what I can see things that cause it to get confused are basically any edit to a file I seem to make. My best guess is the hints are being generated from the previous version of the file, rather than the current version. Hopefully this shows how they are one version behind Final edit, that seems to be the case. The inlayHints request is indeed sent before the didChange request.
|
f4d6f05
to
4f04c20
Compare
4f04c20
to
8672c2f
Compare
62aed15
to
9a99f5f
Compare
Turns out this was a bug I introduced while porting the rust-analyzer code to clangd. A close comparison of the two showed that I was registering the feature's Should be fixed now. |
No description provided.