diff options
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | book/src/guides/adding_languages.md | 4 | ||||
-rw-r--r-- | book/src/install.md | 4 | ||||
-rw-r--r-- | helix-core/src/syntax.rs | 2 | ||||
-rw-r--r-- | helix-loader/src/grammar.rs | 4 | ||||
-rw-r--r-- | helix-term/src/args.rs | 9 | ||||
-rw-r--r-- | helix-term/src/main.rs | 19 |
8 files changed, 25 insertions, 23 deletions
@@ -435,7 +435,6 @@ name = "helix-term" version = "0.6.0" dependencies = [ "anyhow", - "cc", "chrono", "content_inspector", "crossterm", @@ -460,7 +459,6 @@ dependencies = [ "serde_json", "signal-hook", "signal-hook-tokio", - "threadpool", "tokio", "tokio-stream", "toml", @@ -39,8 +39,8 @@ build from source. git clone https://github.com/helix-editor/helix cd helix cargo install --path helix-term -hx --fetch-grammars -hx --build-grammars +hx --grammar fetch +hx --grammar build ``` This will install the `hx` binary to `$HOME/.cargo/bin` and build tree-sitter grammars. diff --git a/book/src/guides/adding_languages.md b/book/src/guides/adding_languages.md index e000770c..e5fa456c 100644 --- a/book/src/guides/adding_languages.md +++ b/book/src/guides/adding_languages.md @@ -60,7 +60,7 @@ git repository: | --- | ----------- | | `git` | A git remote URL from which the grammar should be cloned | | `rev` | The revision (commit hash or tag) which should be fetched | -| `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 | +| `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 | Or a `path` key with an absolute path to a locally available grammar directory. @@ -79,7 +79,7 @@ the last matching query supersedes the ones before it. See ## Common Issues -- 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. +- 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. - If a parser is segfaulting or you want to remove the parser, make sure to remove the compiled parser in `runtime/grammar/<name>.so` diff --git a/book/src/install.md b/book/src/install.md index db42509c..b3d42aaf 100644 --- a/book/src/install.md +++ b/book/src/install.md @@ -58,5 +58,5 @@ via the `HELIX_RUNTIME` environment variable. ## Building tree-sitter grammars Tree-sitter grammars must be fetched and compiled if not pre-packaged. -Fetch grammars with `hx --fetch-grammars` (requires `git`) and compile them -with `hx --build-grammars` (requires a C compiler). +Fetch grammars with `hx --grammar fetch` (requires `git`) and compile them +with `hx --grammar build` (requires a C compiler). diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs index 6ae46d4f..3b2d56d1 100644 --- a/helix-core/src/syntax.rs +++ b/helix-core/src/syntax.rs @@ -388,7 +388,7 @@ impl LanguageConfiguration { &injections_query, &locals_query, ) - .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)); + .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)); config.configure(scopes); Some(Arc::new(config)) diff --git a/helix-loader/src/grammar.rs b/helix-loader/src/grammar.rs index b7a3cfcf..dc327498 100644 --- a/helix-loader/src/grammar.rs +++ b/helix-loader/src/grammar.rs @@ -239,12 +239,12 @@ fn build_grammar(grammar: GrammarConfiguration) -> Result<()> { }; let grammar_dir_entries = grammar_dir.read_dir().with_context(|| { - format!("Failed to read directory {grammar_dir:?}. Did you use 'hx --fetch-grammars'?") + format!("Failed to read directory {grammar_dir:?}. Did you use 'hx --grammar fetch'?") })?; if grammar_dir_entries.count() == 0 { return Err(anyhow!( - "Directory {grammar_dir:?} is empty. Did you use 'hx --fetch-grammars'?" + "Directory {grammar_dir:?} is empty. Did you use 'hx --grammar fetch'?" )); }; diff --git a/helix-term/src/args.rs b/helix-term/src/args.rs index 80076528..e0f0af00 100644 --- a/helix-term/src/args.rs +++ b/helix-term/src/args.rs @@ -34,8 +34,13 @@ impl Args { args.health = true; args.health_arg = argv.next_if(|opt| !opt.starts_with('-')); } - "--fetch-grammars" => args.fetch_grammars = true, - "--build-grammars" => args.build_grammars = true, + "-g" | "--grammar" => match argv.next().as_deref() { + Some("fetch") => args.fetch_grammars = true, + Some("build") => args.build_grammars = true, + _ => { + anyhow::bail!("--grammar must be followed by either 'fetch' or 'build'") + } + }, arg if arg.starts_with("--") => { anyhow::bail!("unexpected double dash argument: {}", arg) } diff --git a/helix-term/src/main.rs b/helix-term/src/main.rs index a69e121b..6511e004 100644 --- a/helix-term/src/main.rs +++ b/helix-term/src/main.rs @@ -59,16 +59,15 @@ ARGS: <files>... Sets the input file to use, position can also be specified via file[:row[:col]] FLAGS: - -h, --help Prints help information - --edit-config Opens the helix config file - --tutor Loads the tutorial - --health [LANG] Checks for potential errors in editor setup - If given, checks for config errors in language LANG - --fetch-grammars Fetches tree-sitter grammars listed in languages.toml - --build-grammars Builds tree-sitter grammars fetched with --fetch-grammars - -v Increases logging verbosity each use for up to 3 times - (default file: {}) - -V, --version Prints version information + -h, --help Prints help information + --edit-config Opens the helix config file + --tutor Loads the tutorial + --health [LANG] Checks for potential errors in editor setup + If given, checks for config errors in language LANG + -g, --grammars {{fetch|build}} Fetches or builds tree-sitter grammars listed in languages.toml + -v Increases logging verbosity each use for up to 3 times + (default file: {}) + -V, --version Prints version information ", env!("CARGO_PKG_NAME"), env!("VERSION_AND_GIT_HASH"), |