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

Directly use tree sitter C API #10286

Open
pascalkuthe opened this issue Apr 8, 2024 · 2 comments
Open

Directly use tree sitter C API #10286

pascalkuthe opened this issue Apr 8, 2024 · 2 comments
Assignees
Labels
A-dependencies Area: Dependency A-tree-sitter Area: Tree-sitter C-enhancement Category: Improvements E-medium Call for participation: Experience needed to fix: Medium / intermediate

Comments

@pascalkuthe
Copy link
Member

pascalkuthe commented Apr 8, 2024

I am not convinced the tree sitter rust crate is worth using . The api is really subotimal. The C API is stable and the rust api is fairly easy to replace since its just bindings.

Things to improve (add more as we find more)

  • Use regex-cursor for queries instead of buffering (we allocate for every query, I found out)

    • using the cursor trait instead of their text provider api (which is only used for regex captures) it would be possible to fix crashed like Helix crashes when editing files with Russian text #7273 which are caused by captures within unicode chars. Regex-cursor fully supports invalid utf8 and won't call rope.slice but manage the iteration itself. I could remiplement this osmewhat with the current api but it would be reimplementing some nont quite tirival logic. I don't want to do that for code I don't expect to keep
  • fix undefined behaviour in the query api

  • remvoe code we don't neeed to speedup builds

we can bundle this crate together with our highlighter so other people don't need to vendor our code. I want to seperate our TS code from config and other code into a seperate crate anyway. They really shouldn't be coupled

@pascalkuthe pascalkuthe added the C-enhancement Category: Improvements label Apr 8, 2024
@pascalkuthe pascalkuthe self-assigned this Apr 8, 2024
@pascalkuthe pascalkuthe added A-dependencies Area: Dependency E-medium Call for participation: Experience needed to fix: Medium / intermediate A-tree-sitter Area: Tree-sitter labels Apr 8, 2024
@pppKin
Copy link
Contributor

pppKin commented Apr 9, 2024

I did some quick search and it seems that zed and lapce still use the tree-sitter crate. Of course that doesn't mean we should not explore other options. Maybe we can make something that'll benefit everyone?

@pascalkuthe
Copy link
Member Author

pascalkuthe commented Apr 9, 2024

That what I meant with

I want to seperate our TS code from config and other code into a seperate crate anyway.

We want to publish the highlighter on crates.io which would cover that. I don't think zed would want to use that (the guy that maintains tree sitter works on zed) but Laplace already uses a vendored copy of our highlighter (which is pretty old and is missing lots of bug fixes and performance improvements I amde since)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-dependencies Area: Dependency A-tree-sitter Area: Tree-sitter C-enhancement Category: Improvements E-medium Call for participation: Experience needed to fix: Medium / intermediate
Projects
None yet
Development

No branches or pull requests

2 participants