diff --git a/helix-term/src/health.rs b/helix-term/src/health.rs index f64e121d5fd17..510060fa69241 100644 --- a/helix-term/src/health.rs +++ b/helix-term/src/health.rs @@ -4,6 +4,7 @@ use crossterm::{ }; use helix_core::config::{default_syntax_loader, user_syntax_loader}; use helix_loader::grammar::load_runtime_file; +use helix_view::clipboard::get_clipboard_provider; use std::io::Write; #[derive(Copy, Clone)] @@ -80,6 +81,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(); @@ -279,9 +307,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 eb186d78e2acf..c2c717ab56038 100644 --- a/helix-term/src/main.rs +++ b/helix-term/src/main.rs @@ -61,9 +61,9 @@ 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 - -g, --grammar {{fetch|build}} Fetches or builds tree-sitter grammars listed in languages.toml + --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 -v Increases logging verbosity each use for up to 3 times (default file: {}) -V, --version Prints version information