Skip to content

Commit

Permalink
Show clipboard info in --health output
Browse files Browse the repository at this point in the history
  • Loading branch information
sudormrfbin committed Jul 2, 2022
1 parent 6e2aaed commit be77b72
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
30 changes: 30 additions & 0 deletions helix-term/src/health.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -279,9 +307,11 @@ fn probe_treesitter_feature(lang: &str, feature: TsFeature) -> std::io::Result<(
pub fn print_health(health_arg: Option<String>) -> 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()?;
}
Expand Down
6 changes: 3 additions & 3 deletions helix-term/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit be77b72

Please sign in to comment.