From 8ef984eceaca14c294899e1c0c6a9b463a6b9a38 Mon Sep 17 00:00:00 2001 From: Gokul Soumya Date: Sun, 3 Jul 2022 01:49:41 +0530 Subject: [PATCH 1/2] Show clipboard info in --health output --- helix-term/src/health.rs | 29 +++++++++++++++++++++++++++++ helix-term/src/main.rs | 4 ++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/helix-term/src/health.rs b/helix-term/src/health.rs index 4a266e481d5e..e32278c3e3b9 100644 --- a/helix-term/src/health.rs +++ b/helix-term/src/health.rs @@ -83,6 +83,33 @@ pub fn general() -> std::io::Result<()> { Ok(()) } +pub fn clipboard() -> std::io::Result<()> { + let stdout = std::io::stdout(); + let mut stdout = stdout.lock(); + + let board = get_clipboard_provider(); + match board.name().as_ref() { + "none" => { + writeln!( + stdout, + "{}", + "System clipboard provider: Not installed".red() + )?; + writeln!( + stdout, + " {}", + "For troubleshooting system clipboard issues, refer".red() + )?; + writeln!(stdout, " {}", + "https://github.com/helix-editor/helix/wiki/Troubleshooting#copypaste-fromto-system-clipboard-not-working" + .red().underlined())?; + } + name => writeln!(stdout, "System clipboard provider: {}", name)?, + } + + Ok(()) +} + pub fn languages_all() -> std::io::Result<()> { let stdout = std::io::stdout(); let mut stdout = stdout.lock(); @@ -282,9 +309,11 @@ fn probe_treesitter_feature(lang: &str, feature: TsFeature) -> std::io::Result<( pub fn print_health(health_arg: Option) -> std::io::Result<()> { match health_arg.as_deref() { Some("all") => languages_all()?, + Some("clipboard") => clipboard()?, Some(lang) => language(lang.to_string())?, None => { general()?; + clipboard()?; writeln!(std::io::stdout().lock())?; languages_all()?; } diff --git a/helix-term/src/main.rs b/helix-term/src/main.rs index 7f04f2014b95..8aaa93d7ceb3 100644 --- a/helix-term/src/main.rs +++ b/helix-term/src/main.rs @@ -61,8 +61,8 @@ ARGS: FLAGS: -h, --help Prints help information --tutor Loads the tutorial - --health [LANG] Checks for potential errors in editor setup - If given, checks for config errors in language LANG + --health [CATEGORY] Checks for potential errors in editor setup + CATEGORY can be a language or one of 'clipboard' or 'all' -g, --grammar {{fetch|build}} Fetches or builds tree-sitter grammars listed in languages.toml -c, --config Specifies a file to use for configuration -v Increases logging verbosity each use for up to 3 times From f9965cfa752e96be13eec4a3e99c53db82e01d5f Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Wed, 31 Aug 2022 09:54:12 -0500 Subject: [PATCH 2/2] health: Separate 'languages' category from 'all' --- helix-term/src/health.rs | 6 +++--- helix-term/src/main.rs | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/helix-term/src/health.rs b/helix-term/src/health.rs index e32278c3e3b9..ac9f06fc6144 100644 --- a/helix-term/src/health.rs +++ b/helix-term/src/health.rs @@ -308,15 +308,15 @@ fn probe_treesitter_feature(lang: &str, feature: TsFeature) -> std::io::Result<( pub fn print_health(health_arg: Option) -> std::io::Result<()> { match health_arg.as_deref() { - Some("all") => languages_all()?, + Some("languages") => languages_all()?, Some("clipboard") => clipboard()?, - Some(lang) => language(lang.to_string())?, - None => { + None | Some("all") => { general()?; clipboard()?; writeln!(std::io::stdout().lock())?; languages_all()?; } + Some(lang) => language(lang.to_string())?, } Ok(()) } diff --git a/helix-term/src/main.rs b/helix-term/src/main.rs index 8aaa93d7ceb3..d21d3e778bf8 100644 --- a/helix-term/src/main.rs +++ b/helix-term/src/main.rs @@ -62,7 +62,8 @@ FLAGS: -h, --help Prints help information --tutor Loads the tutorial --health [CATEGORY] Checks for potential errors in editor setup - CATEGORY can be a language or one of 'clipboard' or 'all' + CATEGORY can be a language or one of 'clipboard', 'languages' + or 'all'. 'all' is the default if not specified. -g, --grammar {{fetch|build}} Fetches or builds tree-sitter grammars listed in languages.toml -c, --config Specifies a file to use for configuration -v Increases logging verbosity each use for up to 3 times