Skip to content
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 Hover, Go to definition, Search by title, and user-defined patterns for triggering completion #9

Open
utensil opened this issue Sep 27, 2024 · 2 comments

Comments

@utensil
Copy link

utensil commented Sep 27, 2024

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!)

@Trebor-Huang
Copy link
Owner

Trebor-Huang commented Sep 27, 2024

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.

@kentookura
Copy link

kentookura commented Oct 3, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants