summaryrefslogtreecommitdiff
path: root/helix-view/src/editor.rs
diff options
context:
space:
mode:
authorPascal Kuthe2023-11-21 00:46:12 +0000
committerBlaž Hrastnik2024-03-23 06:35:25 +0000
commitb46064b8c469c85b9626dba60728e23798354ed8 (patch)
tree203d9698a3e99767202c05e8c62850ea199a2a06 /helix-view/src/editor.rs
parent3001f22b315e479dcfc24c7a0fd221d7fb03d276 (diff)
Add an Amp-like jump command
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
Diffstat (limited to 'helix-view/src/editor.rs')
-rw-r--r--helix-view/src/editor.rs23
1 files changed, 22 insertions, 1 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index bad61052..3c530c4e 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -22,7 +22,7 @@ use tokio_stream::wrappers::UnboundedReceiverStream;
use std::{
borrow::Cow,
cell::Cell,
- collections::{BTreeMap, HashMap},
+ collections::{BTreeMap, HashMap, HashSet},
fs,
io::{self, stdin},
num::NonZeroUsize,
@@ -212,6 +212,23 @@ impl Default for FilePickerConfig {
}
}
+fn deserialize_alphabet<'de, D>(deserializer: D) -> Result<Vec<char>, D::Error>
+where
+ D: Deserializer<'de>,
+{
+ use serde::de::Error;
+
+ let str = String::deserialize(deserializer)?;
+ let chars: Vec<_> = str.chars().collect();
+ let unique_chars: HashSet<_> = chars.iter().copied().collect();
+ if unique_chars.len() != chars.len() {
+ return Err(<D::Error as Error>::custom(
+ "jump-label-alphabet must contain unique characters",
+ ));
+ }
+ Ok(chars)
+}
+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case", default, deny_unknown_fields)]
pub struct Config {
@@ -305,6 +322,9 @@ pub struct Config {
/// Which indent heuristic to use when a new line is inserted
#[serde(default)]
pub indent_heuristic: IndentationHeuristic,
+ /// labels characters used in jumpmode
+ #[serde(skip_serializing, deserialize_with = "deserialize_alphabet")]
+ pub jump_label_alphabet: Vec<char>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, Eq, PartialOrd, Ord)]
@@ -870,6 +890,7 @@ impl Default for Config {
smart_tab: Some(SmartTabConfig::default()),
popup_border: PopupBorderConfig::None,
indent_heuristic: IndentationHeuristic::default(),
+ jump_label_alphabet: ('a'..='z').collect(),
}
}
}