Skip to content

Commit

Permalink
Make path-completion optional (default enabled)
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp-M committed Jul 7, 2022
1 parent b666cce commit a2eb387
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions book/src/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ hidden = false
| `cursorline` | Highlight all lines with a cursor. | `false` |
| `gutters` | Gutters to display: Available are `diagnostics` and `line-numbers`, note that `diagnostics` also includes other features like breakpoints | `["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` |
Expand Down
15 changes: 9 additions & 6 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2789,16 +2789,17 @@ pub mod insert {
})
.collect::<Vec<_>>();

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) {
Expand Down Expand Up @@ -3841,7 +3842,9 @@ pub fn completion(cx: &mut Context) {
completion_lsp(cx, id)
}

completion_path(cx);
if cx.editor.config().path_completion {
completion_path(cx);
}
}

// comments
Expand Down
3 changes: 3 additions & 0 deletions helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,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.
Expand Down Expand Up @@ -404,6 +406,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,
Expand Down

0 comments on commit a2eb387

Please sign in to comment.