diff --git a/book/src/configuration.md b/book/src/configuration.md index 996c5fb6ada3..6f7073bb8d8a 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` | | `idle-timeout` | Time in milliseconds since last keypress before idle timers trigger. Used for autocompletion, set to 0 for instant. | `400` | | `completion-trigger-len` | The min-length of word under cursor to trigger autocompletion | `2` | diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index b9c0662f9d64..bcfb12ad2275 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2936,16 +2936,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) { @@ -4047,7 +4048,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 01a5110c7a52..511b6e941d85 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -136,6 +136,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, /// Time in milliseconds since last keypress before idle timers trigger. @@ -589,6 +591,7 @@ impl Default for Config { middle_click_paste: true, auto_pairs: AutoPairConfig::default(), auto_completion: true, + path_completion: true, auto_format: true, idle_timeout: Duration::from_millis(400), completion_trigger_len: 2,