feat: move tree-sitter configuration to dedicated file#3700
feat: move tree-sitter configuration to dedicated file#3700amaanq merged 8 commits intotree-sitter:masterfrom
Conversation
f521aa8 to
6232f6b
Compare
There was a problem hiding this comment.
This is what I had in mind:
- If
package.jsonexists, the configuration should be moved totree-sitter.json(with a warning) - If
tree-sitter.json(or another file specified via-c/--config) exists, it should read it- If any of the required fields are missing, it should exit with an error
- If neither file exists, it should prompt the user for the basic info (with defaults):
Parser name: foo (from cwd) CamelCase parser name: Foo Description: Foo grammar for tree-sitter Repository URL: https://github.com/tree-sitter/tree-sitter-foo TextMate Scope: source.foo File types (space-separated): .foo Version: 0.1.0 License: MIT Author name: Author email: Author URL:
d2aebf1 to
6caec50
Compare
ObserverOfTime
left a comment
There was a problem hiding this comment.
These template files also need to be updated:
__init__.py(description)binding_test.go(stripped URL)go.mod(stripped URL)
|
We forgot to add a |
|
done |
|
This PR broke my usage of And it turns out that even if I can manually select such a reduced |
A number of grammars in the wild have this character in their name: - sogaiu/tree-sitter-janet-simple#7 - tree-sitter/tree-sitter-c-sharp#408 - tree-sitter/tree-sitter-embedded-template#45 - tree-sitter/tree-sitter-ql-dbscheme#7 I read through tree-sitter#3700 and tree-sitter#3637, and it doesn't look like there was much discussion about this name regex, so hopefully this is an acceptable change?
A number of grammars in the wild have this character in their name: - sogaiu/tree-sitter-janet-simple#7 - tree-sitter/tree-sitter-c-sharp#408 - tree-sitter/tree-sitter-embedded-template#45 - tree-sitter/tree-sitter-ql-dbscheme#7 I read through #3700 and #3637, and it doesn't look like there was much discussion about this name regex, so hopefully this is an acceptable change?
A number of grammars in the wild have this character in their name: - sogaiu/tree-sitter-janet-simple#7 - tree-sitter/tree-sitter-c-sharp#408 - tree-sitter/tree-sitter-embedded-template#45 - tree-sitter/tree-sitter-ql-dbscheme#7 I read through #3700 and #3637, and it doesn't look like there was much discussion about this name regex, so hopefully this is an acceptable change? (cherry picked from commit 7d3c321)
A number of grammars in the wild have this character in their name: - sogaiu/tree-sitter-janet-simple#7 - tree-sitter/tree-sitter-c-sharp#408 - tree-sitter/tree-sitter-embedded-template#45 - tree-sitter/tree-sitter-ql-dbscheme#7 I read through #3700 and #3637, and it doesn't look like there was much discussion about this name regex, so hopefully this is an acceptable change? (cherry picked from commit 7d3c321)
Closes #3637
Problem
The current way to configure a tree-sitter grammar repo is by adding a
tree-sittersection to thepackage.json. This is unideal because it increases coupling to node and confuses newcomers as to why changing stuff in apackage.jsonfile influences CLI behavior. Adding more fields to thepackage.jsonalso increases complexity of a file that, ideally, should stick to node-related configuration data only. Moving to a dedicated file will make it clear that all tree-sitter related configuration is held in this file, and it also makes it easier for us to automatically derive more data to populate in other bindings files (license info, author, etc).Solution
We will now migrate to a dedicated
tree-sitter.jsonconfiguration file. This file is created and populated when a user runstree-sitter init, of which nowinitprompts the user for input much likenpm initdoes. Additionally, ifinitis ran and apackage.jsonfile is detected, the user is prompted for whether or not they'd like the CLI to automatically migrate their config to the newtree-sitter.jsonfile. The package.json is parsed and the key fields for migration are extracted, including information such as the author, version, description, name, and repository url.The loader now holds all the relevant data structures that represent the old package.json tree-sitter fields and new tree-sitter.json fields. Compatibility is retained for the old
tree-sitterfield in apackage.jsonfile until 0.25, at which point that will be removed.I'm putting this PR up now and not once I've finished the docs so that people can take a look and review it.
TODO