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

Make installable via luarocks #26

Open
7 of 8 tasks
FourierTransformer opened this issue Nov 29, 2024 · 5 comments
Open
7 of 8 tasks

Make installable via luarocks #26

FourierTransformer opened this issue Nov 29, 2024 · 5 comments
Labels
Milestone

Comments

@FourierTransformer
Copy link
Collaborator

FourierTransformer commented Nov 29, 2024

With the switch to using the tree-sitter for parsing, the tree-sitter grammar (teal.so) needs to be installed on the user's machine to enable tree-sitter parsing. To enable this, I'm planning to try the following:

  • Create tree-sitter-cli to allow installing tree-sitter CLI via LuaRocks
  • Install tree-sitter-teal's grammar via tree-sitter-teal
  • Try to switch to lua-tree-sitter
    • Includes tree-sitter lib in the source, so we don't have to try and include that as well.
    • Decided to not go this way in the end.
  • Bundle ltreesitter and the tree-sitter lib together.
  • Ideally write unit tests before doing this to ensure all functionality that works with ltreesitter works with lua-tree-sitter. (I think it should)
    • Should be able to load the grammar installed via the neorocks module
  • Update rockspec with all the changes.
    • waiting on new luarocks-build-treesitter-parser for now
  • Test tree-sitter cli without node and just a JSON file
  • See if the LuaRocks module for tree-sitter-cli can be made to work on LuaRocks < 3.10.0

This address the major concern from #25

@FourierTransformer FourierTransformer added this to the 0.1.0 milestone Nov 29, 2024
@FourierTransformer
Copy link
Collaborator Author

I got tree-sitter-cli up and running via LuaRocks and tried installing the teal.so grammar via tree-sitter-teal and it seemed to all install just fine!

I'll probably do some testing on loading parsers/teal.so.

@FourierTransformer
Copy link
Collaborator Author

While the cli can now be installed via LuaRocks, using tree-sitter-teal still requires node to be installed to do the teal.so generation. There are some options in https://github.com/nvim-neorocks/luarocks-build-treesitter-parser that would build from the json file instead, but I'm not sure if that still requires node or has any drawbacks. Might need to investigate further.

@FourierTransformer
Copy link
Collaborator Author

I gave the old "college try" at switching to lua-tree-sitter. It didn't have the same cursor implementation, and I wasn't quite willing to switch everything over to queries or to nodes.

I also attempted to get LuaRocks to build the tree-sitter lib for ltreesitter and install it, but it would require either root privs to install the header/library in the right place or setting environment variables when doing the dependency installation (which would end up being a user action since it can't be done in a rockspec file).

At this point I'm leaning towards bundling ltreesitter and the tree-sitter library together. I got that working in a POC and will continue working that direction in the next few days.

@FourierTransformer
Copy link
Collaborator Author

So it turns out tree-sitter cli can run the build command to build a grammar from a JSON file without node. Node is only needed for the generate command. I'll either see if we can update the tree-sitter-teal package to use the JSON file, or see if they're willing to put in a fallback to use it if Node is not installed, but the JSON file is present.

As far as installing tree-sitter-cli on LuaRocks versions < 3.10.0, it will install just fine with 3.8.0, but seemingly not if it's a LuaRocks tree specified via the commandline. Again, this was fixed in 3.10.0+. so I'm not sure if it's worth chasing.

@FourierTransformer
Copy link
Collaborator Author

Alrighty I have two PRs out there, one of which would allow us to install without Node on the system:

and the other which bundles the tree-sitter library with ltreesitter (and we/the world would not need ltreesitter-ts any longer):

I think when the luarocks-build-treesitter-parser PR is complete with a new version, we can close this issue out! (for ltreesitter, there is currently a workaround in place)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant