on master help sign in
add config option for instant completion entry preview (defaulting to true).

Signed-off-by: Luca Schlecker <luca.schlecker@hotmail.com>

commitdbd248fdfa680373d94fbc10094a160aafa0f7a7 authorLuca Schlecker <luca.schlecker@hotmail.com> dateWed 7 Jun 2023, 14:18 (3 years ago) parent00b152f
3 files changed+7−1
book/src/configuration.md+1 helix-term/src/ui/completion.rs+3−1 helix-view/src/editor.rs+3
book/src/configuration.md+1
@@ -52,6 +52,7 @@ Its settings will be merged with the configuration directory `config.toml` and t
5252| `auto-format` | Enable automatic formatting on save | `true` |
5353| `auto-save` | Enable automatic saving on the focus moving away from Helix. Requires [focus event support](https://github.com/helix-editor/helix/wiki/Terminal-Support) from your terminal | `false` |
5454| `idle-timeout` | Time in milliseconds since last keypress before idle timers trigger. Used for autocompletion, set to 0 for instant | `400` |
55+| `preview-completion-insert` | Whether to apply completion item instantly when selected | `true` |
5556| `completion-trigger-len` | The min-length of word under cursor to trigger autocompletion | `2` |
5657| `completion-replace` | Set to `true` to make completions always replace the entire word and not just the part before the cursor | `false` |
5758| `auto-info` | Whether to display info boxes | `true` |
helix-term/src/ui/completion.rs+3−1
@@ -110,6 +110,7 @@ impl Completion {
110110 start_offset: usize,
111111 trigger_offset: usize,
112112 ) -> Self {
113+ let preview_completion_insert = editor.config().preview_completion_insert;
113114 let replace_mode = editor.config().completion_replace;
114115 // Sort completion items according to their preselect status (given by the LSP server)
115116 items.sort_by_key(|item| !item.item.preselect.unwrap_or(false));
@@ -230,7 +231,7 @@ impl Completion {
230231
231232 match event {
232233 PromptEvent::Abort => {}
233− PromptEvent::Update => {
234+ PromptEvent::Update if preview_completion_insert => {
234235 // Update creates "ghost" transactions which are not sent to the
235236 // lsp server to avoid messing up re-requesting completions. Once a
236237 // completion has been selected (with tab, c-n or c-p) it's always accepted whenever anything
@@ -263,6 +264,7 @@ impl Completion {
263264 );
264265 doc.apply_temporary(&transaction, view.id);
265266 }
267+ PromptEvent::Update => {}
266268 PromptEvent::Validate => {
267269 if let Some(CompleteAction::Selected { savepoint }) =
268270 editor.last_completion.take()
helix-view/src/editor.rs+3
@@ -251,6 +251,8 @@ pub struct Config {
251251 deserialize_with = "deserialize_duration_millis"
252252 )]
253253 pub idle_timeout: Duration,
254+ /// Whether to insert the completion suggestion on hover. Defaults to true.
255+ pub preview_completion_insert: bool,
254256 pub completion_trigger_len: u8,
255257 /// Whether to instruct the LSP to replace the entire word when applying a completion
256258 /// or to only insert new text
@@ -746,6 +748,7 @@ impl Default for Config {
746748 auto_format: true,
747749 auto_save: false,
748750 idle_timeout: Duration::from_millis(400),
751+ preview_completion_insert: true,
749752 completion_trigger_len: 2,
750753 auto_info: true,
751754 file_picker: FilePickerConfig::default(),