vscode-forester icon indicating copy to clipboard operation
vscode-forester copied to clipboard

Add Hover, Go to definition, Search by title, and user-defined patterns for triggering completion

Open utensil opened this issue 1 year ago • 2 comments

These features are the ones I desired for a long time. Today I finally sit down to implement a prototype for them.

The code still needs a bit clean up, but it's working locally. The development branch is https://github.com/utensil/vscode-forester/tree/dev . There is a long holiday coming, so I might not be able to polish it for a PR very soon, but let's log the issue here.

Some screenshots for a preview:

Hover

image

Implemented as a HoverProvider.

Go to definition

image

Implemented as a DefinitionProvider.

There is a caveat that although I got the right range for matching, but when cmd/ctrl+hover, it shows an underline only for the current word range matching /\w+/ not including digits and - etc. that often appear in tree ids. The screenshot shows such issue.

Search by title

Implemented as a WorkspaceSymbolProvider.

One could bind cmd/ctrl+K to it so that it works the same as on forester web page.

image

One caveat is that it's not fuzzy search yet.

user-defined patterns for triggering completion

image

I've defined a lot of macros such as for references and definitions, they would need the same completion as the official macros. The current code hard-coded some of my patterns in it, but it could be some user regex configuration, ideally, one can specify which taxon is the pattern for.

There is a bug I'm still trying to figure out why: \citet{fig. 1}{ can not match (but the same one matches in dev console!)

utensil avatar Sep 27 '24 13:09 utensil

Nice! I didn't do this because there's no way to reuse the range computed with the textmate grammar in hover range selection. We really want to use that because it takes care of escapes and comments etc. So \\ref{} wouldn't trigger anything. My plan was to use a library like this to re-compute the textmate ranges because vscode doesn't want to provide this in the API. Or we could just use treesitter and rewrite the entire thing.

Trebor-Huang avatar Sep 27 '24 14:09 Trebor-Huang

The benefit of using treesitter would be that both our plugins could profit from treesitter queries.

kentookura avatar Oct 03 '24 21:10 kentookura