-
Notifications
You must be signed in to change notification settings - Fork 10
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
Allow tree-sitter library path to be configurable at runtime #36
Comments
It's possible with Language#load. Alternatively you can modify P.S. You might wanna use kotlin-tree-sitter instead. |
That allows us to control the location of our generated parser (e.g. libtree-sitter-pkl.dylib), but not the tree-sitter library (e.g. libtree-sitter.dylib). As far as I can tell, java-tree-sitter requires that it be installed on the system, or provided via I'm curious: why use kotlin-tree-sitter? Is java-tree-sitter not ready for production use yet? |
That's correct, and likely not something that can easily be fixed since that part is auto-generated via jextract.
Neither of them is quite ready for production use yet. |
From what I can tell, that part is hand-authored: java-tree-sitter/src/test/java/io/github/treesitter/jtreesitter/languages/TreeSitterJava.java Lines 25 to 32 in 53c2d15
Is that not the case? |
That's not where the tree-sitter library is loaded. The generated file is not in the repo. |
Yeah, I get that. But, what I'd like is a way to provide my own |
Again, you can provide the parser libraries via |
That is a current limitation of But even then the question is how to expose this as part of the jtreesitter API? Maybe by using a A safer but more verbose solution would be to have a |
@ObserverOfTime, but since you are tweaking the generated source in the try {
return SymbolLookup.libraryLookup(..., arena);
} catch (IllegalArgumentException e) {
return SymbolLookup.loaderLookup();
} Maybe that would already help for your use case @bioball, because it seems you mainly want to have more control over the path, which would then be possible either using Footnotes
|
Thanks for this library!
We're using java-tree-sitter as part of our CLI, which gets shipped as a jar to our users' machines. We'd like to be able to control exactly where the tree-sitter library lives, to prevent users from having to spawn Java with custom flags (e.g.
-Djava.library.path
).We can do this if java-tree-sitter provided a way to specify the library path programmatically at runtime. Java 22's FFI API allows this (see
java.lang.foreign.SymbolLookup#libraryLookup(java.nio.file.Path, java.lang.foreign.Arena)
).It'd be great if the java-tree-sitter library gave us a way to do this, too. It'd involve changing the logic here from being hard-coded.
For now, we plan on modifying
TreeSitter.java
and re-compiling it during our own build. For reference: apple/pkl-lsp#23The text was updated successfully, but these errors were encountered: