generate should not create .editorconfig (et al.), that should be part of an init command
kylegoetz opened this issue · comments
Problem
.editorconfig is a configuration file to help developers in creating a TSG. generate
is to generate a TSG once it's already been coded by a developer.
Currently, the CLI checks to see if the file exists, and if it does not, it generates one from the template. It does this with other files, too. ("The first time you run tree-sitter generate, it will also generate a few other files for bindings")
If the developer does not want an .editorconfig file (or one of the others), there doesn't seem to be a way to prevent generate
from adding one.
The TSG manual online indicates generate
is the command both for initializing/scaffolding a project and for generating code for parsing every time you make changes to the grammar. ("After making changes to your grammar, just run tree-sitter generate again.")
However, some of what generate
does is more properly organized as init code. Copying template .editorconfig, .gitignore, .gitattributes, parser.c
, the Rust bindings, etc. files are all properly initialization code, not code for generating/building.
I'd be happy to file a PR for this, and I think it makes logical sense. I can't recall an application I've used where scaffolding and building were the same command.
Steps to reproduce
Look in [cli/src/generate/grammar_files.rs](https://github.com/tree-sitter/tree-sitter/blob/32cfceec6200ea5e4295e5182cb6d69045397333/cli/src/generate/grammar_files.rs#L29)
Observe the code
// Write .editorconfig file
missing_path(repo_path.join(".editorconfig"), |path| {
generate_file(path, EDITORCONFIG_TEMPLATE, language_name)
})?;
Expected behavior
There should be a new command, tree-sitter init
that does the scaffolding. generate
should not do anything that isn't necessary for generating the grammar.json, etc. much like how one would expect tree-sitter build
not to create a non-transient .editorconfig
.
Tree-sitter version (tree-sitter --version)
tree-sitter 0.20.8
Operating system/version
macOS 12.0.1
Splitting up the command into two is planned for the near future, the --no-bindings
flag currently allows users to opt out.
Might as well keep this open until then.