on master help sign in
rename '--fetch/build-grammars' flags into '--grammar fetch/build'
7044d7dMichael Davis
Cargo.lock−2
@@ -435,7 +435,6 @@ name = "helix-term"
435version = "0.6.0"
435version = "0.6.0"
436dependencies = [
436dependencies = [
437 "anyhow",
437 "anyhow",
438− "cc",
439 "chrono",
438 "chrono",
440 "content_inspector",
439 "content_inspector",
441 "crossterm",
440 "crossterm",
@@ -460,7 +459,6 @@ dependencies = [
460 "serde_json",
459 "serde_json",
461 "signal-hook",
460 "signal-hook",
462 "signal-hook-tokio",
461 "signal-hook-tokio",
463− "threadpool",
464 "tokio",
462 "tokio",
465 "tokio-stream",
463 "tokio-stream",
466 "toml",
464 "toml",
README.md+2−2
@@ -39,8 +39,8 @@ build from source.
39git clone https://github.com/helix-editor/helix
39git clone https://github.com/helix-editor/helix
40cd helix
40cd helix
41cargo install --path helix-term
41cargo install --path helix-term
42−hx --fetch-grammars
42+hx --grammar fetch
43−hx --build-grammars
43+hx --grammar build
44```
44```
45
45
46This will install the `hx` binary to `$HOME/.cargo/bin` and build tree-sitter grammars.
46This 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:
60| --- | ----------- |
60| --- | ----------- |
61| `git` | A git remote URL from which the grammar should be cloned |
61| `git` | A git remote URL from which the grammar should be cloned |
62| `rev` | The revision (commit hash or tag) which should be fetched |
62| `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 |
64
64
65Or a `path` key with an absolute path to a locally available grammar directory.
65Or a `path` key with an absolute path to a locally available grammar directory.
66
66
@@ -79,7 +79,7 @@ the last matching query supersedes the ones before it. See
79
79
80## Common Issues
80## Common Issues
81
81
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.
83
83
84- If a parser is segfaulting or you want to remove the parser, make sure to remove the compiled parser in `runtime/grammar/<name>.so`
84- If a parser is segfaulting or you want to remove the parser, make sure to remove the compiled parser in `runtime/grammar/<name>.so`
85
85
book/src/install.md+2−2
@@ -58,5 +58,5 @@ via the `HELIX_RUNTIME` environment variable.
58## Building tree-sitter grammars
58## Building tree-sitter grammars
59
59
60Tree-sitter grammars must be fetched and compiled if not pre-packaged.
60Tree-sitter grammars must be fetched and compiled if not pre-packaged.
61−Fetch grammars with `hx --fetch-grammars` (requires `git`) and compile them
61+Fetch grammars with `hx --grammar fetch` (requires `git`) and compile them
62−with `hx --build-grammars` (requires a C compiler).
62+with `hx --grammar build` (requires a C compiler).
helix-core/src/syntax.rs+1−1
@@ -388,7 +388,7 @@ impl LanguageConfiguration {
388 &injections_query,
388 &injections_query,
389 &locals_query,
389 &locals_query,
390 )
390 )
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));
392
392
393 config.configure(scopes);
393 config.configure(scopes);
394 Some(Arc::new(config))
394 Some(Arc::new(config))
helix-loader/src/grammar.rs+2−2
@@ -239,12 +239,12 @@ fn build_grammar(grammar: GrammarConfiguration) -> Result<()> {
239 };
239 };
240
240
241 let grammar_dir_entries = grammar_dir.read_dir().with_context(|| {
241 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'?")
243 })?;
243 })?;
244
244
245 if grammar_dir_entries.count() == 0 {
245 if grammar_dir_entries.count() == 0 {
246 return Err(anyhow!(
246 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'?"
248 ));
248 ));
249 };
249 };
250
250
helix-term/src/args.rs+7−2
@@ -34,8 +34,13 @@ impl Args {
34 args.health = true;
34 args.health = true;
35 args.health_arg = argv.next_if(|opt| !opt.starts_with('-'));
35 args.health_arg = argv.next_if(|opt| !opt.starts_with('-'));
36 }
36 }
37+ "-g" | "--grammar" => match argv.next().as_deref() {
37− "--fetch-grammars" => args.fetch_grammars = true,
38+ Some("fetch") => args.fetch_grammars = true,
38− "--build-grammars" => args.build_grammars = true,
39+ Some("build") => args.build_grammars = true,
40+ _ => {
41+ anyhow::bail!("--grammar must be followed by either 'fetch' or 'build'")
42+ }
43+ },
39 arg if arg.starts_with("--") => {
44 arg if arg.starts_with("--") => {
40 anyhow::bail!("unexpected double dash argument: {}", arg)
45 anyhow::bail!("unexpected double dash argument: {}", arg)
41 }
46 }
helix-term/src/main.rs+9−10
@@ -59,16 +59,15 @@ ARGS:
59 <files>... Sets the input file to use, position can also be specified via file[:row[:col]]
59 <files>... Sets the input file to use, position can also be specified via file[:row[:col]]
60
60
61FLAGS:
61FLAGS:
62− -h, --help Prints help information
62+ -h, --help Prints help information
63− --edit-config Opens the helix config file
63+ --edit-config Opens the helix config file
64− --tutor Loads the tutorial
64+ --tutor Loads the tutorial
65− --health [LANG] Checks for potential errors in editor setup
65+ --health [LANG] Checks for potential errors in editor setup
66− If given, checks for config errors in language LANG
66+ If given, checks for config errors in language LANG
67− --fetch-grammars Fetches tree-sitter grammars listed in languages.toml
67+ -g, --grammars {{fetch|build}} Fetches or builds 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
68+ -v Increases logging verbosity each use for up to 3 times
70− (default file: {})
69+ (default file: {})
71− -V, --version Prints version information
70+ -V, --version Prints version information
72",
71",
73 env!("CARGO_PKG_NAME"),
72 env!("CARGO_PKG_NAME"),
74 env!("VERSION_AND_GIT_HASH"),
73 env!("VERSION_AND_GIT_HASH"),