on master help sign in
rename '--fetch/build-grammars' flags into '--grammar fetch/build'

The old flags were a bit long. --grammar is also aliased to -g to make it even easier.

commit7044d7d804ad798207594e1b3bb5bd80a96d3da0 authorMichael Davis <mcarsondavis@gmail.com> dateTue 8 Mar 2022, 00:13 (5 years ago) parent37520f4
8 files changed+25−23
Cargo.lock−2 README.md+2−2 book/src/guides/adding_languages.md+2−2 book/src/install.md+2−2 helix-core/src/syntax.rs+1−1 helix-loader/src/grammar.rs+2−2 helix-term/src/args.rs+7−2 helix-term/src/main.rs+9−10
Cargo.lock−2
@@ -435,7 +435,6 @@ name = "helix-term"
435435version = "0.6.0"
436436dependencies = [
437437 "anyhow",
438− "cc",
439438 "chrono",
440439 "content_inspector",
441440 "crossterm",
@@ -460,7 +459,6 @@ dependencies = [
460459 "serde_json",
461460 "signal-hook",
462461 "signal-hook-tokio",
463− "threadpool",
464462 "tokio",
465463 "tokio-stream",
466464 "toml",
README.md+2−2
@@ -39,8 +39,8 @@ build from source.
3939git clone https://github.com/helix-editor/helix
4040cd helix
4141cargo install --path helix-term
42−hx --fetch-grammars
43−hx --build-grammars
42+hx --grammar fetch
43+hx --grammar build
4444```
4545
4646This will install the `hx` binary to `$HOME/.cargo/bin` and build tree-sitter grammars.
book/src/guides/adding_languages.md+2−2
@@ -60,7 +60,7 @@ git repository:
6060| --- | ----------- |
6161| `git` | A git remote URL from which the grammar should be cloned |
6262| `rev` | The revision (commit hash or tag) which should be fetched |
63−| `subpath` | A path within the grammar directory which should be built. Some grammar repositories host multiple grammars (for example `tree-sitter-typescript` and `tree-sitter-ocaml`) in subdirectories. This key is used to point `hx --build-grammars` to the correct path for compilation. When omitted, the root of repository is used |
63+| `subpath` | A path within the grammar directory which should be built. Some grammar repositories host multiple grammars (for example `tree-sitter-typescript` and `tree-sitter-ocaml`) in subdirectories. This key is used to point `hx --grammar build` to the correct path for compilation. When omitted, the root of repository is used |
6464
6565Or a `path` key with an absolute path to a locally available grammar directory.
6666
@@ -79,7 +79,7 @@ the last matching query supersedes the ones before it. See
7979
8080## Common Issues
8181
82−- If you get errors when running after switching branches, you may have to update the tree-sitter grammars. Run `hx --fetch-grammars` to fetch the grammars and `hx --build-grammars` to build any out-of-date grammars.
82+- If you get errors when running after switching branches, you may have to update the tree-sitter grammars. Run `hx --grammar fetch` to fetch the grammars and `hx --grammar build` to build any out-of-date grammars.
8383
8484- If a parser is segfaulting or you want to remove the parser, make sure to remove the compiled parser in `runtime/grammar/<name>.so`
8585
book/src/install.md+2−2
@@ -58,5 +58,5 @@ via the `HELIX_RUNTIME` environment variable.
5858## Building tree-sitter grammars
5959
6060Tree-sitter grammars must be fetched and compiled if not pre-packaged.
61−Fetch grammars with `hx --fetch-grammars` (requires `git`) and compile them
62−with `hx --build-grammars` (requires a C compiler).
61+Fetch grammars with `hx --grammar fetch` (requires `git`) and compile them
62+with `hx --grammar build` (requires a C compiler).
helix-core/src/syntax.rs+1−1
@@ -388,7 +388,7 @@ impl LanguageConfiguration {
388388 &injections_query,
389389 &locals_query,
390390 )
391− .unwrap_or_else(|query_error| panic!("Could not parse queries for language {:?}. Are your grammars out of sync? Try running 'hx --fetch-grammars' and 'hx --build-grammars'. This query could not be parsed: {:?}", self.language_id, query_error));
391+ .unwrap_or_else(|query_error| panic!("Could not parse queries for language {:?}. Are your grammars out of sync? Try running 'hx --grammar build' and 'hx --grammar build'. This query could not be parsed: {:?}", self.language_id, query_error));
392392
393393 config.configure(scopes);
394394 Some(Arc::new(config))
helix-loader/src/grammar.rs+2−2
@@ -239,12 +239,12 @@ fn build_grammar(grammar: GrammarConfiguration) -> Result<()> {
239239 };
240240
241241 let grammar_dir_entries = grammar_dir.read_dir().with_context(|| {
242− format!("Failed to read directory {grammar_dir:?}. Did you use 'hx --fetch-grammars'?")
242+ format!("Failed to read directory {grammar_dir:?}. Did you use 'hx --grammar fetch'?")
243243 })?;
244244
245245 if grammar_dir_entries.count() == 0 {
246246 return Err(anyhow!(
247− "Directory {grammar_dir:?} is empty. Did you use 'hx --fetch-grammars'?"
247+ "Directory {grammar_dir:?} is empty. Did you use 'hx --grammar fetch'?"
248248 ));
249249 };
250250
helix-term/src/args.rs+7−2
@@ -34,8 +34,13 @@ impl Args {
3434 args.health = true;
3535 args.health_arg = argv.next_if(|opt| !opt.starts_with('-'));
3636 }
37− "--fetch-grammars" => args.fetch_grammars = true,
38− "--build-grammars" => args.build_grammars = true,
37+ "-g" | "--grammar" => match argv.next().as_deref() {
38+ Some("fetch") => args.fetch_grammars = true,
39+ Some("build") => args.build_grammars = true,
40+ _ => {
41+ anyhow::bail!("--grammar must be followed by either 'fetch' or 'build'")
42+ }
43+ },
3944 arg if arg.starts_with("--") => {
4045 anyhow::bail!("unexpected double dash argument: {}", arg)
4146 }
helix-term/src/main.rs+9−10
@@ -59,16 +59,15 @@ ARGS:
5959 <files>... Sets the input file to use, position can also be specified via file[:row[:col]]
6060
6161FLAGS:
62− -h, --help Prints help information
63− --edit-config Opens the helix config file
64− --tutor Loads the tutorial
65− --health [LANG] Checks for potential errors in editor setup
66− If given, checks for config errors in language LANG
67− --fetch-grammars Fetches tree-sitter grammars listed in languages.toml
68− --build-grammars Builds tree-sitter grammars fetched with --fetch-grammars
69− -v Increases logging verbosity each use for up to 3 times
70− (default file: {})
71− -V, --version Prints version information
62+ -h, --help Prints help information
63+ --edit-config Opens the helix config file
64+ --tutor Loads the tutorial
65+ --health [LANG] Checks for potential errors in editor setup
66+ If given, checks for config errors in language LANG
67+ -g, --grammars {{fetch|build}} Fetches or builds tree-sitter grammars listed in languages.toml
68+ -v Increases logging verbosity each use for up to 3 times
69+ (default file: {})
70+ -V, --version Prints version information
7271",
7372 env!("CARGO_PKG_NAME"),
7473 env!("VERSION_AND_GIT_HASH"),