|
|
@ -51,6 +51,7 @@ use helix_view::{
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
use anyhow::{anyhow, bail, ensure, Context as _};
|
|
|
|
use anyhow::{anyhow, bail, ensure, Context as _};
|
|
|
|
|
|
|
|
use heck::{ToKebabCase, ToLowerCamelCase, ToSnakeCase, ToTitleCase, ToUpperCamelCase};
|
|
|
|
use insert::*;
|
|
|
|
use insert::*;
|
|
|
|
use movement::Movement;
|
|
|
|
use movement::Movement;
|
|
|
|
|
|
|
|
|
|
|
@ -329,9 +330,14 @@ impl MappableCommand {
|
|
|
|
extend_prev_char, "Extend to previous occurrence of char",
|
|
|
|
extend_prev_char, "Extend to previous occurrence of char",
|
|
|
|
repeat_last_motion, "Repeat last motion",
|
|
|
|
repeat_last_motion, "Repeat last motion",
|
|
|
|
replace, "Replace with new char",
|
|
|
|
replace, "Replace with new char",
|
|
|
|
switch_case, "Switch (toggle) case",
|
|
|
|
switch_to_alternate_case, "Switch to aLTERNATE cASE",
|
|
|
|
switch_to_uppercase, "Switch to uppercase",
|
|
|
|
switch_to_uppercase, "Switch to UPPERCASE",
|
|
|
|
switch_to_lowercase, "Switch to lowercase",
|
|
|
|
switch_to_lowercase, "Switch to lowercase",
|
|
|
|
|
|
|
|
switch_to_pascal_case, "Switch to PascalCase",
|
|
|
|
|
|
|
|
switch_to_camel_case, "Switch to camelCase",
|
|
|
|
|
|
|
|
switch_to_title_case, "Switch to Title Case",
|
|
|
|
|
|
|
|
switch_to_snake_case, "Switch to snake_case",
|
|
|
|
|
|
|
|
switch_to_kebab_case, "Switch to kebab-case",
|
|
|
|
page_up, "Move page up",
|
|
|
|
page_up, "Move page up",
|
|
|
|
page_down, "Move page down",
|
|
|
|
page_down, "Move page down",
|
|
|
|
half_page_up, "Move half page up",
|
|
|
|
half_page_up, "Move half page up",
|
|
|
@ -1713,7 +1719,15 @@ where
|
|
|
|
exit_select_mode(cx);
|
|
|
|
exit_select_mode(cx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn switch_case(cx: &mut Context) {
|
|
|
|
fn switch_heck_case_impl(cx: &mut Context, change_fn: impl Fn(Tendril) -> String) {
|
|
|
|
|
|
|
|
switch_case_impl(cx, |string| {
|
|
|
|
|
|
|
|
let stri = Tendril::from_iter(string.chars());
|
|
|
|
|
|
|
|
let applied = change_fn(stri);
|
|
|
|
|
|
|
|
Tendril::from_iter(applied.chars())
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn switch_to_alternate_case(cx: &mut Context) {
|
|
|
|
switch_case_impl(cx, |string| {
|
|
|
|
switch_case_impl(cx, |string| {
|
|
|
|
string
|
|
|
|
string
|
|
|
|
.chars()
|
|
|
|
.chars()
|
|
|
@ -1730,6 +1744,26 @@ fn switch_case(cx: &mut Context) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn switch_to_pascal_case(cx: &mut Context) {
|
|
|
|
|
|
|
|
switch_heck_case_impl(cx, |str| str.to_upper_camel_case())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn switch_to_camel_case(cx: &mut Context) {
|
|
|
|
|
|
|
|
switch_heck_case_impl(cx, |str| str.to_lower_camel_case())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn switch_to_title_case(cx: &mut Context) {
|
|
|
|
|
|
|
|
switch_heck_case_impl(cx, |str| str.to_title_case())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn switch_to_snake_case(cx: &mut Context) {
|
|
|
|
|
|
|
|
switch_heck_case_impl(cx, |str| str.to_snake_case())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn switch_to_kebab_case(cx: &mut Context) {
|
|
|
|
|
|
|
|
switch_heck_case_impl(cx, |str| str.to_kebab_case())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn switch_to_uppercase(cx: &mut Context) {
|
|
|
|
fn switch_to_uppercase(cx: &mut Context) {
|
|
|
|
switch_case_impl(cx, |string| {
|
|
|
|
switch_case_impl(cx, |string| {
|
|
|
|
string.chunks().map(|chunk| chunk.to_uppercase()).collect()
|
|
|
|
string.chunks().map(|chunk| chunk.to_uppercase()).collect()
|
|
|
|