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.
pull/1784/head
Michael Davis 3 years ago committed by Blaž Hrastnik
parent 37520f46ae
commit 7044d7d804

2
Cargo.lock generated

@ -435,7 +435,6 @@ name = "helix-term"
version = "0.6.0" version = "0.6.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cc",
"chrono", "chrono",
"content_inspector", "content_inspector",
"crossterm", "crossterm",
@ -460,7 +459,6 @@ dependencies = [
"serde_json", "serde_json",
"signal-hook", "signal-hook",
"signal-hook-tokio", "signal-hook-tokio",
"threadpool",
"tokio", "tokio",
"tokio-stream", "tokio-stream",
"toml", "toml",

@ -39,8 +39,8 @@ build from source.
git clone https://github.com/helix-editor/helix git clone https://github.com/helix-editor/helix
cd helix cd helix
cargo install --path helix-term cargo install --path helix-term
hx --fetch-grammars hx --grammar fetch
hx --build-grammars hx --grammar build
``` ```
This will install the `hx` binary to `$HOME/.cargo/bin` and build tree-sitter grammars. This will install the `hx` binary to `$HOME/.cargo/bin` and build tree-sitter grammars.

@ -60,7 +60,7 @@ git repository:
| --- | ----------- | | --- | ----------- |
| `git` | A git remote URL from which the grammar should be cloned | | `git` | A git remote URL from which the grammar should be cloned |
| `rev` | The revision (commit hash or tag) which should be fetched | | `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. 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 ## 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` - If a parser is segfaulting or you want to remove the parser, make sure to remove the compiled parser in `runtime/grammar/<name>.so`

@ -58,5 +58,5 @@ via the `HELIX_RUNTIME` environment variable.
## Building tree-sitter grammars ## Building tree-sitter grammars
Tree-sitter grammars must be fetched and compiled if not pre-packaged. Tree-sitter grammars must be fetched and compiled if not pre-packaged.
Fetch grammars with `hx --fetch-grammars` (requires `git`) and compile them Fetch grammars with `hx --grammar fetch` (requires `git`) and compile them
with `hx --build-grammars` (requires a C compiler). with `hx --grammar build` (requires a C compiler).

@ -388,7 +388,7 @@ impl LanguageConfiguration {
&injections_query, &injections_query,
&locals_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); config.configure(scopes);
Some(Arc::new(config)) Some(Arc::new(config))

@ -239,12 +239,12 @@ fn build_grammar(grammar: GrammarConfiguration) -> Result<()> {
}; };
let grammar_dir_entries = grammar_dir.read_dir().with_context(|| { 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 { if grammar_dir_entries.count() == 0 {
return Err(anyhow!( 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'?"
)); ));
}; };

@ -34,8 +34,13 @@ impl Args {
args.health = true; args.health = true;
args.health_arg = argv.next_if(|opt| !opt.starts_with('-')); args.health_arg = argv.next_if(|opt| !opt.starts_with('-'));
} }
"--fetch-grammars" => args.fetch_grammars = true, "-g" | "--grammar" => match argv.next().as_deref() {
"--build-grammars" => args.build_grammars = true, 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("--") => { arg if arg.starts_with("--") => {
anyhow::bail!("unexpected double dash argument: {}", arg) anyhow::bail!("unexpected double dash argument: {}", arg)
} }

@ -59,16 +59,15 @@ ARGS:
<files>... Sets the input file to use, position can also be specified via file[:row[:col]] <files>... Sets the input file to use, position can also be specified via file[:row[:col]]
FLAGS: FLAGS:
-h, --help Prints help information -h, --help Prints help information
--edit-config Opens the helix config file --edit-config Opens the helix config file
--tutor Loads the tutorial --tutor Loads the tutorial
--health [LANG] Checks for potential errors in editor setup --health [LANG] Checks for potential errors in editor setup
If given, checks for config errors in language LANG If given, checks for config errors in language LANG
--fetch-grammars Fetches tree-sitter grammars listed in languages.toml -g, --grammars {{fetch|build}} Fetches or builds 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
-v Increases logging verbosity each use for up to 3 times (default file: {})
(default file: {}) -V, --version Prints version information
-V, --version Prints version information
", ",
env!("CARGO_PKG_NAME"), env!("CARGO_PKG_NAME"),
env!("VERSION_AND_GIT_HASH"), env!("VERSION_AND_GIT_HASH"),

Loading…
Cancel
Save