-
Notifications
You must be signed in to change notification settings - Fork 13
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
Show documentation on hover and completion #101
Conversation
I'm concerned that this work will need to be replicated and adapted in the branch search_on_astB, which takes a different approach on parsing and searching. |
Thinking it better, is ok if you do it on main branch, it will serve me as a base anyway, PR very welcomed. |
I could give it a shot at some point, but to be honest my work here is (comparatively) pretty simple - I just traverse top-level nodes in order and attach each doc comment to the node that immediately follows the doc comment. The rest (hover, completion) just reads the attached doc comments from the Indexable structures. So it wouldn't be that much of a loss to completely redo the parsing part for the new branch as needed. That is, the PR could safely land on main, and then the new branch could be rebased by just ignoring my changes on the parsing part (which uses the tree-sitter CST in principle). |
Should be ready to go 😎 Feel free to give it a spin. |
@@ -222,6 +237,9 @@ func (s *Search) BuildCompletionList( | |||
items = append(items, protocol.CompletionItem{ | |||
Label: member.GetName(), | |||
Kind: &member.Kind, | |||
|
|||
// At this moment, struct members cannot receive documentation | |||
Documentation: nil, |
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.
Is this because of how you decide which doc comment you assign to a symbol? (Las doc block parsed belongs to next identified symbol)
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.
In part, yes: I'd have to replicate my code to detect and assign doc comments in the struct parsing function as well in order to accept doc comments inside the struct, i.e. to accept something like
struct Name {
<* doc *>
int a;
}
But also, I didn't do that because it doesn't compile (through c3c
), even though the tree-sitter grammar accepts it.
We could, of course, just copy and paste the struct's own docs to all of its members, but that doesn't feel ideal, at least not at the moment.
Great work! Thank you |
Closes #72
(still WIP)Right now, neither feature works at all in VSCode for some reason. I'm not sure if this is a problem with the extension or with server/client capabilities or something else, but currently, with this PR's changes, the language server is just returningnull
for any hover or completion with documentation in VSCode, meaning items with documentation are just not suggested / have no hover anymore. I'll try to investigate, but for now, all screenshots below use the Zed extension.EDIT: It works in VSCode. Turns out I wasn't telling VSCode to use my build, so it was using an outdated version of the LSP. Whoops :)
In addition to trying to get the VSCode extension to work, I'd like to implement at least the following changes:
@param
docs.Future work
@param value `The requested value.`
)Screenshots
VSCode
Unfortunately, VSCode doesn't support showing documentation directly on completions; however, they can be manually shown with
Ctrl/Cmd + I
:Zed