From 194b09fbc1edb2d0ccdadc53ec0893f61dbded8e Mon Sep 17 00:00:00 2001 From: Gokul Soumya Date: Tue, 8 Mar 2022 10:55:46 +0530 Subject: Add --health command for troubleshooting (#1669) * Move runtime file location definitions to core * Add basic --health command * Add language specific --health * Show summary for all langs with bare --health * Use TsFeature from xtask for --health * cargo fmt Co-authored-by: Blaž Hrastnik --- xtask/src/main.rs | 49 ++++++------------------------------------------- 1 file changed, 6 insertions(+), 43 deletions(-) (limited to 'xtask/src') diff --git a/xtask/src/main.rs b/xtask/src/main.rs index ad0eb16f..ad120f4f 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -3,48 +3,11 @@ use std::{env, error::Error}; type DynError = Box; pub mod helpers { - use std::{ - fmt::Display, - path::{Path, PathBuf}, - }; + use std::path::{Path, PathBuf}; use crate::path; use helix_core::syntax::Configuration as LangConfig; - - #[derive(Copy, Clone)] - pub enum TsFeature { - Highlight, - TextObjects, - AutoIndent, - } - - impl TsFeature { - pub fn all() -> &'static [Self] { - &[Self::Highlight, Self::TextObjects, Self::AutoIndent] - } - - pub fn runtime_filename(&self) -> &'static str { - match *self { - Self::Highlight => "highlights.scm", - Self::TextObjects => "textobjects.scm", - Self::AutoIndent => "indents.toml", - } - } - } - - impl Display for TsFeature { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!( - f, - "{}", - match *self { - Self::Highlight => "Syntax Highlighting", - Self::TextObjects => "Treesitter Textobjects", - Self::AutoIndent => "Auto Indent", - } - ) - } - } + use helix_term::health::TsFeature; /// Get the list of languages that support a particular tree-sitter /// based feature. @@ -105,9 +68,9 @@ pub mod md_gen { use crate::helpers; use crate::path; - use std::fs; - use helix_term::commands::TYPABLE_COMMAND_LIST; + use helix_term::health::TsFeature; + use std::fs; pub const TYPABLE_COMMANDS_MD_OUTPUT: &str = "typable-cmd.md"; pub const LANG_SUPPORT_MD_OUTPUT: &str = "lang-support.md"; @@ -151,13 +114,13 @@ pub mod md_gen { pub fn lang_features() -> Result { let mut md = String::new(); - let ts_features = helpers::TsFeature::all(); + let ts_features = TsFeature::all(); let mut cols = vec!["Language".to_owned()]; cols.append( &mut ts_features .iter() - .map(|t| t.to_string()) + .map(|t| t.long_title().to_string()) .collect::>(), ); cols.push("Default LSP".to_owned()); -- cgit v1.2.3-70-g09d2