pltrant / GSL-Editor

GSL Editor extension for Visual Studio Code
GNU General Public License v3.0
1 stars 2 forks source link

Add snippet-assisted hover? #37

Closed abirmingham closed 7 months ago

abirmingham commented 8 months ago

Patrick -

I'm curious if you think this is worth adding. The desire is to add hover tips for commands, which snippets provide a loose approximation of. It has been helpful for me in my research, so I figured it may be useful to others as well. It is toggleable via a setting that defaults to disabled.


image
image
image

The snippets/gsl.json file contains a wealth of information on commands. This commit allows the hover provider to match snippets based on the first word in their prefix, displaying the corresponding snippet descriptions in markdown.

In the case where multiple snippets match, all of the descriptions are shown. One such case is callmatch. A more sophisticated implementation of this commit might resolve to a single snippet, but it may also be desirable to show the user alternative usages. I'm on the fence.

It may also be cleaner to separate the descriptions from the snippets, but that is a much larger diff, and would require dynamically building the snippets from multiple files. If that direction is desired, then it might be worth considering moving gsl.json to a typescript file.

Finally, note that this commit adds resolveJsonModule: true to the tsconfig so that json files are importable in typescript.

abirmingham commented 7 months ago

Closing for now. Will rebase/reopen after #39 is accepted

pltrant commented 7 months ago

For this one, I just wonder if this needs an option to enable/disable. While it does change default behavior, said behavior is also not something most users just do (hover over gsl keywords). I think it may not be worth it to overload the settings with.