on master help sign in
Make idle-timeout configurable
commit633b981db22bb30c601b838eaaeb814a64156125 authorBlaž Hrastnik <blaz@mxxn.io> dateSun 10 Oct 2021, 12:32 (5 years ago) parentc7f3a97
3 files changed+22−2
book/src/configuration.md+1 helix-term/src/commands.rs+9−2 helix-view/src/editor.rs+12
book/src/configuration.md+1
@@ -19,6 +19,7 @@ To override global configuration parameters, create a `config.toml` file located
1919| `line-number` | Line number display (`absolute`, `relative`) | `absolute` |
2020| `smart-case` | Enable smart case regex searching (case insensitive unless pattern contains upper case characters) | `true` |
2121| `auto-pairs` | Enable automatic insertion of pairs to parenthese, brackets, etc. | `true` |
22+| `idle-timeout` | Time in milliseconds since last keypress before idle timers trigger. Used for autocompletion, set to 0 for instant. | `400` |
2223
2324## LSP
2425
helix-term/src/commands.rs+9−2
@@ -4130,7 +4130,7 @@ pub fn completion(cx: &mut Context) {
41304130 };
41314131
41324132 if items.is_empty() {
4133− editor.set_error("No completion available".to_string());
4133+ // editor.set_error("No completion available".to_string());
41344134 return;
41354135 }
41364136 let size = compositor.size();
@@ -4138,7 +4138,14 @@ pub fn completion(cx: &mut Context) {
41384138 .find(std::any::type_name::<ui::EditorView>())
41394139 .unwrap();
41404140 if let Some(ui) = ui.as_any_mut().downcast_mut::<ui::EditorView>() {
4141− ui.set_completion(editor, items, offset_encoding, start_offset, trigger_offset, size);
4141+ ui.set_completion(
4142+ editor,
4143+ items,
4144+ offset_encoding,
4145+ start_offset,
4146+ trigger_offset,
4147+ size,
4148+ );
41424149 };
41434150 },
41444151 );
helix-view/src/editor.rs+12
@@ -26,6 +26,14 @@ use helix_core::Position;
2626
2727use serde::Deserialize;
2828
29+fn deserialize_duration_millis<'de, D>(deserializer: D) -> Result<Duration, D::Error>
30+where
31+ D: serde::Deserializer<'de>,
32+{
33+ let millis = u64::deserialize(deserializer)?;
34+ Ok(Duration::from_millis(millis))
35+}
36+
2937#[derive(Debug, Clone, PartialEq, Deserialize)]
3038#[serde(rename_all = "kebab-case", default)]
3139pub struct Config {
@@ -45,6 +53,9 @@ pub struct Config {
4553 pub smart_case: bool,
4654 /// Automatic insertion of pairs to parentheses, brackets, etc. Defaults to true.
4755 pub auto_pairs: bool,
56+ /// Time in milliseconds since last keypress before idle timers trigger. Used for autocompletion, set to 0 for instant. Defaults to 400ms.
57+ #[serde(skip_serializing, deserialize_with = "deserialize_duration_millis")]
58+ pub idle_timeout: Duration,
4859}
4960
5061#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
@@ -72,6 +83,7 @@ impl Default for Config {
7283 middle_click_paste: true,
7384 smart_case: true,
7485 auto_pairs: true,
86+ idle_timeout: Duration::from_millis(400),
7587 }
7688 }
7789}