on master help sign in
add config option for instant completion entry preview (defaulting to true).
dbd248fLuca Schlecker
book/src/configuration.md+1
@@ -52,6 +52,7 @@ Its settings will be merged with the configuration directory `config.toml` and t
52| `auto-format` | Enable automatic formatting on save | `true` |
52| `auto-format` | Enable automatic formatting on save | `true` |
53| `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` |
53| `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` |
54| `idle-timeout` | Time in milliseconds since last keypress before idle timers trigger. Used for autocompletion, set to 0 for instant | `400` |
54| `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` |
55| `completion-trigger-len` | The min-length of word under cursor to trigger autocompletion | `2` |
56| `completion-trigger-len` | The min-length of word under cursor to trigger autocompletion | `2` |
56| `completion-replace` | Set to `true` to make completions always replace the entire word and not just the part before the cursor | `false` |
57| `completion-replace` | Set to `true` to make completions always replace the entire word and not just the part before the cursor | `false` |
57| `auto-info` | Whether to display info boxes | `true` |
58| `auto-info` | Whether to display info boxes | `true` |
helix-term/src/ui/completion.rs+3−1
@@ -110,6 +110,7 @@ impl Completion {
110 start_offset: usize,
110 start_offset: usize,
111 trigger_offset: usize,
111 trigger_offset: usize,
112 ) -> Self {
112 ) -> Self {
113+ let preview_completion_insert = editor.config().preview_completion_insert;
113 let replace_mode = editor.config().completion_replace;
114 let replace_mode = editor.config().completion_replace;
114 // Sort completion items according to their preselect status (given by the LSP server)
115 // Sort completion items according to their preselect status (given by the LSP server)
115 items.sort_by_key(|item| !item.item.preselect.unwrap_or(false));
116 items.sort_by_key(|item| !item.item.preselect.unwrap_or(false));
@@ -230,7 +231,7 @@ impl Completion {
230
231
231 match event {
232 match event {
232 PromptEvent::Abort => {}
233 PromptEvent::Abort => {}
233− PromptEvent::Update => {
234+ PromptEvent::Update if preview_completion_insert => {
234 // Update creates "ghost" transactions which are not sent to the
235 // Update creates "ghost" transactions which are not sent to the
235 // lsp server to avoid messing up re-requesting completions. Once a
236 // lsp server to avoid messing up re-requesting completions. Once a
236 // completion has been selected (with tab, c-n or c-p) it's always accepted whenever anything
237 // completion has been selected (with tab, c-n or c-p) it's always accepted whenever anything
@@ -263,6 +264,7 @@ impl Completion {
263 );
264 );
264 doc.apply_temporary(&transaction, view.id);
265 doc.apply_temporary(&transaction, view.id);
265 }
266 }
267+ PromptEvent::Update => {}
266 PromptEvent::Validate => {
268 PromptEvent::Validate => {
267 if let Some(CompleteAction::Selected { savepoint }) =
269 if let Some(CompleteAction::Selected { savepoint }) =
268 editor.last_completion.take()
270 editor.last_completion.take()
helix-view/src/editor.rs+3
@@ -251,6 +251,8 @@ pub struct Config {
251 deserialize_with = "deserialize_duration_millis"
251 deserialize_with = "deserialize_duration_millis"
252 )]
252 )]
253 pub idle_timeout: Duration,
253 pub idle_timeout: Duration,
254+ /// Whether to insert the completion suggestion on hover. Defaults to true.
255+ pub preview_completion_insert: bool,
254 pub completion_trigger_len: u8,
256 pub completion_trigger_len: u8,
255 /// Whether to instruct the LSP to replace the entire word when applying a completion
257 /// Whether to instruct the LSP to replace the entire word when applying a completion
256 /// or to only insert new text
258 /// or to only insert new text
@@ -746,6 +748,7 @@ impl Default for Config {
746 auto_format: true,
748 auto_format: true,
747 auto_save: false,
749 auto_save: false,
748 idle_timeout: Duration::from_millis(400),
750 idle_timeout: Duration::from_millis(400),
751+ preview_completion_insert: true,
749 completion_trigger_len: 2,
752 completion_trigger_len: 2,
750 auto_info: true,
753 auto_info: true,
751 file_picker: FilePickerConfig::default(),
754 file_picker: FilePickerConfig::default(),