-
-
Notifications
You must be signed in to change notification settings - Fork 169
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 "Open Type Documentation" context menu option #405
Add "Open Type Documentation" context menu option #405
Conversation
General question: isn't it what Go to Declaration context menu option already does via LSP? If I saw
|
I have only seen
Very good point. This current implementation for types was very straightforward (once your PR helped me understand how the docs are triggered, so thanks again). Implementing this for methods and properties will be harder[1] because I don't fully understand the language server yet, and it's a very difficult system to just 'poke around' in. I think the best course of action for now is to pick a narrower name, like [1]: I can expand on why I think this is, if anybody is interested. |
I went ahead and renamed it I also learned how to create custom This feature could be used to control v3 or v4 specific menu options or views, if we end up with any of those. |
If you don't mind sharing, I'd be interested. LSP is something I'd like to familiarize myself with better.
I didn't know you could that, sounds great! |
dbbfdd7
to
52c9e8e
Compare
Ctrl+clicking on a symbol in Godot's internal script editor opens the documentation. Also in VSCode, when ctrl+clicking on a symbol from a JS library that has typings, it opens the corresponding I don't know how the ctrl+click logic is implemented on the LSP/extension-level though, or if opening this documentation page is even possible for this case. |
Open Symbol Documentation
context menu optionOpen Type Documentation
context menu option
Thanks for the alternative perspective. Most of my experience is in C, where a Declaration and a Definition are both actual language features that are explicitly inside the source code.
It's definitely possible to register our own "provider" for this behavior, but it's yet another subsystem I haven't learned how to use yet. Maybe in the future I'll make the |
Okay, so it looks like opening the docs involves actively communicating with the language server by sending a message containing the This is why it'll work for type names, but methods and variables are more complicated. If we want to look up the documentation for a variable, we'll first have to figure out what type the variable is, then ask for the docs for that type. A method is usually called from an instance of a class, IE on a variable, so for a method we have to identify the associated variable, then look up the variable, then pull the docs. I would like to assume that the language server is actually capable of this, but I don't yet know the magic words to get it to return this information. I just did a quick test of watching the messages used to populate the hover popups, and unfortunately, when you hover over a variable, the language server responds with @tomwyr if you wanted to investigate this together sometime, I'd be down. My discord is in my github profile, if you use that. Edit: Found issues #205 and godotengine/godot#43188 that are relevant to future development of this feature. |
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.
This pull request uses spaces for indentation, but it seems that the rest of the files use tabs for indentation. This should be harmonized before the PR is merged.
Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro>
I have no idea how that happened... I don't think I changed any vscode settings and I'm pretty sure my previous stuff had the correct indentation. I'm gonna see if I can configure prettier on a precommit hook or something, and maybe write a test for the CI so the machine will yell at me right away. Thanks for catching my use of |
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.
Thanks!
Open Type Documentation
context menu option
This adds an editor context menu option to open the symbol docs for the selected word, or the word under the cursor.
Open questions:
Open Symbol Documentation
the right name?Code_62VWSKM8sC.mp4
Special thanks to @tomwyr, since this builds directly on his PR that fixes the doc viewer behavior.