Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Using tree-sitter-highlight library from upstream #156

Closed
jspawar opened this issue Jul 15, 2021 · 1 comment
Closed

Using tree-sitter-highlight library from upstream #156

jspawar opened this issue Jul 15, 2021 · 1 comment
Labels
question Not a bug report or feature request

Comments

@jspawar
Copy link

jspawar commented Jul 15, 2021

Hello, new to a lot of this, so apologies in advance for any misunderstandings of course. Was poking around and from what I appear to see is that the highlighting provided by this module seems to be done a bit "manually" by something like querying the tree-sitter "tree" for a buffer and using that to highlight?

Was curious then why tree-sitter-highlight wasn't used instead? (Assuming it wasn't used because it's not in the Cargo.toml)

I also tried toying around with that upstream library and seems plenty sufficient (so far as I understand it is what's actually intended to back highlighting in the bigger consumers of tree-sitter such as Atom or GitHub itself). Gave it some input files and it correctly provided region ranges along with the correct type of node/token.

Wonder if it could also mitigate some issues folks are having such as #94 and #76? The output I received was able to correctly identify local variables, so seems like it should?

@shackra shackra added the question Not a bug report or feature request label Jul 16, 2021
@ubolonton
Copy link
Collaborator

Was curious then why tree-sitter-highlight wasn't used instead? (Assuming it wasn't used because it's not in the Cargo.toml)

That library is designed for the use case of highlighting static sources, without handling edits. The underlying mechanism is the same: querying the syntax tree using a Lisp-like query language.

I also tried toying around with that upstream library and seems plenty sufficient (so far as I understand it is what's actually intended to back highlighting in the bigger consumers of tree-sitter such as Atom or GitHub itself).

GitHub's use case is the static highlighting mentioned above.
Atom doesn't use that library. Its highlighting mechanism is more ad-hoc, which predates the Lisp-like query language, and hasn't been updated for a long time AFAICT.

Gave it some input files and it correctly provided region ranges along with the correct type of node/token.

Wonder if it could also mitigate some issues folks are having such as #94 and #76? The output I received was able to correctly identify local variables, so seems like it should?

The hard part is handling the local predicates in an efficient manner, in the presence of (dynamic) text edits. That library only handles the static case, so it won't help. The same applies to other contextual concerns, like injected language blocks.

@emacs-tree-sitter emacs-tree-sitter locked and limited conversation to collaborators Aug 1, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
question Not a bug report or feature request
Projects
None yet
Development

No branches or pull requests

3 participants