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

Local compilation of abritrary TS grammars #79

Closed
wants to merge 2 commits into from

Conversation

ethan-leba
Copy link

I wanted to get the ball rolling on abritrary grammar installation, so here's my attempt at it. Let me know if this fits in with your goals for TS langs, and what we can change if not!

This PR adds the following:

  • Splits the compilation logic in tree-sitter-langs-compile from the submodule handling.
  • Allows abritary directories to be specified in tree-sitter-langs-ensure.

This will allow users to be able to use grammars that aren't in TS langs, or compile versions that are more recent than what is in TS langs.

A next step I'd like to see is automatic installation from a git repo instead of cloning manually, but out of scope of this PR.

@ethan-leba ethan-leba force-pushed the local-dir branch 2 times, most recently from 15c93d4 to 2eef589 Compare February 28, 2022 16:39
* Split the compilation logic in `tree-sitter-langs-compile` from the
  submodule handling
Probably unwanted for users locally compiling if there are no errors
@ethan-leba
Copy link
Author

Hi @ubolonton, is there anything I can do to help get this PR through code review?

@siraben
Copy link

siraben commented Mar 25, 2022

Can you give an example of how a user would use this? Suppose I had the grammars compiled in ~/.tree-sitter/bin, how can I get tree-sitter langs to use those more recent ones?

@ethan-leba
Copy link
Author

Can you give an example of how a user would use this?

Sure, I have a snippet like this in my config:

(tree-sitter-langs-ensure 'my-python "~/tree-sitter-python")
(push '(python-mode . my-python) tree-sitter-major-mode-language-alist)

Suppose I had the grammars compiled in ~/.tree-sitter/bin, how can I get tree-sitter langs to use those more recent ones?

If you already have a grammar with the same symbol name, then ensure won't override it -- so you'd have to manually delete the old grammar from your grammar-dir, or give the grammar a different symbol name. It would be great if ensure could detect if the provided grammar is newer and overwrite, but that would be for a future PR. (Not sure exactly if that was what you were asking?)

@siraben
Copy link

siraben commented Mar 25, 2022

Do I have to do tree-sitter-langs-ensure for every language in my grammar-dir?

@ethan-leba
Copy link
Author

The purpose of this PR is to allow grammars to be installed outside of the prepackaged repositories that come with TSL -- the functionality for interacting with those prepackaged grammars is completely unchanged. For custom grammars, you'd need to provide a path of course

@ethan-leba
Copy link
Author

Closing this as it will need to be reworked if/when emacs-tree-sitter/elisp-tree-sitter#220 is merged

@ethan-leba ethan-leba closed this May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants