summaryrefslogtreecommitdiff
path: root/helix-view/src/editor.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-view/src/editor.rs')
-rw-r--r--helix-view/src/editor.rs19
1 files changed, 15 insertions, 4 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index d44dc1c6..85d9be67 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -13,6 +13,7 @@ use futures_util::future;
use futures_util::stream::select_all::SelectAll;
use tokio_stream::wrappers::UnboundedReceiverStream;
+use log::debug;
use std::{
borrow::Cow,
collections::{BTreeMap, HashMap},
@@ -29,7 +30,10 @@ use anyhow::{bail, Error};
pub use helix_core::diagnostic::Severity;
pub use helix_core::register::Registers;
-use helix_core::syntax;
+use helix_core::{
+ auto_pairs::AutoPairs,
+ syntax::{self, AutoPairConfig},
+};
use helix_core::{Position, Selection};
use helix_dap as dap;
@@ -98,8 +102,10 @@ pub struct Config {
pub line_number: LineNumber,
/// Middle click paste support. Defaults to true.
pub middle_click_paste: bool,
- /// Automatic insertion of pairs to parentheses, brackets, etc. Defaults to true.
- pub auto_pairs: bool,
+ /// Automatic insertion of pairs to parentheses, brackets,
+ /// etc. Optionally, this can be a list of 2-tuples to specify a
+ /// global list of characters to pair. Defaults to true.
+ pub auto_pairs: AutoPairConfig,
/// Automatic auto-completion, automatically pop up without user trigger. Defaults to true.
pub auto_completion: bool,
/// Time in milliseconds since last keypress before idle timers trigger. Used for autocompletion, set to 0 for instant. Defaults to 400ms.
@@ -217,7 +223,7 @@ impl Default for Config {
},
line_number: LineNumber::Absolute,
middle_click_paste: true,
- auto_pairs: true,
+ auto_pairs: AutoPairConfig::default(),
auto_completion: true,
idle_timeout: Duration::from_millis(400),
completion_trigger_len: 2,
@@ -289,6 +295,7 @@ pub struct Editor {
pub autoinfo: Option<Info>,
pub config: Config,
+ pub auto_pairs: Option<AutoPairs>,
pub idle_timer: Pin<Box<Sleep>>,
pub last_motion: Option<Motion>,
@@ -312,6 +319,9 @@ impl Editor {
config: Config,
) -> Self {
let language_servers = helix_lsp::Registry::new();
+ let auto_pairs = (&config.auto_pairs).into();
+
+ debug!("Editor config: {config:#?}");
// HAXX: offset the render area height by 1 to account for prompt/commandline
area.height -= 1;
@@ -337,6 +347,7 @@ impl Editor {
idle_timer: Box::pin(sleep(config.idle_timeout)),
last_motion: None,
config,
+ auto_pairs,
exit_code: 0,
}
}