Add completion trigger chars

pull/6/head
trivernis 2 years ago
parent 1ad06ee586
commit 37bb8a80d1
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -22,6 +22,7 @@ And others I forgot about...
- Added a `--show-explorer` cli flag to open the file explorer on startup (useful for embedded explorer mode)
- Added a `delete` (aliases `rm`, `del`) command to delete the file associated with the current buffer
- Changed keybind `<space> E` to close the explorer instead of toggling the recursion one
- Added a completion chars setting that triggers autocomplete when typing one of those chars
- - -

@ -51,6 +51,7 @@ on unix operating systems.
| `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` |
| `completion-trigger-chars` | The chars that trigger completion (additional to all word chars) | `['.', ':']` |
| `auto-info` | Whether to display infoboxes | `true` |
| `true-color` | Set to `true` to override automatic detection of terminal truecolor support in the event of a false negative. | `false` |
| `rulers` | List of column positions at which to display the rulers. Can be overridden by language specific `rulers` in `languages.toml` file. | `[]` |

@ -2942,9 +2942,11 @@ pub mod insert {
use helix_core::chars::char_is_word;
let mut iter = text.chars_at(cursor);
iter.reverse();
for _ in 0..config.completion_trigger_len {
match iter.next() {
Some(c) if char_is_word(c) => {}
Some(c) if config.completion_trigger_chars.contains(&c) => {}
_ => return,
}
}

@ -197,6 +197,7 @@ pub struct Config {
)]
pub idle_timeout: Duration,
pub completion_trigger_len: u8,
pub completion_trigger_chars: Vec<char>,
/// Whether to display infoboxes. Defaults to true.
pub auto_info: bool,
pub file_picker: FilePickerConfig,
@ -670,6 +671,7 @@ impl Default for Config {
indent_guides: IndentGuidesConfig::default(),
color_modes: true,
explorer: ExplorerConfig::default(),
completion_trigger_chars: vec!['.'],
}
}
}

Loading…
Cancel
Save