scztt / LanguageServer.quark

16 stars 10 forks source link

add HoverProvider #13

Closed karnpapon closed 2 months ago

karnpapon commented 1 year ago

hi,

I add HoverProvider module, with basic functionality. currently support only (documented) Class (retrieved by SCDoc.documents) where the document msg comes from list below

the hover msg consists of parsed SCDocNode

\TITLE
\CATEGORIES
\SUMMARY
\DESCRIPTION
\EXAMPLES

screenshot

Screen Shot 2566-08-11 at 00 00 41

https://github.com/scztt/LanguageServer.quark/assets/22865807/810b2eeb-1d4a-4f49-8fa7-fee2dfddf4ed

related issue

karnpapon commented 1 year ago

sorry for a large chunk of code, but mainly a large chunk was grabbed from official SC class with some modifications (notated by prefix/suffix eg. ForLSP or lsp eg prLinkTargetForInternalLinkForLSP, lspBaseDir so it can be clearly seen).

scztt commented 1 year ago

This is a great addition, thanks for working on this. I see some things I would like to adjust to get this merged, but overall I think the approach is good and it's a fantastic feature. There are also other places in the language server where we have the opportunity to return documentation strings but we are not currently capable of doing do, due to limitations of the built-in renderer - I think overriding / modifying the renderer to support what we need here would help us in other places as well.

I'll try to give this a more thorough review in the next week or two - please forgive any delays, it might take a bit of time!

scztt commented 1 year ago

I believe I already have code to also resolve class method syntax like Class.method elsewhere - connecting this would allow us to render docs for UGen methods as well, which would be huge. Maybe as a follow up PR?

karnpapon commented 1 year ago

Happy to help! 🎉 been dreaming 'bout SuperCollider's LSP for a long time.

I believe I already have code to also resolve class method syntax like Class.method elsewhere - connecting this would allow us to render docs for UGen methods as well, which would be huge. Maybe as a follow up PR?

aha, I saw it!, a LSPDatabase.methodsForClass, right? that'd be nice to render a doc for method as well! anyway, while this is prolly working just fine. For a long-term, maybe we need to find a way to generate AST so we can properly show the docs, I guess. AFAIK, there's a few existing projects like sparkler or tree-sitter-supercollider which already implemented. what do you think?

scztt commented 1 year ago

AFAIK, there's a few existing projects like sparkler or tree-sitter-supercollider which already implemented. what do you think?

This is definitely the next major step - there are actually some frustrating bugs in the current LSP / VSCode plugin that can probably ONLY be fixed with proper access to the AST. I've made a little progress at serializing the SuperCollider AST from Sparkler - and then yes, this is definitely the next step.

karnpapon commented 2 months ago

closing as the development is planned to move to separated quark SCDocMarkdownRenderer