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

generate should not create .editorconfig (et al.), that should be part of an init command #3321

Open
kylegoetz opened this issue Apr 26, 2024 · 2 comments
Labels
cli enhancement Feature request
Milestone

Comments

@kylegoetz
Copy link

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

@amaanq
Copy link
Member

amaanq commented Apr 26, 2024

Splitting up the command into two is planned for the near future, the --no-bindings flag currently allows users to opt out.

@amaanq amaanq closed this as not planned Won't fix, can't repro, duplicate, stale Apr 26, 2024
@ObserverOfTime ObserverOfTime added enhancement Feature request cli and removed bug labels Apr 26, 2024
@ObserverOfTime
Copy link
Member

Might as well keep this open until then.

@ObserverOfTime ObserverOfTime added this to the 0.24 milestone Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli enhancement Feature request
Projects
None yet
Development

No branches or pull requests

3 participants