AndroidIDEOfficial / android-tree-sitter

Tree Sitter for Android
GNU Lesser General Public License v2.1
51 stars 17 forks source link

How are the languages published to maven central? #20

Closed AntonPieper closed 1 year ago

AntonPieper commented 1 year ago

More generally, how can I add another Tree-sitter grammar? Specifically I want to use GLSL. I see that you have forks of tree-sitter-java and the like, but there does not seem to be the source of the maven module. So how can I add my own grammar? Ideally without using maven

itsaky commented 1 year ago

The Gradle modules for the grammars are almost identical (just some minor differences in CMakeLists and the Java binding class). Therefore,

The generated modules are located in rootDir/grammar-modules directory.

To add a new grammar :

  1. Add the grammar source to the grammars directory. You can add a submodule with the following command :
    git submodule add <remote_url> grammars/<language_name>
  2. The language_name must be the simple name of the language (i.e without the tree-sitter- prefix). This name is used to generate the shared library and the Gradle module. For example, if the language_name is abc :
    • Module tree-sitter-abc will be generated.
    • The name of the generated shared library will be libtree-sitter-abc.so.
  3. Update the grammars.json file to include the newly added grammar.
  4. Sync the project to generate the module for the grammar.

Also, make sure you read the prerequisites for building the project.

itsaky commented 1 year ago

The README has been updated to include information about using/loading external grammars i.e. grammars that are not published to Maven Central along with this project.