matze / tree-painter

tree-sitter based syntax highlighting HTML rendering
MIT License
17 stars 3 forks source link

Thoughts on fixing submodules #3

Open lf- opened 2 years ago

lf- commented 2 years ago

It's very difficult to depend on tree-painter except by path, since cargo submodule support is awful, and it takes multiple minutes to full-depth clone everything on an 800mbit connection: https://github.com/rust-lang/cargo/issues/7987 https://github.com/rust-lang/cargo/issues/1171. This is a huge usability issue, unfortunately. Also, the rust bindings of any given tree-sitter parser are not necessarily maintained or consistent.

I think that Helix has fairly exhaustively explored the other ways to achieve it: it does all three of the following:

In sum, it looks like this will require some build engineering work, but it seems necessary to build it with Nix or really, depend on it in any scenario.

matze commented 1 year ago

For wastebin, I added tree-painter as yet another submodule. It's not nice at all from a setup point of view but it avoids the horrendous clone times.

P.S.: I saw your concerns regarding performance. Not sure what's wrong but when comparing syntect with tree-sitter, highlighting becomes an order of magnitude faster in release mode. Highlighting option.rs takes ~160ms with syntect but merely 13ms with tree-sitter.

kaj commented 1 year ago

This does not seem to be a problem when depending on tree-painter through a crates.io release (currently 0.0.0), but it does seem to be a problem when trying to get newer code by git dependency?

# No problem
tree-painter = "0.0.0"

# Problem?
tree-painter = { git = "https://github.com/matze/tree-painter" }

Is that so? Or is it just that there were fewer modules in the 0.0.0 release?

matze commented 1 year ago

Or is it just that there were fewer modules in the 0.0.0 release?

Kind of. The thing is, if I want to make a crates.io release all dependencies must be on crates.io as well and of course have matching tree-sitter version requirements. Unfortunate reality is however that most grammars are not very keen on regular updates and some do not even provide Rust "bindings" even though they could. Hence the submodules which I could update on my own but then prevent me from making proper crates.io releases.

kaj commented 1 year ago

Hm. Maybe there could be a tree-sitter-parser-collection crate that does all the required magic, that various crate that uses the parsers (like this one) could depend on?

lf- commented 1 year ago

that's something I'm working on slowly with lf-/gridlock, actually.

matze commented 1 year ago

If that's a repo, it is inaccessible :-(

lf- commented 1 year ago

@matze apologies for that, it is an unfinished side project and I was super busy and didn't get around to finishing it enough to make it usable-ish. It's now public: https://github.com/lf-/gridlock