Skip to content

Conversation

@girishji
Copy link
Contributor

@girishji girishji commented Aug 9, 2025

This patch introduces a new option 'autocompletedelay' ('acl') that specifies the delay, in milliseconds, before the autocomplete menu appears after typing.

When set to a non-zero value, Vim waits for the specified time before showing the completion popup, allowing users to reduce distraction from rapid suggestion pop-ups or to fine-tune the responsiveness of completion. Set this to a value slightly higher than your typing speed.

The default value is 0, which preserves the current immediate-popup behavior.

Similar to 'editor.quickSuggestionsDelay' in VSCode.

@zeertzjq
Copy link
Member

zeertzjq commented Aug 10, 2025

Set this to a value slightly higher than your typing speed.

Should this also be mentioned in the help? Although "typing speed" is not a delay, so maybe "typing interval"?

@char101
Copy link
Contributor

char101 commented Aug 11, 2025

In Windows GVim (where the cursor is a thin vertical line), using this option (set autocompletedelay=1000) blocks the cursor movement on the first character.

For example, when typing h in the second line, the cursor will not be moved after h but stuck before h. Only after typing he will the cursor move.

hello
|h
hello
he|

Futhermore, it seems that pumvisible() still returns true when the popup menu is delayed. If I set this mapping

inoremap <expr> <cr> pumvisible() ? "\<c-y>" : "\<cr>"

typing enter after hello at the second line does not insert <cr>.

hello
hello|

@girishji
Copy link
Contributor Author

Set this to a value slightly higher than your typing speed.

Should this also be mentioned in the help? Although "typing speed" is not a delay, so maybe "typing interval"?

I added something to that effect.

@girishji
Copy link
Contributor Author

@char101 Gvim handles the cursor slightly differently than terminal Vim. I’ll investigate. The pumvisible() issue should now be resolved.

@girishji
Copy link
Contributor Author

@char101 Can you give it a try now? I did not test on Gvim, but found some issues with cursor update. If it does not fix, let me know.

@char101
Copy link
Contributor

char101 commented Aug 12, 2025

I tried it and unfortunately the cursor is still stuck. I noticed that there is a function called gui_update_cursor. I tested replacing

 cursor_on();
 setcursor();
 out_flush();

with

gui_update_cursor(TRUE, FALSE);

and it does move the cursor.

Edit: after looking at terminal.c, I tested this lines of code and it also move the cursor.

#ifdef FEAT_GUI
	if (gui.in_use)
	{
	    gui_update_cursor(FALSE, FALSE);
	    gui_mch_flush();
	}
#endif

@girishji
Copy link
Contributor Author

Can you try (no need to check for gui):

    cursor_on();
    setcursor();
    out_flush_cursor(FALSE, FALSE);

@char101
Copy link
Contributor

char101 commented Aug 13, 2025

Can you try (no need to check for gui):

    cursor_on();
    setcursor();
    out_flush_cursor(FALSE, FALSE);

I have tested it and it seems to work.

@chrisbra
Copy link
Member

So is the current autocompletion too distracting? If yes, than we should possibly set the default to 10 like in VSCode? If not, why do we need this?

@berggeist
Copy link

berggeist commented Aug 15, 2025

In my eyes such an option would make sense, so please take it into consideration to merge this PR.

@girishji unfortunately, when ac is active and acl is set to a long duration, e.g. 1000 Vim on my computer core dumps when typing CTRL-N quickly in insert-mode.

Just insert a couple of characters, then begin a new word starting with an already existing character within the current buffer and quickly type CTRL-N (maybe several times).

Vim: Caught deadly signal SEGV
Vim: Finished.
Segmentation fault (core dumped)

My settings are:
complete=.,w,b,u,t
completeopt=menuone,preinsert

If you need some more information, don't hesitate to ask me.

@girishji
Copy link
Contributor Author

@berggeist , you can try the following change. It ought to fix it. I'll have time later today to look into this in depth:

diff --git a/src/insexpand.c b/src/insexpand.c
index 3c4a69a54..c8b7b8131 100644
--- a/src/insexpand.c
+++ b/src/insexpand.c
@@ -7160,7 +7160,7 @@ ins_complete(int c, int enable_pum)
        {
            if (char_avail())
            {
-               ins_compl_free();
+               ins_compl_restart();
                compl_interrupted = TRUE;
                break;
            }

@berggeist
Copy link

@girishji thank you for your quick help. This fixes the core dumps 👍

@girishji girishji force-pushed the timeouts branch 2 times, most recently from b647c4d to 2f2fba4 Compare August 16, 2025 05:17
This patch introduces a new global option `'autocompletedelay'` (`'acl'`) that
specifies the delay, in milliseconds, before the autocomplete menu appears
after typing.

When set to a non-zero value, Vim waits for the specified time before showing
the completion popup, allowing users to reduce distraction from rapid
suggestion pop-ups or to fine-tune the responsiveness of completion.

The default value is `0`, which preserves the current immediate-popup
behavior.
@girishji
Copy link
Contributor Author

So is the current autocompletion too distracting? If yes, than we should possibly set the default to 10 like in VSCode? If not, why do we need this?

I’d lean toward keeping the delay at 0. I don’t think it is distracting, and it’s entirely subjective--users often equate how fast the popup appears with how “good” the autocompletion system feels. From experience building an autocomplete plugin, even a 10 ms delay isn’t consciously perceptible, but users strongly notice overall responsiveness, and any extra delay risks making the experience feel sluggish. A “reasonable” delay of several hundred milliseconds would also be entirely subjective.

The framing of “if it’s distracting then set it to 10, if not then why do we need it” is a bit of a false dilemma.

@chrisbra
Copy link
Member

okay thanks, that's fair

@chrisbra chrisbra closed this in a09b160 Aug 16, 2025
@char101
Copy link
Contributor

char101 commented Aug 17, 2025

With autocompletedelay set, I noticed that pressing <C-n> and <C-p> is also delayed when the completion menu is visible.

For example, with set autocomplete autocompletedelay=500 completeopt=menu

hello
hella
he|

After he wait until the completion menu appears, then press <C-n>, the first entry will only be selected after 500ms.

Edit: the <Down> and <Up> keys are also delayed.

mao-yining pushed a commit to mao-yining/vim that referenced this pull request Aug 18, 2025
Problem:  completion: not possible to delay the autcompletion
Solution: add the 'autocompletedelay' option value (Girish Palya).

This patch introduces a new global option 'autocompletedelay'/'acl' that
specifies the delay, in milliseconds, before the autocomplete menu
appears after typing.

When set to a non-zero value, Vim waits for the specified time before
showing the completion popup, allowing users to reduce distraction from
rapid suggestion pop-ups or to fine-tune the responsiveness of
completion.

The default value is 0, which preserves the current immediate-popup
behavior.

closes: vim#17960

Signed-off-by: Girish Palya <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
@girishji girishji deleted the timeouts branch August 19, 2025 06:23
chrisbra pushed a commit that referenced this pull request Aug 20, 2025
Problem:  Autocompletion adds delay
          (gcanat, char101, after v9.1.1638)
Solution: Temporarily disable autocomplation (Girish Palya).

related: #17960
fixes: #18022
closes: #18048

Signed-off-by: Girish Palya <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
zeertzjq added a commit to zeertzjq/neovim that referenced this pull request Aug 22, 2025
Problem:  completion: not possible to delay the autcompletion
Solution: add the 'autocompletedelay' option value (Girish Palya).

This patch introduces a new global option 'autocompletedelay'/'acl' that
specifies the delay, in milliseconds, before the autocomplete menu
appears after typing.

When set to a non-zero value, Vim waits for the specified time before
showing the completion popup, allowing users to reduce distraction from
rapid suggestion pop-ups or to fine-tune the responsiveness of
completion.

The default value is 0, which preserves the current immediate-popup
behavior.

closes: vim/vim#17960

vim/vim@a09b160

N/A patch: vim-patch:9.1.1641: a few compiler warnings are output

Co-authored-by: Girish Palya <girishji@gmail.com>
zeertzjq added a commit to zeertzjq/neovim that referenced this pull request Aug 23, 2025
Problem:  completion: not possible to delay the autcompletion
Solution: add the 'autocompletedelay' option value (Girish Palya).

This patch introduces a new global option 'autocompletedelay'/'acl' that
specifies the delay, in milliseconds, before the autocomplete menu
appears after typing.

When set to a non-zero value, Vim waits for the specified time before
showing the completion popup, allowing users to reduce distraction from
rapid suggestion pop-ups or to fine-tune the responsiveness of
completion.

The default value is 0, which preserves the current immediate-popup
behavior.

closes: vim/vim#17960

vim/vim@a09b160

N/A patch: vim-patch:9.1.1641: a few compiler warnings are output

Co-authored-by: Girish Palya <girishji@gmail.com>
zeertzjq added a commit to zeertzjq/neovim that referenced this pull request Aug 23, 2025
Problem:  Autocompletion adds delay
          (gcanat, char101, after v9.1.1638)
Solution: Temporarily disable autocomplation (Girish Palya).

related: vim/vim#17960
fixes: vim/vim#18022
closes: vim/vim#18048

vim/vim@196c376

Co-authored-by: Girish Palya <girishji@gmail.com>
zeertzjq added a commit to zeertzjq/neovim that referenced this pull request Aug 23, 2025
Problem:  completion: not possible to delay the autcompletion
Solution: add the 'autocompletedelay' option value (Girish Palya).

This patch introduces a new global option 'autocompletedelay'/'acl' that
specifies the delay, in milliseconds, before the autocomplete menu
appears after typing.

When set to a non-zero value, Vim waits for the specified time before
showing the completion popup, allowing users to reduce distraction from
rapid suggestion pop-ups or to fine-tune the responsiveness of
completion.

The default value is 0, which preserves the current immediate-popup
behavior.

closes: vim/vim#17960

vim/vim@a09b160

N/A patch: vim-patch:9.1.1641: a few compiler warnings are output

Co-authored-by: Girish Palya <girishji@gmail.com>
zeertzjq added a commit to zeertzjq/neovim that referenced this pull request Aug 23, 2025
Problem:  Autocompletion adds delay
          (gcanat, char101, after v9.1.1638)
Solution: Temporarily disable autocomplation (Girish Palya).

related: vim/vim#17960
fixes: vim/vim#18022
closes: vim/vim#18048

vim/vim@196c376

Co-authored-by: Girish Palya <girishji@gmail.com>
zeertzjq added a commit to zeertzjq/neovim that referenced this pull request Aug 23, 2025
Problem:  completion: not possible to delay the autcompletion
Solution: add the 'autocompletedelay' option value (Girish Palya).

This patch introduces a new global option 'autocompletedelay'/'acl' that
specifies the delay, in milliseconds, before the autocomplete menu
appears after typing.

When set to a non-zero value, Vim waits for the specified time before
showing the completion popup, allowing users to reduce distraction from
rapid suggestion pop-ups or to fine-tune the responsiveness of
completion.

The default value is 0, which preserves the current immediate-popup
behavior.

closes: vim/vim#17960

vim/vim@a09b160

N/A patch: vim-patch:9.1.1641: a few compiler warnings are output

Co-authored-by: Girish Palya <girishji@gmail.com>
zeertzjq added a commit to zeertzjq/neovim that referenced this pull request Aug 23, 2025
Problem:  Autocompletion adds delay
          (gcanat, char101, after v9.1.1638)
Solution: Temporarily disable autocomplation (Girish Palya).

related: vim/vim#17960
fixes: vim/vim#18022
closes: vim/vim#18048

vim/vim@196c376

Co-authored-by: Girish Palya <girishji@gmail.com>
sahinf pushed a commit to sahinf/vim that referenced this pull request Sep 7, 2025
Problem:  completion: not possible to delay the autcompletion
Solution: add the 'autocompletedelay' option value (Girish Palya).

This patch introduces a new global option 'autocompletedelay'/'acl' that
specifies the delay, in milliseconds, before the autocomplete menu
appears after typing.

When set to a non-zero value, Vim waits for the specified time before
showing the completion popup, allowing users to reduce distraction from
rapid suggestion pop-ups or to fine-tune the responsiveness of
completion.

The default value is 0, which preserves the current immediate-popup
behavior.

closes: vim#17960

Signed-off-by: Girish Palya <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
sahinf pushed a commit to sahinf/vim that referenced this pull request Sep 7, 2025
Problem:  Autocompletion adds delay
          (gcanat, char101, after v9.1.1638)
Solution: Temporarily disable autocomplation (Girish Palya).

related: vim#17960
fixes: vim#18022
closes: vim#18048

Signed-off-by: Girish Palya <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
dundargoc pushed a commit to dundargoc/neovim that referenced this pull request Sep 27, 2025
Problem:  completion: not possible to delay the autcompletion
Solution: add the 'autocompletedelay' option value (Girish Palya).

This patch introduces a new global option 'autocompletedelay'/'acl' that
specifies the delay, in milliseconds, before the autocomplete menu
appears after typing.

When set to a non-zero value, Vim waits for the specified time before
showing the completion popup, allowing users to reduce distraction from
rapid suggestion pop-ups or to fine-tune the responsiveness of
completion.

The default value is 0, which preserves the current immediate-popup
behavior.

closes: vim/vim#17960

vim/vim@a09b160

N/A patch: vim-patch:9.1.1641: a few compiler warnings are output

Co-authored-by: Girish Palya <girishji@gmail.com>
dundargoc pushed a commit to dundargoc/neovim that referenced this pull request Sep 27, 2025
Problem:  Autocompletion adds delay
          (gcanat, char101, after v9.1.1638)
Solution: Temporarily disable autocomplation (Girish Palya).

related: vim/vim#17960
fixes: vim/vim#18022
closes: vim/vim#18048

vim/vim@196c376

Co-authored-by: Girish Palya <girishji@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants