5use helix_term::commands::TYPABLE_COMMAND_LIST;
6use helix_term::health::TsFeature;
9pub const TYPABLE_COMMANDS_MD_OUTPUT: &str = "typable-cmd.md";
10pub const LANG_SUPPORT_MD_OUTPUT: &str = "lang-support.md";
12fn md_table_heading(cols: &[String]) -> String {
13 let mut header = String::new();
14 header += &md_table_row(cols);
15 header += &md_table_row(&vec!["---".to_string(); cols.len()]);
19fn md_table_row(cols: &[String]) -> String {
20 format!("| {} |\n", cols.join(" | "))
23fn md_mono(s: &str) -> String {
27pub fn typable_commands() -> Result<String, DynError> {
28 let mut md = String::new();
29 md.push_str(&md_table_heading(&[
31 "Description".to_owned(),
34 let cmdify = |s: &str| format!("`:{}`", s);
36 for cmd in TYPABLE_COMMAND_LIST {
37 let names = std::iter::once(&cmd.name)
38 .chain(cmd.aliases.iter())
43 let doc = cmd.doc.replace('\n', "<br>");
45 md.push_str(&md_table_row(&[names.to_owned(), doc.to_owned()]));
51pub fn lang_features() -> Result<String, DynError> {
52 let mut md = String::new();
53 let ts_features = TsFeature::all();
55 let mut cols = vec!["Language".to_owned()];
59 .map(|t| t.long_title().to_string())
62 cols.push("Default LSP".to_owned());
64 md.push_str(&md_table_heading(&cols));
65 let config = helpers::lang_config();
67 let mut langs = config
70 .map(|l| l.language_id.clone())
72 langs.sort_unstable();
74 let mut ts_features_to_langs = Vec::new();
75 for &feat in ts_features {
76 ts_features_to_langs.push((feat, helpers::ts_lang_support(feat)));
79 let mut row = Vec::new();
84 .find(|l| l.language_id == lang)
85 .unwrap(); // lang comes from config
86 row.push(lc.language_id.clone());
88 for (_feat, support_list) in &ts_features_to_langs {
90 if support_list.contains(&lang) {
101 .map(|s| s.command.clone())
102 .map(|c| md_mono(&c))
103 .unwrap_or_default(),
106 md.push_str(&md_table_row(&row));
113pub fn write(filename: &str, data: &str) {
114 let error = format!("Could not write to {}", filename);
115 let path = path::book_gen().join(filename);
116 fs::write(path, data).expect(&error);
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list