diff --git a/Cargo.lock b/Cargo.lock index de4b2279a..0e9f9765a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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", diff --git a/README.md b/README.md index 8e4e42d9e..4052d9411 100644 --- a/README.md +++ b/README.md @@ -39,8 +39,8 @@ # Installation 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 e000770c6..e5fa456c6 100644 --- a/book/src/guides/adding_languages.md +++ b/book/src/guides/adding_languages.md @@ -60,7 +60,7 @@ ## Grammar configuration | --- | ----------- | | `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 @@ ## Queries ## 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/.so` diff --git a/book/src/install.md b/book/src/install.md index db42509c1..b3d42aaf4 100644 --- a/book/src/install.md +++ b/book/src/install.md @@ -58,5 +58,5 @@ ## Build from source ## 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 6ae46d4ff..3b2d56d12 100644 --- a/helix-core/src/syntax.rs +++ b/helix-core/src/syntax.rs @@ -388,7 +388,7 @@ fn initialize_highlight(&self, scopes: &[String]) -> Option 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 800765289..e0f0af00f 100644 --- a/helix-term/src/args.rs +++ b/helix-term/src/args.rs @@ -34,8 +34,13 @@ pub fn parse_args() -> Result { 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 a69e121b1..6511e0046 100644 --- a/helix-term/src/main.rs +++ b/helix-term/src/main.rs @@ -59,16 +59,15 @@ async fn main_impl() -> Result { ... 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"),