Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'xtask/src/docgen.rs')
-rw-r--r--xtask/src/docgen.rs100
1 files changed, 10 insertions, 90 deletions
diff --git a/xtask/src/docgen.rs b/xtask/src/docgen.rs
index 79ecfea1..473882f3 100644
--- a/xtask/src/docgen.rs
+++ b/xtask/src/docgen.rs
@@ -2,16 +2,11 @@ use crate::helpers;
use crate::path;
use crate::DynError;
-use helix_term::commands::MappableCommand;
use helix_term::commands::TYPABLE_COMMAND_LIST;
use helix_term::health::TsFeature;
-use helix_view::document::Mode;
-
-use std::collections::HashSet;
use std::fs;
pub const TYPABLE_COMMANDS_MD_OUTPUT: &str = "typable-cmd.md";
-pub const STATIC_COMMANDS_MD_OUTPUT: &str = "static-cmd.md";
pub const LANG_SUPPORT_MD_OUTPUT: &str = "lang-support.md";
fn md_table_heading(cols: &[String]) -> String {
@@ -36,8 +31,7 @@ pub fn typable_commands() -> Result<String, DynError> {
"Description".to_owned(),
]));
- // escape | so it doesn't get rendered as a column separator
- let cmdify = |s: &str| format!("`:{}`", s.replace('|', "\\|"));
+ let cmdify = |s: &str| format!("`:{}`", s);
for cmd in TYPABLE_COMMAND_LIST {
let names = std::iter::once(&cmd.name)
@@ -54,68 +48,6 @@ pub fn typable_commands() -> Result<String, DynError> {
Ok(md)
}
-pub fn static_commands() -> Result<String, DynError> {
- let mut md = String::new();
- let keymap = helix_term::keymap::default();
- let keymaps = [
- ("normal", keymap[&Mode::Normal].reverse_map()),
- ("select", keymap[&Mode::Select].reverse_map()),
- ("insert", keymap[&Mode::Insert].reverse_map()),
- ];
-
- md.push_str(&md_table_heading(&[
- "Name".to_owned(),
- "Description".to_owned(),
- "Default keybinds".to_owned(),
- ]));
-
- for cmd in MappableCommand::STATIC_COMMAND_LIST {
- let keymap_strings: Vec<_> = keymaps
- .iter()
- .map(|(mode, keymap)| {
- let bindings = keymap
- .get(cmd.name())
- .map(|bindings| {
- let mut bind_strings: Vec<_> = bindings
- .iter()
- .map(|bind| {
- let keys = &bind
- .iter()
- .map(|key| key.key_sequence_format())
- .collect::<String>()
- // escape | so it doesn't get rendered as a column separator
- .replace('|', "\\|");
- format!("`` {} ``", keys)
- })
- .collect();
- // sort for stable output. sorting by length puts simple
- // keybindings first and groups similar keys together
- bind_strings.sort_by_key(|s| (s.len(), s.to_owned()));
- bind_strings.join(", ")
- })
- .unwrap_or_default();
-
- (mode, bindings)
- })
- .collect();
-
- let keymap_string = keymap_strings
- .iter()
- .filter(|(_, bindings)| !bindings.is_empty())
- .map(|(mode, bindings)| format!("{}: {}", mode, bindings))
- .collect::<Vec<_>>()
- .join(", ");
-
- md.push_str(&md_table_row(&[
- md_mono(cmd.name()),
- cmd.doc().to_owned(),
- keymap_string,
- ]));
- }
-
- Ok(md)
-}
-
pub fn lang_features() -> Result<String, DynError> {
let mut md = String::new();
let ts_features = TsFeature::all();
@@ -127,10 +59,10 @@ pub fn lang_features() -> Result<String, DynError> {
.map(|t| t.long_title().to_string())
.collect::<Vec<_>>(),
);
- cols.push("Default language servers".to_owned());
+ cols.push("Default LSP".to_owned());
md.push_str(&md_table_heading(&cols));
- let config = helix_core::config::default_lang_config();
+ let config = helpers::lang_config();
let mut langs = config
.language
@@ -163,25 +95,13 @@ pub fn lang_features() -> Result<String, DynError> {
.to_owned(),
);
}
- let mut seen_commands = HashSet::new();
- let mut commands = String::new();
- for ls_config in lc
- .language_servers
- .iter()
- .filter_map(|ls| config.language_server.get(&ls.name))
- {
- let command = &ls_config.command;
- if !seen_commands.insert(command) {
- continue;
- }
-
- if !commands.is_empty() {
- commands.push_str(", ");
- }
-
- commands.push_str(&md_mono(command));
- }
- row.push(commands);
+ row.push(
+ lc.language_server
+ .as_ref()
+ .map(|s| s.command.clone())
+ .map(|c| md_mono(&c))
+ .unwrap_or_default(),
+ );
md.push_str(&md_table_row(&row));
row.clear();