Skip to content

Configurable timeout for 'complete' sources #17908

Description

@echasnovski

Is your feature request about something that is currently impossible or hard to do? Please describe the problem.

Manual Insert mode completion (like after <C-n>) is blocking and can take non-negligible amount of time to finish (like when there is a big buffer open).

Recently #17812 introduced a concept of "timing out" a 'complete' source while returning candidates found within allocated time slot. If applied to manual completion, this seems to improve the blocking behavior.

The problem is that timeout is not configurable (which seems to be by initial design) and only applied when 'autocomplete' is enabled.

Describe the solution you'd like

A way to configure "timeout for 'complete' source" that will apply to both 'autocomplete' (probably as initial timeout before decay) and manual <C-n> invocation (probably without decaying and applied to each source separately).

Being able to configure this will improve both manual and auto completion experience.

One of the way to do it might be to allow a new completeopt flag that configures timeout. Maybe something like timeout:ms, so that set completeopt+=timeout:500 sets timeout to 500 milliseconds.

The other way is a separate option, like 'completetimeout'.

Describe alternatives you've considered

Asking for manual completion to be non-blocking, but this seems to be too complicated. There seems to already be an infrastructure for "timeout" feature which is a reasonable solution.

Additional context

There is a note in #17812 that "Timeout values are intentionally not configurable". I do understand the "just work" approach, but the problem is that slow completion candidate computation might be a result of slow machine or generally slow LSP server. And although there might be small amount of candidates available within 80 ms window, it might be inconvenient to not have more candidates at the cost of small time increase (if user wants it).

Allowing users to adjust timeout seems like a not overly complicated way to solve this. So it can "just work" with enabled 'autocomplete', but still allow users to adjust for both auto and manual completion.


cc @girishji as you are the most qualified person to discuss and potentially add this.

Activity

  1. girishji commented on Aug 5, 2025

    @girishji
    Contributor

    The autocomplete timeout can be made configurable; however, only a narrow range of values is practical before the popup window starts to feel sluggish—especially when multiple large buffers are open.

    As for ctrl-N, I'm not sure why anyone would prefer it when autocomplete already exists. That said, if the project leaders believe adding a timeout is worthwhile, I'm open to implementing it. However, it should remain a separate mechanism.

  2. echasnovski commented on Aug 5, 2025

    @echasnovski
    ContributorAuthor

    As for ctrl-N, I'm not sure why anyone would prefer it when autocomplete already exists.

    Some (surprisingly large group of) people don't like the idea of autocompletion per se. So having on-demand completion which can be used with large buffers is an improvement.

    It is also useful when implementing own autocompletion logic, which is my original motivation. I've been relying on <C-n> as a fallback for years now and it works great. With one exception: it is blocking and can sometimes cause visible lag when typing. Being able to limit its blocking time while still returning relevant candidates is a great improvement here.

    However, it should remain a separate mechanism.

    Do you mean configuring timeout for 'autocomplete' and for manual <C-n> should be separate? If yes, could you please explain why? My thought was that they essentially set a time limit for the same completion sources, so might as well be the single option/flag. It also feels likely that user of 'autocomplete' will likely not use manual <C-n> and vice versa, so the situation of "I want one timeout for 'autocomplete' but the other for manual <C-n>" will not be that common.

    That said, if the project leaders believe adding a timeout is worthwhile, I'm open to implementing it.

    @chrisbra, do you think configurable timeout for 'complete' sources is worthwhile?

  3. girishji commented on Aug 5, 2025

    @girishji
    Contributor

    Do you mean configuring timeout for 'autocomplete' and for manual <C-n> should be separate? If yes, could you please explain why?

    When the two timeouts are combined, Ctrl_N is no longer backwards compatible, as it inherits the abort-on-timeout behavior from autocomplete. Users who are accustomed to Ctrl_N doing exhaustive search may find that annoying—though they could always set the timeout to a large value. I will let chrisbra decide.

  4. chrisbra commented on Aug 6, 2025

    @chrisbra
    Member

    I would think that the timeout option would make sense for users who do not want to use 'autocomplete' setting. But it is true, that this is backwards incompatible, perhaps we could use timeout:0 as a default, which means do not timeout? So that this would not break existing users experience?

  5. echasnovski commented on Aug 6, 2025

    @echasnovski
    ContributorAuthor

    But it is true, that this is backwards incompatible, perhaps we could use timeout:0 as a default, which means do not timeout? So that this would not break existing users experience?

    That was my assumption as well: no timeout by default which is achieved either by missing timeout flag or setting it to 0. Sorry to not have said that explicitly.

  6. added a commit that references this issue on Aug 23, 2025
    69a337e
  7. added 3 commits that reference this issue on Aug 24, 2025
    c5a59f9
    bc64098
    810a234
  8. added a commit that references this issue on Sep 7, 2025
    ef7dcc9
  9. added a commit that references this issue on Sep 27, 2025
    706cd54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions