From 3518fd9ca5e7af2a9052659d9c5a88fbd8f5f466 Mon Sep 17 00:00:00 2001 From: Philipp Mildenberger Date: Wed, 1 Jun 2022 21:42:01 +0200 Subject: [PATCH] Make path-completion optional (default enabled) --- book/src/configuration.md | 1 + helix-term/src/commands.rs | 15 +++++++++------ helix-view/src/editor.rs | 3 +++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/book/src/configuration.md b/book/src/configuration.md index 9f3fe2fa95bd2..c06f28c3c3b9d 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -48,6 +48,7 @@ on unix operating systems. | `cursorcolumn` | Highlight all columns with a cursor. | `false` | | `gutters` | Gutters to display: Available are `diagnostics` and `line-numbers` and `spacer`, note that `diagnostics` also includes other features like breakpoints, 1-width padding will be inserted if gutters is non-empty | `["diagnostics", "line-numbers"]` | | `auto-completion` | Enable automatic pop up of auto-completion. | `true` | +| `path-completion` | Enable filepath completion, show files and directories if a path at the cursor was recognized. | `true` | | `auto-format` | Enable automatic formatting on save. | `true` | | `auto-save` | Enable automatic saving on focus moving away from Helix. Requires [focus event support](https://github.com/helix-editor/helix/wiki/Terminal-Support) from your terminal. | `false` | | `idle-timeout` | Time in milliseconds since last keypress before idle timers trigger. Used for autocompletion, set to 0 for instant. | `400` | diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index e2a27fb153a87..fdf906a29675d 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2946,16 +2946,17 @@ pub mod insert { }) .collect::>(); - if !trigger_completion_ls_ids.is_empty() || ch == '/' { + if !trigger_completion_ls_ids.is_empty() { cx.editor.clear_idle_timer(); - // TODO path for windows - if ch == '/' { - super::completion_path(cx) - } for id in trigger_completion_ls_ids { super::completion_lsp(cx, id) } } + // TODO path for windows + if ch == '/' && cx.editor.config().path_completion { + cx.editor.clear_idle_timer(); + super::completion_path(cx) + } } fn signature_help(cx: &mut Context, ch: char) { @@ -4057,7 +4058,9 @@ pub fn completion(cx: &mut Context) { completion_lsp(cx, id) } - completion_path(cx); + if cx.editor.config().path_completion { + completion_path(cx); + } } // comments diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 0991e45ac6b19..eabb6290d79ef 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -138,6 +138,8 @@ pub struct Config { pub auto_pairs: AutoPairConfig, /// Automatic auto-completion, automatically pop up without user trigger. Defaults to true. pub auto_completion: bool, + /// Filepath completion, show files and directories if a path at the cursor was recognized. Defaults to true. + pub path_completion: bool, /// Automatic formatting on save. Defaults to true. pub auto_format: bool, /// Automatic save on focus lost. Defaults to false. @@ -593,6 +595,7 @@ impl Default for Config { middle_click_paste: true, auto_pairs: AutoPairConfig::default(), auto_completion: true, + path_completion: true, auto_format: true, auto_save: false, idle_timeout: Duration::from_millis(400),