-
Notifications
You must be signed in to change notification settings - Fork 59
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 go-to-definition on type names in inlay hints #1535
Support go-to-definition on type names in inlay hints #1535
Comments
Interesting idea. Are you working on this right now? If not, perhaps I could have a try :) |
Please feel free, I probably wouldn't get to this for a while :) |
(Apologies for the late reply, I've been little occupied recently. And please don't mind if I'm asking stupid question.) |
It's a good question. Usually, the way this would work is that the client capabilities include an option that indicates whether the client supports the richer format. However, since there is no such option in |
I've hit another problem. IIUC, according to current LSP specification we don't have access to position information for linkable inlay hints. As a result, we may miss user's intended cursor location. For example, for class template with template parameters, we're unable to tell which declaration that user want to inspect. auto f(auto p) { return p; }
struct C {};
void foo() {
auto r = f(std::vector<C>()); // r: std::vector<C>
} We could only provide one location for hint Or we don't provide any clickable links on templates, at least before LSP specification provides cursor information for inlay hints. I've installed rust-analyzer and tried with some generics, and it looks like fine to drop support for inner template parameters. :( |
I think the idea behind having an array of |
So, I guess I'm in a pickle here and I'm looking for a (possible) solution. As previously said, I'm trying to extract type hint to Currently I'm rewriting a visiting logic(which is mostly borrowed from I'm considering a workaround and here is what I've come up with:
Do you have any suggestion? Or could we resort to any other facility that provides more flexibility on type names? Thank you very much in advance :) |
It would be handy if there existed a version of Unfortunately I'm not aware of such a thing and it would probably be somewhat involved to write, so for now we may need to do something more manual. One general thought: the solution doesn't need to be perfect / handle all edge cases. Any solution that provides links to type names in some common cases, is an improvement over the status quo. So, if it makes the task easier to "bail out" when encountering some edge cases and just fall back on printing a particular type component as a string with no links, I think that's fine. Some thoughts on your specific options:
Does the |
Thank you for sharing me ideas and my tentative implementation is using
FWIW, I'm not using |
For the use case of getting a target declaration for a |
@zyn0217 what do you think about making some incremental progress here by starting with a simple initial change, e.g. always producing just one |
Ah, sure! Let me sort out the patch. And sorry for procrastinating... |
Just have sent out a patch of the protocol part to reduce the review workloads. This part looks separated and backward compatible. |
So, I have rewritten most of the logic (the previous implementation was sadly lost :( ), and the drafts are now on this branch. This is going to support links on template-type arguments for hopefully most common cases e.g.
|
Rust-analyzer supports go-to-definition on type names (where the type has a definition in the source) in inlay hints.
LSP 3.17 appears to support this using an optional feature called "interactive and composite labels", where
InlayHint.label
is an array of InlayHintLabelParts (which can have associated locations) rather than a string.It would be nice to add similar support to clangd.
The text was updated successfully, but these errors were encountered: