From 9f424f03c3b2a2239b605bcdbc6cf6215700abb2 Mon Sep 17 00:00:00 2001 From: sandal Date: Wed, 14 Dec 2022 09:12:39 +0100 Subject: [PATCH] Added a step for fetching and building treesitter grammars for helix (#263) --- src/config.rs | 1 + src/main.rs | 1 + src/steps/generic.rs | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/src/config.rs b/src/config.rs index 91127684..76ea4bea 100644 --- a/src/config.rs +++ b/src/config.rs @@ -110,6 +110,7 @@ pub enum Step { Julia, Juliaup, Kakoune, + Helix, Krew, Macports, Mas, diff --git a/src/main.rs b/src/main.rs index 21c5fa9d..83e0039d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -367,6 +367,7 @@ fn run() -> Result<()> { runner.execute(Step::Vim, "The Ultimate vimrc", || vim::upgrade_ultimate_vimrc(&ctx))?; runner.execute(Step::Vim, "voom", || vim::run_voom(&base_dirs, run_type))?; runner.execute(Step::Kakoune, "Kakoune", || kakoune::upgrade_kak_plug(&ctx))?; + runner.execute(Step::Helix, "helix", || generic::run_helix_grammars(&ctx))?; runner.execute(Step::Node, "npm", || node::run_npm_upgrade(&ctx))?; runner.execute(Step::Node, "yarn", || node::run_yarn_upgrade(&ctx))?; runner.execute(Step::Node, "pnpm", || node::run_pnpm_upgrade(&ctx))?; diff --git a/src/steps/generic.rs b/src/steps/generic.rs index 16791199..cb7c64fd 100644 --- a/src/steps/generic.rs +++ b/src/steps/generic.rs @@ -499,6 +499,26 @@ pub fn run_dotnet_upgrade(ctx: &ExecutionContext) -> Result<()> { Ok(()) } +pub fn run_helix_grammars(ctx: &ExecutionContext) -> Result<()> { + utils::require("helix")?; + + print_separator("Helix"); + + ctx.run_type() + .execute(ctx.sudo().as_ref().ok_or(TopgradeError::SudoRequired)?) + .args(["helix", "--grammar", "fetch"]) + .status_checked() + .with_context(|| "Failed to download helix grammars!")?; + + ctx.run_type() + .execute(ctx.sudo().as_ref().ok_or(TopgradeError::SudoRequired)?) + .args(["helix", "--grammar", "build"]) + .status_checked() + .with_context(|| "Failed to build helix grammars!")?; + + Ok(()) +} + pub fn run_raco_update(run_type: RunType) -> Result<()> { let raco = utils::require("raco")?;