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 Oct 27, 2022
1 parent 971c8d5 commit 3518fd9
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 @@ -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` |
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 @@ -2946,16 +2946,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 @@ -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
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 @@ -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.
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 3518fd9

Please sign in to comment.