patch 9.1.1590: cannot perform autocompletion

Commit: 
https://github.com/vim/vim/commit/af9a7a04f18693eee4400dd134135527f4e8cd5f
Author: Girish Palya <giris...@gmail.com>
Date:   Fri Jul 25 18:48:53 2025 +0200

    patch 9.1.1590: cannot perform autocompletion
    
    Problem:  cannot perform autocompletion
    Solution: Add the 'autocomplete' option value
              (Girish Palya)
    
    This change introduces the 'autocomplete' ('ac') boolean option to
    enable automatic popup menu completion during insert mode. When enabled,
    Vim shows a completion menu as you type, similar to pressing |i\_CTRL-N|
    manually. The items are collected from sources defined in the
    'complete' option.
    
    To ensure responsiveness, this feature uses a time-sliced strategy:
    
    - Sources earlier in the 'complete' list are given more time.
    - If a source exceeds its allocated timeout, it is interrupted.
    - The next source is then started with a reduced timeout (exponentially
      decayed).
    - A small minimum ensures every source still gets a brief chance to
      contribute.
    
    The feature is fully compatible with other |i_CTRL-X| completion modes,
    which can temporarily suspend automatic completion when triggered.
    
    See :help 'autocomplete' and :help ins-autocompletion for more details.
    
    To try it out, use :set ac
    
    You should see a popup menu appear automatically with suggestions. This
    works seamlessly across:
    
    - Large files (multi-gigabyte size)
    - Massive codebases (:argadd thousands of .c or .h files)
    - Large dictionaries via the `k` option
    - Slow or blocking LSP servers or user-defined 'completefunc'
    
    Despite potential slowness in sources, the menu remains fast,
    responsive, and useful.
    
    Compatibility: This mode is fully compatible with existing completion
    methods. You can still invoke any CTRL-X based completion (e.g.,
    CTRL-X CTRL-F for filenames) at any time (CTRL-X temporarily
    suspends 'autocomplete'). To specifically use i_CTRL-N, dismiss the
    current popup by pressing CTRL-E first.
    
    ---
    
    How it works
    
    To keep completion snappy under all conditions, autocompletion uses a
    decaying time-sliced algorithm:
    
    - Starts with an initial timeout (80ms).
    - If a source does not complete within the timeout, it's interrupted and
      the timeout is halved for the next source.
    - This continues recursively until a minimum timeout (5ms) is reached.
    - All sources are given a chance, but slower ones are de-prioritized
      quickly.
    
    Most of the time, matches are computed well within the initial window.
    
    ---
    
    Implementation details
    
    - Completion logic is mostly triggered in `edit.c` and handled in
      insexpand.c.
    
    - Uses existing inc_compl_check_keys() mechanism, so no new polling
      hooks are needed.
    
    - The completion system already checks for user input periodically; it
      now also checks for timer expiry.
    
    ---
    
    Design notes
    
    - The menu doesn't continuously update after it's shown to prevent
      visual distraction (due to resizing) and ensure the internal list
      stays synchronized with the displayed menu.
    
    - The 'complete' option determines priority—sources listed earlier get
      more time.
    
    - The exponential time-decay mechanism prevents indefinite collection,
      contributing to low CPU usage and a minimal memory footprint.
    
    - Timeout values are intentionally not configurable—this system is
      optimized to "just work" out of the box. If autocompletion feels slow,
      it typically indicates a deeper performance bottleneck (e.g., a slow
      custom function not using `complete_check()`) rather than a
      configuration issue.
    
    ---
    
    Performance
    
    Based on testing, the total roundtrip time for completion is generally
    under 200ms. For common usage, it often responds in under 50ms on an
    average laptop, which falls within the "feels instantaneous" category
    (sub-100ms) for perceived user experience.
    
    | Upper Bound (ms) | Perceived UX
    |----------------- |-------------
    | <100 ms          | Excellent; instantaneous
    | <200 ms          | Good; snappy
    | >300 ms          | Noticeable lag
    | >500 ms          | Sluggish/Broken
    
    ---
    
    Why this belongs in core:
    
    - Minimal and focused implementation, tightly integrated with existing
      Insert-mode completion logic.
    - Zero reliance on autocommands and external scripting.
    - Makes full use of Vim’s highly composable 'complete' infrastructure
      while avoiding the complexity of plugin-based solutions.
    - Gives users C native autocompletion with excellent responsiveness and
      no configuration overhead.
    - Adds a key UX functionality in a simple, performant, and Vim-like way.
    
    closes: #17812
    
    Signed-off-by: Girish Palya <giris...@gmail.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt
index 4352388f5..ec896809e 100644
--- a/runtime/doc/insert.txt
+++ b/runtime/doc/insert.txt
@@ -1,4 +1,4 @@
-*insert.txt*    For Vim version 9.1.  Last change: 2025 Jul 21
+*insert.txt*    For Vim version 9.1.  Last change: 2025 Jul 25
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -1133,6 +1133,22 @@ Stop completion                                          
*compl-stop*
 CTRL-X CTRL-Z          Stop completion without changing the text.
 
 
+AUTOCOMPLETION                                         *ins-autocompletion*
+
+Vim can display a completion menu as you type, similar to using |i_CTRL-N|,
+but triggered automatically.  See |'autocomplete'|. The menu items are
+collected from the sources listed in the |'complete'| option.
+
+Unlike manual |i_CTRL-N| completion, this mode uses a decaying timeout to keep
+Vim responsive.  Sources earlier in the |'complete'| list are given more time
+(higher priority), but every source is guaranteed a time slice, however small.
+
+This mode is fully compatible with other completion modes.  You can invoke
+any of them at any time by typing |CTRL-X|, which temporarily suspends
+autocompletion.  To use |i_CTRL-N| specifically, press |CTRL-E| first to
+dismiss the popup menu (see |complete_CTRL-E|).
+
+
 FUNCTIONS FOR FINDING COMPLETIONS                      *complete-functions*
 
 This applies to 'completefunc', 'thesaurusfunc' and 'omnifunc'.
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 0a1d955fb..a9ebaec19 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -1,4 +1,4 @@
-*options.txt*  For Vim version 9.1.  Last change: 2025 Jul 21
+*options.txt*  For Vim version 9.1.  Last change: 2025 Jul 25
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -911,6 +911,13 @@ A jump table for the options with a short description can 
be found at |Q_op|.
        the current directory won't change when navigating to it.
        Note: When this option is on some plugins may not work.
 
+                       *'autocomplete'* *'ac'* *'noautocomplete'* *'noac'*
+'autocomplete' 'ac'    boolean (default off)
+                       global
+                       {only available on platforms with timing support}
+       When on, Vim shows a completion menu as you type, similar to using
+       |i_CTRL-N|, but triggered automatically.  See |ins-autocompletion|.
+
                        *'autoindent'* *'ai'* *'noautoindent'* *'noai'*
 'autoindent' 'ai'      boolean (default off)
                        local to buffer
@@ -2129,9 +2136,9 @@ A jump table for the options with a short description can 
be found at |Q_op|.
                If the Dict returned by the {func} includes {"refresh": 
"always"},
                the function will be invoked again whenever the leading text
                changes.
-               If generating matches is potentially slow, |complete_check()|
-               should be used to avoid blocking and preserve editor
-               responsiveness.
+               If generating matches is potentially slow, call
+               |complete_check()| periodically to keep Vim responsive. This
+               is especially important for |ins-autocompletion|.
        F       equivalent to using "F{func}", where the function is taken from
                the 'completefunc' option.
        o       equivalent to using "F{func}", where the function is taken from
@@ -2278,6 +2285,9 @@ A jump table for the options with a short description can 
be found at |Q_op|.
                    completion in the preview window.  Only works in
                    combination with "menu" or "menuone".
 
+       Only "fuzzy", "popup", "popuphidden" and "preview" have an effect when
+       'autocomplete' is enabled.
+
        This option does not apply to |cmdline-completion|. See 'wildoptions'
        for that.
 
diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt
index bc308987f..ed790ab17 100644
--- a/runtime/doc/quickref.txt
+++ b/runtime/doc/quickref.txt
@@ -1,4 +1,4 @@
-*quickref.txt*  For Vim version 9.1.  Last change: 2025 Jul 16
+*quickref.txt*  For Vim version 9.1.  Last change: 2025 Jul 25
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -607,6 +607,7 @@ Short explanation of each option:           *option-list*
 'arabic'         'arab'    for Arabic as a default second language
 'arabicshape'    'arshape' do shaping for Arabic characters
 'autochdir'      'acd'     change directory to the file in the current window
+'autocomplete'   'ac'      automatic completion in insert mode
 'autoindent'     'ai'      take indent for new line from previous line
 'autoread'       'ar'      autom. read file when changed outside of Vim
 'autoshelldir'   'asd'     change directory to the shell's current directory
diff --git a/runtime/doc/tags b/runtime/doc/tags
index 1d1c83959..2b4202606 100644
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -41,6 +41,7 @@ $quote        eval.txt        /*$quote*
 ']     motion.txt      /*']*
 '^     motion.txt      /*'^*
 'a     motion.txt      /*'a*
+'ac'   options.txt     /*'ac'*
 'acd'  options.txt     /*'acd'*
 'ai'   options.txt     /*'ai'*
 'akm'  options.txt     /*'akm'*
@@ -62,6 +63,7 @@ $quote        eval.txt        /*$quote*
 'as'   todo.txt        /*'as'*
 'asd'  options.txt     /*'asd'*
 'autochdir'    options.txt     /*'autochdir'*
+'autocomplete' options.txt     /*'autocomplete'*
 'autoindent'   options.txt     /*'autoindent'*
 'autoprint'    vi_diff.txt     /*'autoprint'*
 'autoread'     options.txt     /*'autoread'*
@@ -555,6 +557,7 @@ $quote      eval.txt        /*$quote*
 'mzschemedll'  options.txt     /*'mzschemedll'*
 'mzschemegcdll'        options.txt     /*'mzschemegcdll'*
 'nf'   options.txt     /*'nf'*
+'noac' options.txt     /*'noac'*
 'noacd'        options.txt     /*'noacd'*
 'noai' options.txt     /*'noai'*
 'noakm'        options.txt     /*'noakm'*
@@ -571,6 +574,7 @@ $quote      eval.txt        /*$quote*
 'noas' todo.txt        /*'noas'*
 'noasd'        options.txt     /*'noasd'*
 'noautochdir'  options.txt     /*'noautochdir'*
+'noautocomplete'       options.txt     /*'noautocomplete'*
 'noautoindent' options.txt     /*'noautoindent'*
 'noautoread'   options.txt     /*'noautoread'*
 'noautosave'   todo.txt        /*'noautosave'*
@@ -8585,6 +8589,7 @@ inputlist()       builtin.txt     /*inputlist()*
 inputrestore() builtin.txt     /*inputrestore()*
 inputsave()    builtin.txt     /*inputsave()*
 inputsecret()  builtin.txt     /*inputsecret()*
+ins-autocompletion     insert.txt      /*ins-autocompletion*
 ins-completion insert.txt      /*ins-completion*
 ins-completion-menu    insert.txt      /*ins-completion-menu*
 ins-expandtab  insert.txt      /*ins-expandtab*
diff --git a/runtime/doc/version9.txt b/runtime/doc/version9.txt
index 10b47424f..a82676c42 100644
--- a/runtime/doc/version9.txt
+++ b/runtime/doc/version9.txt
@@ -1,4 +1,4 @@
-*version9.txt*  For Vim version 9.1.  Last change: 2025 Jul 21
+*version9.txt*  For Vim version 9.1.  Last change: 2025 Jul 25
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -41604,6 +41604,7 @@ Completion~
        "preinsert"     - highlight to be inserted values
        "nearest"       - sort completion results by distance to cursor
 - new function |wildtrigger()| to trigger wildcard expansion
+- Support for Autocompletion has been added |ins-autocompletion|
 
 Platform specific~
 -----------------
@@ -41809,6 +41810,7 @@ Ex-Commands: ~
 
 Options: ~
 
+'autocompletion'       Enable auto completion |ins-autocompletion|
 'chistory'             Size of the quickfix stack |quickfix-stack|.
 'completefuzzycollect' Enable fuzzy collection of candidates for (some)
                        |ins-completion| modes
diff --git a/runtime/optwin.vim b/runtime/optwin.vim
index 80dcec79d..47e165f45 100644
--- a/runtime/optwin.vim
+++ b/runtime/optwin.vim
@@ -1,7 +1,7 @@
 " These commands create the option window.
 "
 " Maintainer:  The Vim Project <https://github.com/vim/vim>
-" Last Change: 2025 Jul 16
+" Last Change: 2025 Jul 25
 " Former Maintainer:   Bram Moolenaar <b...@vim.org>
 
 " If there already is an option window, jump to that one.
@@ -873,13 +873,15 @@ endif
 if has("insert_expand")
   call <SID>AddOption("complete", gettext("specifies how Insert mode 
completion works for CTRL-N and CTRL-P"))
   call append("$", "   " .. s:local_to_buffer)
-  call <SID>OptionL("cfc")
-  call <SID>AddOption("completefuzzycollect", gettext("use fuzzy collection 
for specific completion modes"))
   call <SID>OptionL("cpt")
+  call <SID>AddOption("autocomplete", gettext("automatic completion in insert 
mode"))
+  call <SID>BinOptionG("ac", &ac)
   call <SID>AddOption("completeopt", gettext("whether to use a popup menu for 
Insert mode completion"))
   call <SID>OptionL("cot")
   call <SID>AddOption("completeitemalign", gettext("popup menu item align 
order"))
   call <SID>OptionG("cia", &cia)
+  call <SID>AddOption("completefuzzycollect", gettext("use fuzzy collection 
for specific completion modes"))
+  call <SID>OptionL("cfc")
   if exists("+completepopup")
     call <SID>AddOption("completepopup", gettext("options for the Insert mode 
completion info popup"))
     call <SID>OptionG("cpp", &cpp)
diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim
index eebd6ba4a..c3dd63ab0 100644
--- a/runtime/syntax/vim.vim
+++ b/runtime/syntax/vim.vim
@@ -2,7 +2,7 @@
 " Language:       Vim script
 " Maintainer:     Hirohito Higashi <h.east.727 ATMARK gmail.com>
 "         Doug Kearns <dougkea...@gmail.com>
-" Last Change:    2025 Jul 24
+" Last Change:    2025 Jul 25
 " Former Maintainer: Charles E. Campbell
 
 " DO NOT CHANGE DIRECTLY.
@@ -63,29 +63,29 @@ syn keyword vimStdPlugin contained  Arguments Asm Break 
Cfilter Clear Continue Di
 
 " vimOptions are caught only when contained in a vimSet {{{2
 " GEN_SYN_VIM: vimOption normal, START_STR='syn keyword vimOption contained', 
END_STR='skipwhite nextgroup=vimSetEqual,vimSetMod'
-syn keyword vimOption contained al aleph ari allowrevins ambw ambiwidth arab 
arabic arshape arabicshape acd autochdir ai autoindent ar autoread asd 
autoshelldir aw autowrite awa autowriteall bg background bs backspace bk backup 
bkc backupcopy bdir backupdir bex backupext bsk backupskip bdlay balloondelay 
beval ballooneval bevalterm balloonevalterm bexpr balloonexpr bo belloff bin 
binary bomb brk breakat bri breakindent briopt breakindentopt bsdir browsedir 
bh bufhidden bl buflisted bt buftype cmp casemap cdh cdhome cd cdpath cedit ccv 
charconvert chi chistory cin cindent cink cinkeys cino cinoptions cinsd 
cinscopedecls cinw cinwords cb clipboard cpm clipmethod ch cmdheight cwh 
cmdwinheight cc colorcolumn co columns com comments cms commentstring cp 
compatible skipwhite nextgroup=vimSetEqual,vimSetMod
-syn keyword vimOption contained cpt complete cfu completefunc cfc 
completefuzzycollect cia completeitemalign cot completeopt cpp completepopup 
csl completeslash cocu concealcursor cole conceallevel cf confirm ci copyindent 
cpo cpoptions cm cryptmethod cspc cscopepathcomp csprg cscopeprg csqf 
cscopequickfix csre cscoperelative cst cscopetag csto cscopetagorder csverb 
cscopeverbose crb cursorbind cuc cursorcolumn cul cursorline culopt 
cursorlineopt debug def define deco delcombine dict dictionary diff dia 
diffanchors dex diffexpr dip diffopt dg digraph dir directory dy display ead 
eadirection ed edcompatible emo emoji enc encoding eof endoffile eol endofline 
ea equalalways ep equalprg eb errorbells ef errorfile efm errorformat ek 
esckeys ei eventignore eiw eventignorewin skipwhite 
nextgroup=vimSetEqual,vimSetMod
-syn keyword vimOption contained et expandtab ex exrc fenc fileencoding fencs 
fileencodings ff fileformat ffs fileformats fic fileignorecase ft filetype fcs 
fillchars ffu findfunc fixeol fixendofline fcl foldclose fdc foldcolumn fen 
foldenable fde foldexpr fdi foldignore fdl foldlevel fdls foldlevelstart fmr 
foldmarker fdm foldmethod fml foldminlines fdn foldnestmax fdo foldopen fdt 
foldtext fex formatexpr flp formatlistpat fo formatoptions fp formatprg fs 
fsync gd gdefault gfm grepformat gp grepprg gcr guicursor gfn guifont gfs 
guifontset gfw guifontwide ghr guiheadroom gli guiligatures go guioptions 
guipty gtl guitablabel gtt guitabtooltip hf helpfile hh helpheight hlg helplang 
hid hidden hl highlight hi history hk hkmap hkp hkmapp hls hlsearch icon 
iconstring skipwhite nextgroup=vimSetEqual,vimSetMod
-syn keyword vimOption contained ic ignorecase imaf imactivatefunc imak 
imactivatekey imc imcmdline imd imdisable imi iminsert ims imsearch imsf 
imstatusfunc imst imstyle inc include inex includeexpr is incsearch inde 
indentexpr indk indentkeys inf infercase im insertmode ise isexpand isf isfname 
isi isident isk iskeyword isp isprint js joinspaces jop jumpoptions key kmp 
keymap km keymodel kpc keyprotocol kp keywordprg lmap langmap lm langmenu lnr 
langnoremap lrm langremap ls laststatus lz lazyredraw lhi lhistory lbr 
linebreak lines lsp linespace lisp lop lispoptions lw lispwords list lcs 
listchars lpl loadplugins luadll magic mef makeef menc makeencoding mp makeprg 
mps matchpairs mat matchtime mco maxcombine mfd maxfuncdepth mmd maxmapdepth mm 
maxmem mmp maxmempattern skipwhite nextgroup=vimSetEqual,vimSetMod
-syn keyword vimOption contained mmt maxmemtot msc maxsearchcount mis menuitems 
mopt messagesopt msm mkspellmem ml modeline mle modelineexpr mls modelines ma 
modifiable mod modified more mouse mousef mousefocus mh mousehide mousem 
mousemodel mousemev mousemoveevent mouses mouseshape mouset mousetime mzq 
mzquantum mzschemedll mzschemegcdll nf nrformats nu number nuw numberwidth ofu 
omnifunc odev opendevice opfunc operatorfunc pp packpath para paragraphs paste 
pt pastetoggle pex patchexpr pm patchmode pa path perldll pi preserveindent pvh 
previewheight pvp previewpopup pvw previewwindow pdev printdevice penc 
printencoding pexpr printexpr pfn printfont pheader printheader pmbcs 
printmbcharset pmbfn printmbfont popt printoptions prompt ph pumheight pmw 
pummaxwidth skipwhite nextgroup=vimSetEqual,vimSetMod
-syn keyword vimOption contained pw pumwidth pythondll pythonhome 
pythonthreedll pythonthreehome pyx pyxversion qftf quickfixtextfunc qe 
quoteescape ro readonly rdt redrawtime re regexpengine rnu relativenumber remap 
rop renderoptions report rs restorescreen ri revins rl rightleft rlc 
rightleftcmd rubydll ru ruler ruf rulerformat rtp runtimepath scr scroll scb 
scrollbind scf scrollfocus sj scrolljump so scrolloff sbo scrollopt sect 
sections secure sel selection slm selectmode ssop sessionoptions sh shell shcf 
shellcmdflag sp shellpipe shq shellquote srr shellredir ssl shellslash stmp 
shelltemp st shelltype sxe shellxescape sxq shellxquote sr shiftround sw 
shiftwidth shm shortmess sn shortname sbr showbreak sc showcmd sloc showcmdloc 
sft showfulltag sm showmatch skipwhite nextgroup=vimSetEqual,vimSetMod
-syn keyword vimOption contained smd showmode stal showtabline stpl 
showtabpanel ss sidescroll siso sidescrolloff scl signcolumn scs smartcase si 
smartindent sta smarttab sms smoothscroll sts softtabstop spell spc 
spellcapcheck spf spellfile spl spelllang spo spelloptions sps spellsuggest sb 
splitbelow spk splitkeep spr splitright sol startofline stl statusline su 
suffixes sua suffixesadd swf swapfile sws swapsync swb switchbuf smc synmaxcol 
syn syntax tcl tabclose tal tabline tpm tabpagemax tpl tabpanel tplo 
tabpanelopt ts tabstop tbs tagbsearch tc tagcase tfu tagfunc tl taglength tr 
tagrelative tag tags tgst tagstack tcldll term tbidi termbidi tenc termencoding 
tgc termguicolors twk termwinkey twsl termwinscroll tws termwinsize twt 
termwintype terse ta textauto skipwhite nextgroup=vimSetEqual,vimSetMod
-syn keyword vimOption contained tx textmode tw textwidth tsr thesaurus tsrfu 
thesaurusfunc top tildeop to timeout tm timeoutlen title titlelen titleold 
titlestring tb toolbar tbis toolbariconsize ttimeout ttm ttimeoutlen tbi 
ttybuiltin tf ttyfast ttym ttymouse tsl ttyscroll tty ttytype udir undodir udf 
undofile ul undolevels ur undoreload uc updatecount ut updatetime vsts 
varsofttabstop vts vartabstop vbs verbose vfile verbosefile vdir viewdir vop 
viewoptions vi viminfo vif viminfofile ve virtualedit vb visualbell warn wiv 
weirdinvert ww whichwrap wc wildchar wcm wildcharm wig wildignore wic 
wildignorecase wmnu wildmenu wim wildmode wop wildoptions wak winaltkeys wcr 
wincolor wi window wfb winfixbuf wfh winfixheight wfw winfixwidth wh winheight 
wmh winminheight skipwhite nextgroup=vimSetEqual,vimSetMod
+syn keyword vimOption contained al aleph ari allowrevins ambw ambiwidth arab 
arabic arshape arabicshape acd autochdir ac autocomplete ai autoindent ar 
autoread asd autoshelldir aw autowrite awa autowriteall bg background bs 
backspace bk backup bkc backupcopy bdir backupdir bex backupext bsk backupskip 
bdlay balloondelay beval ballooneval bevalterm balloonevalterm bexpr 
balloonexpr bo belloff bin binary bomb brk breakat bri breakindent briopt 
breakindentopt bsdir browsedir bh bufhidden bl buflisted bt buftype cmp casemap 
cdh cdhome cd cdpath cedit ccv charconvert chi chistory cin cindent cink 
cinkeys cino cinoptions cinsd cinscopedecls cinw cinwords cb clipboard cpm 
clipmethod ch cmdheight cwh cmdwinheight cc colorcolumn co columns com comments 
cms commentstring skipwhite nextgroup=vimSetEqual,vimSetMod
+syn keyword vimOption contained cp compatible cpt complete cfu completefunc 
cfc completefuzzycollect cia completeitemalign cot completeopt cpp 
completepopup csl completeslash cocu concealcursor cole conceallevel cf confirm 
ci copyindent cpo cpoptions cm cryptmethod cspc cscopepathcomp csprg cscopeprg 
csqf cscopequickfix csre cscoperelative cst cscopetag csto cscopetagorder 
csverb cscopeverbose crb cursorbind cuc cursorcolumn cul cursorline culopt 
cursorlineopt debug def define deco delcombine dict dictionary diff dia 
diffanchors dex diffexpr dip diffopt dg digraph dir directory dy display ead 
eadirection ed edcompatible emo emoji enc encoding eof endoffile eol endofline 
ea equalalways ep equalprg eb errorbells ef errorfile efm errorformat ek 
esckeys ei eventignore skipwhite nextgroup=vimSetEqual,vimSetMod
+syn keyword vimOption contained eiw eventignorewin et expandtab ex exrc fenc 
fileencoding fencs fileencodings ff fileformat ffs fileformats fic 
fileignorecase ft filetype fcs fillchars ffu findfunc fixeol fixendofline fcl 
foldclose fdc foldcolumn fen foldenable fde foldexpr fdi foldignore fdl 
foldlevel fdls foldlevelstart fmr foldmarker fdm foldmethod fml foldminlines 
fdn foldnestmax fdo foldopen fdt foldtext fex formatexpr flp formatlistpat fo 
formatoptions fp formatprg fs fsync gd gdefault gfm grepformat gp grepprg gcr 
guicursor gfn guifont gfs guifontset gfw guifontwide ghr guiheadroom gli 
guiligatures go guioptions guipty gtl guitablabel gtt guitabtooltip hf helpfile 
hh helpheight hlg helplang hid hidden hl highlight hi history hk hkmap hkp 
hkmapp hls hlsearch skipwhite nextgroup=vimSetEqual,vimSetMod
+syn keyword vimOption contained icon iconstring ic ignorecase imaf 
imactivatefunc imak imactivatekey imc imcmdline imd imdisable imi iminsert ims 
imsearch imsf imstatusfunc imst imstyle inc include inex includeexpr is 
incsearch inde indentexpr indk indentkeys inf infercase im insertmode ise 
isexpand isf isfname isi isident isk iskeyword isp isprint js joinspaces jop 
jumpoptions key kmp keymap km keymodel kpc keyprotocol kp keywordprg lmap 
langmap lm langmenu lnr langnoremap lrm langremap ls laststatus lz lazyredraw 
lhi lhistory lbr linebreak lines lsp linespace lisp lop lispoptions lw 
lispwords list lcs listchars lpl loadplugins luadll magic mef makeef menc 
makeencoding mp makeprg mps matchpairs mat matchtime mco maxcombine mfd 
maxfuncdepth mmd maxmapdepth mm maxmem skipwhite nextgroup=vimSetEqual,vimSetMod
+syn keyword vimOption contained mmp maxmempattern mmt maxmemtot msc 
maxsearchcount mis menuitems mopt messagesopt msm mkspellmem ml modeline mle 
modelineexpr mls modelines ma modifiable mod modified more mouse mousef 
mousefocus mh mousehide mousem mousemodel mousemev mousemoveevent mouses 
mouseshape mouset mousetime mzq mzquantum mzschemedll mzschemegcdll nf 
nrformats nu number nuw numberwidth ofu omnifunc odev opendevice opfunc 
operatorfunc pp packpath para paragraphs paste pt pastetoggle pex patchexpr pm 
patchmode pa path perldll pi preserveindent pvh previewheight pvp previewpopup 
pvw previewwindow pdev printdevice penc printencoding pexpr printexpr pfn 
printfont pheader printheader pmbcs printmbcharset pmbfn printmbfont popt 
printoptions prompt ph pumheight skipwhite nextgroup=vimSetEqual,vimSetMod
+syn keyword vimOption contained pmw pummaxwidth pw pumwidth pythondll 
pythonhome pythonthreedll pythonthreehome pyx pyxversion qftf quickfixtextfunc 
qe quoteescape ro readonly rdt redrawtime re regexpengine rnu relativenumber 
remap rop renderoptions report rs restorescreen ri revins rl rightleft rlc 
rightleftcmd rubydll ru ruler ruf rulerformat rtp runtimepath scr scroll scb 
scrollbind scf scrollfocus sj scrolljump so scrolloff sbo scrollopt sect 
sections secure sel selection slm selectmode ssop sessionoptions sh shell shcf 
shellcmdflag sp shellpipe shq shellquote srr shellredir ssl shellslash stmp 
shelltemp st shelltype sxe shellxescape sxq shellxquote sr shiftround sw 
shiftwidth shm shortmess sn shortname sbr showbreak sc showcmd sloc showcmdloc 
sft showfulltag skipwhite nextgroup=vimSetEqual,vimSetMod
+syn keyword vimOption contained sm showmatch smd showmode stal showtabline 
stpl showtabpanel ss sidescroll siso sidescrolloff scl signcolumn scs smartcase 
si smartindent sta smarttab sms smoothscroll sts softtabstop spell spc 
spellcapcheck spf spellfile spl spelllang spo spelloptions sps spellsuggest sb 
splitbelow spk splitkeep spr splitright sol startofline stl statusline su 
suffixes sua suffixesadd swf swapfile sws swapsync swb switchbuf smc synmaxcol 
syn syntax tcl tabclose tal tabline tpm tabpagemax tpl tabpanel tplo 
tabpanelopt ts tabstop tbs tagbsearch tc tagcase tfu tagfunc tl taglength tr 
tagrelative tag tags tgst tagstack tcldll term tbidi termbidi tenc termencoding 
tgc termguicolors twk termwinkey twsl termwinscroll tws termwinsize twt 
termwintype terse skipwhite nextgroup=vimSetEqual,vimSetMod
+syn keyword vimOption contained ta textauto tx textmode tw textwidth tsr 
thesaurus tsrfu thesaurusfunc top tildeop to timeout tm timeoutlen title 
titlelen titleold titlestring tb toolbar tbis toolbariconsize ttimeout ttm 
ttimeoutlen tbi ttybuiltin tf ttyfast ttym ttymouse tsl ttyscroll tty ttytype 
udir undodir udf undofile ul undolevels ur undoreload uc updatecount ut 
updatetime vsts varsofttabstop vts vartabstop vbs verbose vfile verbosefile 
vdir viewdir vop viewoptions vi viminfo vif viminfofile ve virtualedit vb 
visualbell warn wiv weirdinvert ww whichwrap wc wildchar wcm wildcharm wig 
wildignore wic wildignorecase wmnu wildmenu wim wildmode wop wildoptions wak 
winaltkeys wcr wincolor wi window wfb winfixbuf wfh winfixheight wfw 
winfixwidth wh winheight wmh winminheight skipwhite 
nextgroup=vimSetEqual,vimSetMod
 syn keyword vimOption contained wmw winminwidth winptydll wiw winwidth wse 
wlseat wst wlsteal wtm wltimeoutlen wrap wm wrapmargin ws wrapscan write wa 
writeany wb writebackup wd writedelay xtermcodes skipwhite 
nextgroup=vimSetEqual,vimSetMod
 
 " vimOptions: These are the turn-off setting variants {{{2
 " GEN_SYN_VIM: vimOption turn-off, START_STR='syn keyword vimOption 
contained', END_STR=''
-syn keyword vimOption contained noari noallowrevins noarab noarabic noarshape 
noarabicshape noacd noautochdir noai noautoindent noar noautoread noasd 
noautoshelldir noaw noautowrite noawa noautowriteall nobk nobackup nobeval 
noballooneval nobevalterm noballoonevalterm nobin nobinary nobomb nobri 
nobreakindent nobl nobuflisted nocdh nocdhome nocin nocindent nocp nocompatible 
nocf noconfirm noci nocopyindent nocsre nocscoperelative nocst nocscopetag 
nocsverb nocscopeverbose nocrb nocursorbind nocuc nocursorcolumn nocul 
nocursorline nodeco nodelcombine nodiff nodg nodigraph noed noedcompatible 
noemo noemoji noeof noendoffile noeol noendofline noea noequalalways noeb 
noerrorbells noek noesckeys noet noexpandtab noex noexrc nofic nofileignorecase 
nofixeol nofixendofline
-syn keyword vimOption contained nofen nofoldenable nofs nofsync nogd 
nogdefault noguipty nohid nohidden nohk nohkmap nohkp nohkmapp nohls nohlsearch 
noicon noic noignorecase noimc noimcmdline noimd noimdisable nois noincsearch 
noinf noinfercase noim noinsertmode nojs nojoinspaces nolnr nolangnoremap nolrm 
nolangremap nolz nolazyredraw nolbr nolinebreak nolisp nolist nolpl 
noloadplugins nomagic noml nomodeline nomle nomodelineexpr noma nomodifiable 
nomod nomodified nomore nomousef nomousefocus nomh nomousehide nomousemev 
nomousemoveevent nonu nonumber noodev noopendevice nopaste nopi 
nopreserveindent nopvw nopreviewwindow noprompt noro noreadonly nornu 
norelativenumber noremap nors norestorescreen nori norevins norl norightleft 
noru noruler noscb noscrollbind noscf noscrollfocus
-syn keyword vimOption contained nosecure nossl noshellslash nostmp noshelltemp 
nosr noshiftround nosn noshortname nosc noshowcmd nosft noshowfulltag nosm 
noshowmatch nosmd noshowmode noscs nosmartcase nosi nosmartindent nosta 
nosmarttab nosms nosmoothscroll nospell nosb nosplitbelow nospr nosplitright 
nosol nostartofline noswf noswapfile notbs notagbsearch notr notagrelative 
notgst notagstack notbidi notermbidi notgc notermguicolors noterse nota 
notextauto notx notextmode notop notildeop noto notimeout notitle nottimeout 
notbi nottybuiltin notf nottyfast noudf noundofile novb novisualbell nowarn 
nowiv noweirdinvert nowic nowildignorecase nowmnu nowildmenu nowfb nowinfixbuf 
nowfh nowinfixheight nowfw nowinfixwidth nowst nowlsteal nowrap nows nowrapscan 
nowrite
-syn keyword vimOption contained nowa nowriteany nowb nowritebackup noxtermcodes
+syn keyword vimOption contained noari noallowrevins noarab noarabic noarshape 
noarabicshape noacd noautochdir noac noautocomplete noai noautoindent noar 
noautoread noasd noautoshelldir noaw noautowrite noawa noautowriteall nobk 
nobackup nobeval noballooneval nobevalterm noballoonevalterm nobin nobinary 
nobomb nobri nobreakindent nobl nobuflisted nocdh nocdhome nocin nocindent nocp 
nocompatible nocf noconfirm noci nocopyindent nocsre nocscoperelative nocst 
nocscopetag nocsverb nocscopeverbose nocrb nocursorbind nocuc nocursorcolumn 
nocul nocursorline nodeco nodelcombine nodiff nodg nodigraph noed 
noedcompatible noemo noemoji noeof noendoffile noeol noendofline noea 
noequalalways noeb noerrorbells noek noesckeys noet noexpandtab noex noexrc 
nofic nofileignorecase
+syn keyword vimOption contained nofixeol nofixendofline nofen nofoldenable 
nofs nofsync nogd nogdefault noguipty nohid nohidden nohk nohkmap nohkp 
nohkmapp nohls nohlsearch noicon noic noignorecase noimc noimcmdline noimd 
noimdisable nois noincsearch noinf noinfercase noim noinsertmode nojs 
nojoinspaces nolnr nolangnoremap nolrm nolangremap nolz nolazyredraw nolbr 
nolinebreak nolisp nolist nolpl noloadplugins nomagic noml nomodeline nomle 
nomodelineexpr noma nomodifiable nomod nomodified nomore nomousef nomousefocus 
nomh nomousehide nomousemev nomousemoveevent nonu nonumber noodev noopendevice 
nopaste nopi nopreserveindent nopvw nopreviewwindow noprompt noro noreadonly 
nornu norelativenumber noremap nors norestorescreen nori norevins norl 
norightleft noru noruler
+syn keyword vimOption contained noscb noscrollbind noscf noscrollfocus 
nosecure nossl noshellslash nostmp noshelltemp nosr noshiftround nosn 
noshortname nosc noshowcmd nosft noshowfulltag nosm noshowmatch nosmd 
noshowmode noscs nosmartcase nosi nosmartindent nosta nosmarttab nosms 
nosmoothscroll nospell nosb nosplitbelow nospr nosplitright nosol nostartofline 
noswf noswapfile notbs notagbsearch notr notagrelative notgst notagstack 
notbidi notermbidi notgc notermguicolors noterse nota notextauto notx 
notextmode notop notildeop noto notimeout notitle nottimeout notbi nottybuiltin 
notf nottyfast noudf noundofile novb novisualbell nowarn nowiv noweirdinvert 
nowic nowildignorecase nowmnu nowildmenu nowfb nowinfixbuf nowfh nowinfixheight 
nowfw nowinfixwidth nowst nowlsteal
+syn keyword vimOption contained nowrap nows nowrapscan nowrite nowa nowriteany 
nowb nowritebackup noxtermcodes
 
 " vimOptions: These are the invertible variants {{{2
 " GEN_SYN_VIM: vimOption invertible, START_STR='syn keyword vimOption 
contained', END_STR=''
-syn keyword vimOption contained invari invallowrevins invarab invarabic 
invarshape invarabicshape invacd invautochdir invai invautoindent invar 
invautoread invasd invautoshelldir invaw invautowrite invawa invautowriteall 
invbk invbackup invbeval invballooneval invbevalterm invballoonevalterm invbin 
invbinary invbomb invbri invbreakindent invbl invbuflisted invcdh invcdhome 
invcin invcindent invcp invcompatible invcf invconfirm invci invcopyindent 
invcsre invcscoperelative invcst invcscopetag invcsverb invcscopeverbose invcrb 
invcursorbind invcuc invcursorcolumn invcul invcursorline invdeco invdelcombine 
invdiff invdg invdigraph inved invedcompatible invemo invemoji inveof 
invendoffile inveol invendofline invea invequalalways inveb inverrorbells invek 
invesckeys
-syn keyword vimOption contained invet invexpandtab invex invexrc invfic 
invfileignorecase invfixeol invfixendofline invfen invfoldenable invfs invfsync 
invgd invgdefault invguipty invhid invhidden invhk invhkmap invhkp invhkmapp 
invhls invhlsearch invicon invic invignorecase invimc invimcmdline invimd 
invimdisable invis invincsearch invinf invinfercase invim invinsertmode invjs 
invjoinspaces invlnr invlangnoremap invlrm invlangremap invlz invlazyredraw 
invlbr invlinebreak invlisp invlist invlpl invloadplugins invmagic invml 
invmodeline invmle invmodelineexpr invma invmodifiable invmod invmodified 
invmore invmousef invmousefocus invmh invmousehide invmousemev 
invmousemoveevent invnu invnumber invodev invopendevice invpaste invpi 
invpreserveindent invpvw invpreviewwindow
-syn keyword vimOption contained invprompt invro invreadonly invrnu 
invrelativenumber invremap invrs invrestorescreen invri invrevins invrl 
invrightleft invru invruler invscb invscrollbind invscf invscrollfocus 
invsecure invssl invshellslash invstmp invshelltemp invsr invshiftround invsn 
invshortname invsc invshowcmd invsft invshowfulltag invsm invshowmatch invsmd 
invshowmode invscs invsmartcase invsi invsmartindent invsta invsmarttab invsms 
invsmoothscroll invspell invsb invsplitbelow invspr invsplitright invsol 
invstartofline invswf invswapfile invtbs invtagbsearch invtr invtagrelative 
invtgst invtagstack invtbidi invtermbidi invtgc invtermguicolors invterse invta 
invtextauto invtx invtextmode invtop invtildeop invto invtimeout invtitle 
invttimeout invtbi invttybuiltin
-syn keyword vimOption contained invtf invttyfast invudf invundofile invvb 
invvisualbell invwarn invwiv invweirdinvert invwic invwildignorecase invwmnu 
invwildmenu invwfb invwinfixbuf invwfh invwinfixheight invwfw invwinfixwidth 
invwst invwlsteal invwrap invws invwrapscan invwrite invwa invwriteany invwb 
invwritebackup invxtermcodes
+syn keyword vimOption contained invari invallowrevins invarab invarabic 
invarshape invarabicshape invacd invautochdir invac invautocomplete invai 
invautoindent invar invautoread invasd invautoshelldir invaw invautowrite 
invawa invautowriteall invbk invbackup invbeval invballooneval invbevalterm 
invballoonevalterm invbin invbinary invbomb invbri invbreakindent invbl 
invbuflisted invcdh invcdhome invcin invcindent invcp invcompatible invcf 
invconfirm invci invcopyindent invcsre invcscoperelative invcst invcscopetag 
invcsverb invcscopeverbose invcrb invcursorbind invcuc invcursorcolumn invcul 
invcursorline invdeco invdelcombine invdiff invdg invdigraph inved 
invedcompatible invemo invemoji inveof invendoffile inveol invendofline invea 
invequalalways inveb inverrorbells
+syn keyword vimOption contained invek invesckeys invet invexpandtab invex 
invexrc invfic invfileignorecase invfixeol invfixendofline invfen invfoldenable 
invfs invfsync invgd invgdefault invguipty invhid invhidden invhk invhkmap 
invhkp invhkmapp invhls invhlsearch invicon invic invignorecase invimc 
invimcmdline invimd invimdisable invis invincsearch invinf invinfercase invim 
invinsertmode invjs invjoinspaces invlnr invlangnoremap invlrm invlangremap 
invlz invlazyredraw invlbr invlinebreak invlisp invlist invlpl invloadplugins 
invmagic invml invmodeline invmle invmodelineexpr invma invmodifiable invmod 
invmodified invmore invmousef invmousefocus invmh invmousehide invmousemev 
invmousemoveevent invnu invnumber invodev invopendevice invpaste invpi 
invpreserveindent
+syn keyword vimOption contained invpvw invpreviewwindow invprompt invro 
invreadonly invrnu invrelativenumber invremap invrs invrestorescreen invri 
invrevins invrl invrightleft invru invruler invscb invscrollbind invscf 
invscrollfocus invsecure invssl invshellslash invstmp invshelltemp invsr 
invshiftround invsn invshortname invsc invshowcmd invsft invshowfulltag invsm 
invshowmatch invsmd invshowmode invscs invsmartcase invsi invsmartindent invsta 
invsmarttab invsms invsmoothscroll invspell invsb invsplitbelow invspr 
invsplitright invsol invstartofline invswf invswapfile invtbs invtagbsearch 
invtr invtagrelative invtgst invtagstack invtbidi invtermbidi invtgc 
invtermguicolors invterse invta invtextauto invtx invtextmode invtop invtildeop 
invto invtimeout invtitle
+syn keyword vimOption contained invttimeout invtbi invttybuiltin invtf 
invttyfast invudf invundofile invvb invvisualbell invwarn invwiv invweirdinvert 
invwic invwildignorecase invwmnu invwildmenu invwfb invwinfixbuf invwfh 
invwinfixheight invwfw invwinfixwidth invwst invwlsteal invwrap invws 
invwrapscan invwrite invwa invwriteany invwb invwritebackup invxtermcodes
 " termcap codes (which can also be set) {{{2
 " GEN_SYN_VIM: vimOption term output code, START_STR='syn keyword vimOption 
contained', END_STR='skipwhite nextgroup=vimSetEqual,vimSetMod'
 syn keyword vimOption contained t_AB t_AF t_AU t_AL t_al t_bc t_BE t_BD t_cd 
t_ce t_Ce t_CF t_cl t_cm t_Co t_CS t_Cs t_cs t_CV t_da t_db t_DL t_dl t_ds t_Ds 
t_EC t_EI t_fs t_fd t_fe t_GP t_IE t_IS t_ke t_ks t_le t_mb t_md t_me t_mr t_ms 
t_nd t_op t_RF t_RB t_RC t_RI t_Ri t_RK t_RS t_RT t_RV t_Sb t_SC t_se t_Sf t_SH 
t_SI t_Si t_so t_SR t_sr t_ST t_Te t_te t_TE t_ti t_TI t_Ts t_ts t_u7 t_ue t_us 
t_Us t_ut t_vb t_ve t_vi t_VS t_vs t_WP t_WS t_XM t_xn t_xs t_ZH t_ZR t_8f t_8b 
t_8u t_xo skipwhite nextgroup=vimSetEqual,vimSetMod
@@ -102,15 +102,15 @@ syn match   vimOption contained   "t_k;"
 
 " vimOptions: These are the variable names {{{2
 " GEN_SYN_VIM: vimOption normal variable,           START_STR='syn keyword 
vimOptionVarName contained', END_STR=''
-syn keyword vimOptionVarName contained al aleph ari allowrevins ambw ambiwidth 
arab arabic arshape arabicshape acd autochdir ai autoindent ar autoread asd 
autoshelldir aw autowrite awa autowriteall bg background bs backspace bk backup 
bkc backupcopy bdir backupdir bex backupext bsk backupskip bdlay balloondelay 
beval ballooneval bevalterm balloonevalterm bexpr balloonexpr bo belloff bin 
binary bomb brk breakat bri breakindent briopt breakindentopt bsdir browsedir 
bh bufhidden bl buflisted bt buftype cmp casemap cdh cdhome cd cdpath cedit ccv 
charconvert chi chistory cin cindent cink cinkeys cino cinoptions cinsd 
cinscopedecls cinw cinwords cb clipboard cpm clipmethod ch cmdheight cwh 
cmdwinheight cc colorcolumn co columns com comments cms commentstring cp 
compatible
-syn keyword vimOptionVarName contained cpt complete cfu completefunc cfc 
completefuzzycollect cia completeitemalign cot completeopt cpp completepopup 
csl completeslash cocu concealcursor cole conceallevel cf confirm ci copyindent 
cpo cpoptions cm cryptmethod cspc cscopepathcomp csprg cscopeprg csqf 
cscopequickfix csre cscoperelative cst cscopetag csto cscopetagorder csverb 
cscopeverbose crb cursorbind cuc cursorcolumn cul cursorline culopt 
cursorlineopt debug def define deco delcombine dict dictionary diff dia 
diffanchors dex diffexpr dip diffopt dg digraph dir directory dy display ead 
eadirection ed edcompatible emo emoji enc encoding eof endoffile eol endofline 
ea equalalways ep equalprg eb errorbells ef errorfile efm errorformat ek 
esckeys ei eventignore eiw eventignorewin
-syn keyword vimOptionVarName contained et expandtab ex exrc fenc fileencoding 
fencs fileencodings ff fileformat ffs fileformats fic fileignorecase ft 
filetype fcs fillchars ffu findfunc fixeol fixendofline fcl foldclose fdc 
foldcolumn fen foldenable fde foldexpr fdi foldignore fdl foldlevel fdls 
foldlevelstart fmr foldmarker fdm foldmethod fml foldminlines fdn foldnestmax 
fdo foldopen fdt foldtext fex formatexpr flp formatlistpat fo formatoptions fp 
formatprg fs fsync gd gdefault gfm grepformat gp grepprg gcr guicursor gfn 
guifont gfs guifontset gfw guifontwide ghr guiheadroom gli guiligatures go 
guioptions guipty gtl guitablabel gtt guitabtooltip hf helpfile hh helpheight 
hlg helplang hid hidden hl highlight hi history hk hkmap hkp hkmapp hls 
hlsearch icon iconstring
-syn keyword vimOptionVarName contained ic ignorecase imaf imactivatefunc imak 
imactivatekey imc imcmdline imd imdisable imi iminsert ims imsearch imsf 
imstatusfunc imst imstyle inc include inex includeexpr is incsearch inde 
indentexpr indk indentkeys inf infercase im insertmode ise isexpand isf isfname 
isi isident isk iskeyword isp isprint js joinspaces jop jumpoptions key kmp 
keymap km keymodel kpc keyprotocol kp keywordprg lmap langmap lm langmenu lnr 
langnoremap lrm langremap ls laststatus lz lazyredraw lhi lhistory lbr 
linebreak lines lsp linespace lisp lop lispoptions lw lispwords list lcs 
listchars lpl loadplugins luadll magic mef makeef menc makeencoding mp makeprg 
mps matchpairs mat matchtime mco maxcombine mfd maxfuncdepth mmd maxmapdepth mm 
maxmem mmp maxmempattern
-syn keyword vimOptionVarName contained mmt maxmemtot msc maxsearchcount mis 
menuitems mopt messagesopt msm mkspellmem ml modeline mle modelineexpr mls 
modelines ma modifiable mod modified more mouse mousef mousefocus mh mousehide 
mousem mousemodel mousemev mousemoveevent mouses mouseshape mouset mousetime 
mzq mzquantum mzschemedll mzschemegcdll nf nrformats nu number nuw numberwidth 
ofu omnifunc odev opendevice opfunc operatorfunc pp packpath para paragraphs 
paste pt pastetoggle pex patchexpr pm patchmode pa path perldll pi 
preserveindent pvh previewheight pvp previewpopup pvw previewwindow pdev 
printdevice penc printencoding pexpr printexpr pfn printfont pheader 
printheader pmbcs printmbcharset pmbfn printmbfont popt printoptions prompt ph 
pumheight pmw pummaxwidth
-syn keyword vimOptionVarName contained pw pumwidth pythondll pythonhome 
pythonthreedll pythonthreehome pyx pyxversion qftf quickfixtextfunc qe 
quoteescape ro readonly rdt redrawtime re regexpengine rnu relativenumber remap 
rop renderoptions report rs restorescreen ri revins rl rightleft rlc 
rightleftcmd rubydll ru ruler ruf rulerformat rtp runtimepath scr scroll scb 
scrollbind scf scrollfocus sj scrolljump so scrolloff sbo scrollopt sect 
sections secure sel selection slm selectmode ssop sessionoptions sh shell shcf 
shellcmdflag sp shellpipe shq shellquote srr shellredir ssl shellslash stmp 
shelltemp st shelltype sxe shellxescape sxq shellxquote sr shiftround sw 
shiftwidth shm shortmess sn shortname sbr showbreak sc showcmd sloc showcmdloc 
sft showfulltag sm showmatch
-syn keyword vimOptionVarName contained smd showmode stal showtabline stpl 
showtabpanel ss sidescroll siso sidescrolloff scl signcolumn scs smartcase si 
smartindent sta smarttab sms smoothscroll sts softtabstop spell spc 
spellcapcheck spf spellfile spl spelllang spo spelloptions sps spellsuggest sb 
splitbelow spk splitkeep spr splitright sol startofline stl statusline su 
suffixes sua suffixesadd swf swapfile sws swapsync swb switchbuf smc synmaxcol 
syn syntax tcl tabclose tal tabline tpm tabpagemax tpl tabpanel tplo 
tabpanelopt ts tabstop tbs tagbsearch tc tagcase tfu tagfunc tl taglength tr 
tagrelative tag tags tgst tagstack tcldll term tbidi termbidi tenc termencoding 
tgc termguicolors twk termwinkey twsl termwinscroll tws termwinsize twt 
termwintype terse ta textauto
-syn keyword vimOptionVarName contained tx textmode tw textwidth tsr thesaurus 
tsrfu thesaurusfunc top tildeop to timeout tm timeoutlen title titlelen 
titleold titlestring tb toolbar tbis toolbariconsize ttimeout ttm ttimeoutlen 
tbi ttybuiltin tf ttyfast ttym ttymouse tsl ttyscroll tty ttytype udir undodir 
udf undofile ul undolevels ur undoreload uc updatecount ut updatetime vsts 
varsofttabstop vts vartabstop vbs verbose vfile verbosefile vdir viewdir vop 
viewoptions vi viminfo vif viminfofile ve virtualedit vb visualbell warn wiv 
weirdinvert ww whichwrap wc wildchar wcm wildcharm wig wildignore wic 
wildignorecase wmnu wildmenu wim wildmode wop wildoptions wak winaltkeys wcr 
wincolor wi window wfb winfixbuf wfh winfixheight wfw winfixwidth wh winheight 
wmh winminheight
-syn keyword vimOptionVarName contained wmw winminwidth winptydll wiw winwidth 
wse wlseat wst wlsteal wtm wltimeoutlen wrap wm wrapmargin ws wrapscan write wa 
writeany wb writebackup wd writedelay xtermcodes
+syn keyword vimOptionVarName contained al aleph ari allowrevins ambw ambiwidth 
arab arabic arshape arabicshape acd autochdir ac autocomplete ai autoindent ar 
autoread asd autoshelldir aw autowrite awa autowriteall bg background bs 
backspace bk backup bkc backupcopy bdir backupdir bex backupext bsk backupskip 
bdlay balloondelay beval ballooneval bevalterm balloonevalterm bexpr 
balloonexpr bo belloff bin binary bomb brk breakat bri breakindent briopt 
breakindentopt bsdir browsedir bh bufhidden bl buflisted bt buftype cmp casemap 
cdh cdhome cd cdpath cedit ccv charconvert chi chistory cin cindent cink 
cinkeys cino cinoptions cinsd cinscopedecls cinw cinwords cb clipboard cpm 
clipmethod ch cmdheight cwh cmdwinheight cc colorcolumn co columns com comments 
cms commentstring
+syn keyword vimOptionVarName contained cp compatible cpt complete cfu 
completefunc cfc completefuzzycollect cia completeitemalign cot completeopt cpp 
completepopup csl completeslash cocu concealcursor cole conceallevel cf confirm 
ci copyindent cpo cpoptions cm cryptmethod cspc cscopepathcomp csprg cscopeprg 
csqf cscopequickfix csre cscoperelative cst cscopetag csto cscopetagorder 
csverb cscopeverbose crb cursorbind cuc cursorcolumn cul cursorline culopt 
cursorlineopt debug def define deco delcombine dict dictionary diff dia 
diffanchors dex diffexpr dip diffopt dg digraph dir directory dy display ead 
eadirection ed edcompatible emo emoji enc encoding eof endoffile eol endofline 
ea equalalways ep equalprg eb errorbells ef errorfile efm errorformat ek 
esckeys ei eventignore
+syn keyword vimOptionVarName contained eiw eventignorewin et expandtab ex exrc 
fenc fileencoding fencs fileencodings ff fileformat ffs fileformats fic 
fileignorecase ft filetype fcs fillchars ffu findfunc fixeol fixendofline fcl 
foldclose fdc foldcolumn fen foldenable fde foldexpr fdi foldignore fdl 
foldlevel fdls foldlevelstart fmr foldmarker fdm foldmethod fml foldminlines 
fdn foldnestmax fdo foldopen fdt foldtext fex formatexpr flp formatlistpat fo 
formatoptions fp formatprg fs fsync gd gdefault gfm grepformat gp grepprg gcr 
guicursor gfn guifont gfs guifontset gfw guifontwide ghr guiheadroom gli 
guiligatures go guioptions guipty gtl guitablabel gtt guitabtooltip hf helpfile 
hh helpheight hlg helplang hid hidden hl highlight hi history hk hkmap hkp 
hkmapp hls hlsearch
+syn keyword vimOptionVarName contained icon iconstring ic ignorecase imaf 
imactivatefunc imak imactivatekey imc imcmdline imd imdisable imi iminsert ims 
imsearch imsf imstatusfunc imst imstyle inc include inex includeexpr is 
incsearch inde indentexpr indk indentkeys inf infercase im insertmode ise 
isexpand isf isfname isi isident isk iskeyword isp isprint js joinspaces jop 
jumpoptions key kmp keymap km keymodel kpc keyprotocol kp keywordprg lmap 
langmap lm langmenu lnr langnoremap lrm langremap ls laststatus lz lazyredraw 
lhi lhistory lbr linebreak lines lsp linespace lisp lop lispoptions lw 
lispwords list lcs listchars lpl loadplugins luadll magic mef makeef menc 
makeencoding mp makeprg mps matchpairs mat matchtime mco maxcombine mfd 
maxfuncdepth mmd maxmapdepth
+syn keyword vimOptionVarName contained mm maxmem mmp maxmempattern mmt 
maxmemtot msc maxsearchcount mis menuitems mopt messagesopt msm mkspellmem ml 
modeline mle modelineexpr mls modelines ma modifiable mod modified more mouse 
mousef mousefocus mh mousehide mousem mousemodel mousemev mousemoveevent mouses 
mouseshape mouset mousetime mzq mzquantum mzschemedll mzschemegcdll nf 
nrformats nu number nuw numberwidth ofu omnifunc odev opendevice opfunc 
operatorfunc pp packpath para paragraphs paste pt pastetoggle pex patchexpr pm 
patchmode pa path perldll pi preserveindent pvh previewheight pvp previewpopup 
pvw previewwindow pdev printdevice penc printencoding pexpr printexpr pfn 
printfont pheader printheader pmbcs printmbcharset pmbfn printmbfont popt 
printoptions prompt
+syn keyword vimOptionVarName contained ph pumheight pmw pummaxwidth pw 
pumwidth pythondll pythonhome pythonthreedll pythonthreehome pyx pyxversion 
qftf quickfixtextfunc qe quoteescape ro readonly rdt redrawtime re regexpengine 
rnu relativenumber remap rop renderoptions report rs restorescreen ri revins rl 
rightleft rlc rightleftcmd rubydll ru ruler ruf rulerformat rtp runtimepath scr 
scroll scb scrollbind scf scrollfocus sj scrolljump so scrolloff sbo scrollopt 
sect sections secure sel selection slm selectmode ssop sessionoptions sh shell 
shcf shellcmdflag sp shellpipe shq shellquote srr shellredir ssl shellslash 
stmp shelltemp st shelltype sxe shellxescape sxq shellxquote sr shiftround sw 
shiftwidth shm shortmess sn shortname sbr showbreak sc showcmd sloc showcmdloc
+syn keyword vimOptionVarName contained sft showfulltag sm showmatch smd 
showmode stal showtabline stpl showtabpanel ss sidescroll siso sidescrolloff 
scl signcolumn scs smartcase si smartindent sta smarttab sms smoothscroll sts 
softtabstop spell spc spellcapcheck spf spellfile spl spelllang spo 
spelloptions sps spellsuggest sb splitbelow spk splitkeep spr splitright sol 
startofline stl statusline su suffixes sua suffixesadd swf swapfile sws 
swapsync swb switchbuf smc synmaxcol syn syntax tcl tabclose tal tabline tpm 
tabpagemax tpl tabpanel tplo tabpanelopt ts tabstop tbs tagbsearch tc tagcase 
tfu tagfunc tl taglength tr tagrelative tag tags tgst tagstack tcldll term 
tbidi termbidi tenc termencoding tgc termguicolors twk termwinkey twsl 
termwinscroll tws termwinsize
+syn keyword vimOptionVarName contained twt termwintype terse ta textauto tx 
textmode tw textwidth tsr thesaurus tsrfu thesaurusfunc top tildeop to timeout 
tm timeoutlen title titlelen titleold titlestring tb toolbar tbis 
toolbariconsize ttimeout ttm ttimeoutlen tbi ttybuiltin tf ttyfast ttym 
ttymouse tsl ttyscroll tty ttytype udir undodir udf undofile ul undolevels ur 
undoreload uc updatecount ut updatetime vsts varsofttabstop vts vartabstop vbs 
verbose vfile verbosefile vdir viewdir vop viewoptions vi viminfo vif 
viminfofile ve virtualedit vb visualbell warn wiv weirdinvert ww whichwrap wc 
wildchar wcm wildcharm wig wildignore wic wildignorecase wmnu wildmenu wim 
wildmode wop wildoptions wak winaltkeys wcr wincolor wi window wfb winfixbuf 
wfh winfixheight wfw winfixwidth
+syn keyword vimOptionVarName contained wh winheight wmh winminheight wmw 
winminwidth winptydll wiw winwidth wse wlseat wst wlsteal wtm wltimeoutlen wrap 
wm wrapmargin ws wrapscan write wa writeany wb writebackup wd writedelay 
xtermcodes
 " GEN_SYN_VIM: vimOption term output code variable, START_STR='syn keyword 
vimOptionVarName contained', END_STR=''
 syn keyword vimOptionVarName contained t_AB t_AF t_AU t_AL t_al t_bc t_BE t_BD 
t_cd t_ce t_Ce t_CF t_cl t_cm t_Co t_CS t_Cs t_cs t_CV t_da t_db t_DL t_dl t_ds 
t_Ds t_EC t_EI t_fs t_fd t_fe t_GP t_IE t_IS t_ke t_ks t_le t_mb t_md t_me t_mr 
t_ms t_nd t_op t_RF t_RB t_RC t_RI t_Ri t_RK t_RS t_RT t_RV t_Sb t_SC t_se t_Sf 
t_SH t_SI t_Si t_so t_SR t_sr t_ST t_Te t_te t_TE t_ti t_TI t_Ts t_ts t_u7 t_ue 
t_us t_Us t_ut t_vb t_ve t_vi t_VS t_vs t_WP t_WS t_XM t_xn t_xs t_ZH t_ZR t_8f 
t_8b t_8u t_xo
 syn keyword vimOptionVarName contained t_F1 t_F2 t_F3 t_F4 t_F5 t_F6 t_F7 t_F8 
t_F9 t_k1 t_K1 t_k2 t_k3 t_K3 t_k4 t_K4 t_k5 t_K5 t_k6 t_K6 t_k7 t_K7 t_k8 t_K8 
t_k9 t_K9 t_KA t_kb t_kB t_KB t_KC t_kd t_kD t_KD t_KE t_KF t_KG t_kh t_KH t_kI 
t_KI t_KJ t_KK t_kl t_KL t_kN t_kP t_kr t_ku
diff --git a/src/edit.c b/src/edit.c
index 97e4224c0..5974f244a 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -983,6 +983,17 @@ doESCkey:
        case Ctrl_H:
            did_backspace = ins_bs(c, BACKSPACE_CHAR, &inserted_space);
            auto_format(FALSE, TRUE);
+           if (did_backspace && p_ac && !char_avail()
+                   && curwin->w_cursor.col > 0)
+           {
+               c = char_before_cursor();
+               if (ins_compl_setup_autocompl(c))
+               {
+                   update_screen(UPD_VALID); // Show char deletion immediately
+                   out_flush();
+                   goto docomplete; // Trigger autocompletion
+               }
+           }
            break;
 
        case Ctrl_W:    // delete word before the cursor
@@ -1401,6 +1412,14 @@ normalchar:
            // closed fold.
            foldOpenCursor();
 #endif
+           // Trigger autocompletion
+           if (p_ac && !char_avail() && ins_compl_setup_autocompl(c))
+           {
+               update_screen(UPD_VALID); // Show character immediately
+               out_flush();
+               goto docomplete;
+           }
+
            break;
        }   // end of switch (c)
 
@@ -2233,6 +2252,10 @@ insertchar(
     if (       !ISSPECIAL(c)
            && (!has_mbyte || (*mb_char2len)(c) == 1)
            && !has_insertcharpre()
+#ifdef FEAT_EVAL
+           // Skip typeahead if test_override("char_avail", 1) was called.
+           && !disable_char_avail_for_testing
+#endif
            && vpeekc() != NUL
            && !(State & REPLACE_FLAG)
            && !cindent_on()
diff --git a/src/insexpand.c b/src/insexpand.c
index a5d86e1e7..160020224 100644
--- a/src/insexpand.c
+++ b/src/insexpand.c
@@ -198,6 +198,24 @@ static expand_T      compl_xp;
 static win_T     *compl_curr_win = NULL;  // win where completion is active
 static buf_T     *compl_curr_buf = NULL;  // buf where completion is active
 
+#define COMPL_INITIAL_TIMEOUT_MS    80
+// Autocomplete uses a decaying timeout: starting from 
COMPL_INITIAL_TIMEOUT_MS,
+// if the current source exceeds its timeout, it is interrupted and the next
+// begins with half the time. A small minimum timeout ensures every source
+// gets at least a brief chance.
+static int       compl_autocomplete = FALSE;       // whether autocompletion 
is active
+static int       compl_timeout_ms = COMPL_INITIAL_TIMEOUT_MS;
+static int       compl_time_slice_expired = FALSE; // time budget exceeded for 
current source
+static int       compl_from_nonkeyword = FALSE;    // completion started from 
non-keyword
+
+// Halve the current completion timeout, simulating exponential decay.
+#define COMPL_MIN_TIMEOUT_MS   5
+#define DECAY_COMPL_TIMEOUT() \
+    do { \
+       if (compl_timeout_ms > COMPL_MIN_TIMEOUT_MS) \
+           compl_timeout_ms /= 2; \
+    } while (0)
+
 // List of flags for method of completion.
 static int       compl_cont_status = 0;
 # define CONT_ADDING   1       // "normal" or "adding" expansion
@@ -224,6 +242,9 @@ typedef struct cpt_source_T
     int        cs_refresh_always;  // Whether 'refresh:always' is set for func
     int        cs_startcol;        // Start column returned by func
     int        cs_max_matches;     // Max items to display from this source
+#ifdef ELAPSED_FUNC
+    elapsed_T  compl_start_tv;     // Timestamp when match collection starts
+#endif
 } cpt_source_T;
 
 #define STARTCOL_NONE  -9
@@ -283,7 +304,7 @@ ins_ctrl_x(void)
     if (!ctrl_x_mode_cmdline())
     {
        // if the next ^X<> won't ADD nothing, then reset compl_cont_status
-       if (compl_cont_status & CONT_N_ADDS)
+       if ((compl_cont_status & CONT_N_ADDS) && !p_ac)
            compl_cont_status |= CONT_INTRPT;
        else
            compl_cont_status = 0;
@@ -553,6 +574,9 @@ is_first_match(compl_T *match)
     int
 ins_compl_accept_char(int c)
 {
+    if (compl_autocomplete && compl_from_nonkeyword)
+       return FALSE;
+
     if (ctrl_x_mode & CTRL_X_WANT_IDENT)
        // When expanding an identifier only accept identifier chars.
        return vim_isIDc(c);
@@ -816,7 +840,9 @@ cfc_has_mode(void)
     static int
 is_nearest_active(void)
 {
-    return (get_cot_flags() & (COT_NEAREST | COT_FUZZY)) == COT_NEAREST;
+    int flags = get_cot_flags();
+    return (compl_autocomplete || (flags & COT_NEAREST))
+       && !(flags & COT_FUZZY);
 }
 
 /*
@@ -1268,7 +1294,7 @@ ins_compl_del_pum(void)
 pum_wanted(void)
 {
     // 'completeopt' must contain "menu" or "menuone"
-    if ((get_cot_flags() & COT_ANY_MENU) == 0)
+    if ((get_cot_flags() & COT_ANY_MENU) == 0 && !compl_autocomplete)
        return FALSE;
 
     // The display looks bad on a B&W display.
@@ -1301,7 +1327,7 @@ pum_enough_matches(void)
        compl = compl->cp_next;
     } while (!is_first_match(compl));
 
-    if (get_cot_flags() & COT_MENUONE)
+    if ((get_cot_flags() & COT_MENUONE) || compl_autocomplete)
        return (i >= 1);
     return (i >= 2);
 }
@@ -1552,7 +1578,8 @@ ins_compl_build_pum(void)
     int                i = 0;
     int                cur = -1;
     unsigned int cur_cot_flags = get_cot_flags();
-    int                compl_no_select = (cur_cot_flags & COT_NOSELECT) != 0;
+    int                compl_no_select = (cur_cot_flags & COT_NOSELECT) != 0
+                               || compl_autocomplete;
     int                fuzzy_filter = (cur_cot_flags & COT_FUZZY) != 0;
     compl_T    *match_head = NULL;
     compl_T    *match_tail = NULL;
@@ -2016,10 +2043,12 @@ ins_compl_files(
        leader_len = (int)ins_compl_leader_len();
     }
 
-    for (i = 0; i < count && !got_int && !compl_interrupted; i++)
+    for (i = 0; i < count && !got_int && !compl_interrupted
+           && !compl_time_slice_expired; i++)
     {
        fp = mch_fopen((char *)files[i], "r");  // open dictionary file
-       if (flags != DICT_EXACT && !shortmess(SHM_COMPLETIONSCAN))
+       if (flags != DICT_EXACT && !shortmess(SHM_COMPLETIONSCAN)
+               && !compl_autocomplete)
        {
            msg_hist_off = TRUE;        // reset in msg_trunc_attr()
            vim_snprintf((char *)IObuff, IOSIZE,
@@ -2032,7 +2061,8 @@ ins_compl_files(
 
        // Read dictionary file line by line.
        // Check each line for a match.
-       while (!got_int && !compl_interrupted && !vim_fgets(buf, LSIZE, fp))
+       while (!got_int && !compl_interrupted && !compl_time_slice_expired
+              && !vim_fgets(buf, LSIZE, fp))
        {
            ptr = buf;
            if (regmatch != NULL)
@@ -2215,6 +2245,9 @@ ins_compl_clear(void)
     VIM_CLEAR_STRING(compl_orig_text);
     compl_enter_selects = FALSE;
     cpt_sources_clear();
+    compl_autocomplete = FALSE;
+    compl_from_nonkeyword = FALSE;
+    compl_num_bests = 0;
 #ifdef FEAT_EVAL
     // clear v:completed_item
     set_vim_var_dict(VV_COMPLETED_ITEM, dict_alloc_lock(VAR_FIXED));
@@ -2305,7 +2338,7 @@ ins_compl_has_preinsert(void)
 {
     int cur_cot_flags = get_cot_flags();
     return (cur_cot_flags & (COT_PREINSERT | COT_FUZZY | COT_MENUONE))
-       == (COT_PREINSERT | COT_MENUONE);
+       == (COT_PREINSERT | COT_MENUONE) && !compl_autocomplete;
 }
 
 /*
@@ -2429,6 +2462,8 @@ ins_compl_new_leader(void)
        save_w_wrow = curwin->w_wrow;
        save_w_leftcol = curwin->w_leftcol;
        compl_restarting = TRUE;
+       if (p_ac)
+           compl_autocomplete = TRUE;
        if (ins_complete(Ctrl_N, FALSE) == FAIL)
            compl_cont_status = 0;
        compl_restarting = FALSE;
@@ -2543,6 +2578,9 @@ ins_compl_restart(void)
     compl_cont_status = 0;
     compl_cont_mode = 0;
     cpt_sources_clear();
+    compl_autocomplete = FALSE;
+    compl_from_nonkeyword = FALSE;
+    compl_num_bests = 0;
 }
 
 /*
@@ -2903,6 +2941,9 @@ ins_compl_stop(int c, int prev_mode, int retval)
        edit_submode = NULL;
        showmode();
     }
+    compl_autocomplete = FALSE;
+    compl_from_nonkeyword = FALSE;
+    compl_best_matches = 0;
 
     if (c == Ctrl_C && cmdwin_type != 0)
        // Avoid the popup menu remains displayed when leaving the
@@ -3637,7 +3678,10 @@ f_complete_check(typval_T *argvars UNUSED, typval_T 
*rettv)
     RedrawingDisabled = 0;
 
     ins_compl_check_keys(0, TRUE);
-    rettv->vval.v_number = ins_compl_interrupted();
+    if (compl_autocomplete && compl_time_slice_expired)
+       rettv->vval.v_number = TRUE;
+    else
+       rettv->vval.v_number = ins_compl_interrupted();
 
     RedrawingDisabled = save_RedrawingDisabled;
 }
@@ -4111,6 +4155,7 @@ process_next_cpt_value(
 {
     int            compl_type = -1;
     int            status = INS_COMPL_CPT_OK;
+    int            skip_source = compl_autocomplete && compl_from_nonkeyword;
 
     st->found_all = FALSE;
     *advance_cpt_idx = FALSE;
@@ -4118,7 +4163,8 @@ process_next_cpt_value(
     while (*st->e_cpt == ',' || *st->e_cpt == ' ')
        st->e_cpt++;
 
-    if (*st->e_cpt == '.' && !curbuf->b_scanned)
+    if (*st->e_cpt == '.' && !curbuf->b_scanned && !skip_source
+           && !compl_time_slice_expired)
     {
        st->ins_buf = curbuf;
        st->first_match_pos = *start_match_pos;
@@ -4139,7 +4185,8 @@ process_next_cpt_value(
        // wrap and come back there a second time.
        st->set_match_pos = TRUE;
     }
-    else if (vim_strchr((char_u *)"buwU", *st->e_cpt) != NULL
+    else if (!skip_source && !compl_time_slice_expired
+           && vim_strchr((char_u *)"buwU", *st->e_cpt) != NULL
            && (st->ins_buf = ins_compl_next_buf(
                                           st->ins_buf, *st->e_cpt)) != curbuf)
     {
@@ -4164,7 +4211,7 @@ process_next_cpt_value(
            st->dict = st->ins_buf->b_fname;
            st->dict_f = DICT_EXACT;
        }
-       if (!shortmess(SHM_COMPLETIONSCAN))
+       if (!shortmess(SHM_COMPLETIONSCAN) && !compl_autocomplete)
        {
            msg_hist_off = TRUE;        // reset in msg_trunc_attr()
            vim_snprintf((char *)IObuff, IOSIZE, _("Scanning: %s"),
@@ -4182,18 +4229,6 @@ process_next_cpt_value(
     {
        if (ctrl_x_mode_line_or_eval())
            compl_type = -1;
-       else if (*st->e_cpt == 'k' || *st->e_cpt == 's')
-       {
-           if (*st->e_cpt == 'k')
-               compl_type = CTRL_X_DICTIONARY;
-           else
-               compl_type = CTRL_X_THESAURUS;
-           if (*++st->e_cpt != ',' && *st->e_cpt != NUL)
-           {
-               st->dict = st->e_cpt;
-               st->dict_f = DICT_FIRST;
-           }
-       }
 #ifdef FEAT_COMPL_FUNC
        else if (*st->e_cpt == 'F' || *st->e_cpt == 'o')
        {
@@ -4203,24 +4238,39 @@ process_next_cpt_value(
                compl_type = -1;
        }
 #endif
+       else if (!skip_source)
+       {
+           if (*st->e_cpt == 'k' || *st->e_cpt == 's')
+           {
+               if (*st->e_cpt == 'k')
+                   compl_type = CTRL_X_DICTIONARY;
+               else
+                   compl_type = CTRL_X_THESAURUS;
+               if (*++st->e_cpt != ',' && *st->e_cpt != NUL)
+               {
+                   st->dict = st->e_cpt;
+                   st->dict_f = DICT_FIRST;
+               }
+           }
 #ifdef FEAT_FIND_ID
-       else if (*st->e_cpt == 'i')
-           compl_type = CTRL_X_PATH_PATTERNS;
-       else if (*st->e_cpt == 'd')
-           compl_type = CTRL_X_PATH_DEFINES;
+           else if (*st->e_cpt == 'i')
+               compl_type = CTRL_X_PATH_PATTERNS;
+           else if (*st->e_cpt == 'd')
+               compl_type = CTRL_X_PATH_DEFINES;
 #endif
-       else if (*st->e_cpt == ']' || *st->e_cpt == 't')
-       {
-           compl_type = CTRL_X_TAGS;
-           if (!shortmess(SHM_COMPLETIONSCAN))
+           else if (*st->e_cpt == ']' || *st->e_cpt == 't')
            {
-               msg_hist_off = TRUE;    // reset in msg_trunc_attr()
-               vim_snprintf((char *)IObuff, IOSIZE, _("Scanning tags."));
-               (void)msg_trunc_attr((char *)IObuff, TRUE, HL_ATTR(HLF_R));
+               compl_type = CTRL_X_TAGS;
+               if (!shortmess(SHM_COMPLETIONSCAN) && !compl_autocomplete)
+               {
+                   msg_hist_off = TRUE;        // reset in msg_trunc_attr()
+                   vim_snprintf((char *)IObuff, IOSIZE, _("Scanning tags."));
+                   (void)msg_trunc_attr((char *)IObuff, TRUE, HL_ATTR(HLF_R));
+               }
            }
+           else
+               compl_type = -1;
        }
-       else
-           compl_type = -1;
 
        // in any case e_cpt is advanced to the next entry
        (void)copy_option_part(&st->e_cpt, IObuff, IOSIZE, ",");
@@ -4747,7 +4797,8 @@ get_next_default_completion(ins_compl_next_state_T *st, 
pos_T *start_pos)
     int                looped_around = FALSE;
     char_u     *ptr = NULL;
     int                len = 0;
-    int                in_collect = (cfc_has_mode() && compl_length > 0);
+    int                in_fuzzy_collect = (cfc_has_mode() && compl_length > 0)
+       || ((get_cot_flags() & COT_FUZZY) && compl_autocomplete);
     char_u     *leader = ins_compl_leader();
     int                score = 0;
     int                in_curbuf = st->ins_buf == curbuf;
@@ -4773,7 +4824,7 @@ get_next_default_completion(ins_compl_next_state_T *st, 
pos_T *start_pos)
 
        ++msg_silent;  // Don't want messages for wrapscan.
 
-       if (in_collect)
+       if (in_fuzzy_collect)
        {
            found_new_match = search_for_fuzzy_match(st->ins_buf,
                            st->cur_match_pos, leader, compl_direction,
@@ -4832,7 +4883,7 @@ get_next_default_completion(ins_compl_next_state_T *st, 
pos_T *start_pos)
                && start_pos->col  == st->cur_match_pos->col)
            continue;
 
-       if (!in_collect)
+       if (!in_fuzzy_collect)
            ptr = ins_compl_get_next_word_or_line(st->ins_buf, 
st->cur_match_pos,
                                                               &len, 
&cont_s_ipos);
        if (ptr == NULL || (ins_compl_has_preinsert() && STRCMP(ptr, 
compl_pattern.string) == 0))
@@ -4850,7 +4901,7 @@ get_next_default_completion(ins_compl_next_state_T *st, 
pos_T *start_pos)
                        in_curbuf ? NULL : st->ins_buf->b_sfname,
                        0, cont_s_ipos, score) != NOTDONE)
        {
-           if (in_collect && score == compl_first_match->cp_next->cp_score)
+           if (in_fuzzy_collect && score == 
compl_first_match->cp_next->cp_score)
                compl_num_bests++;
            found_new_match = OK;
            break;
@@ -5171,6 +5222,21 @@ prepare_cpt_compl_funcs(void)
     return FAIL;
 }
 
+/*
+ * Start the timer for the current completion source.
+ */
+    static void
+compl_source_start_timer(int source_idx UNUSED)
+{
+#ifdef ELAPSED_FUNC
+    if (compl_autocomplete && cpt_sources_array != NULL)
+    {
+       ELAPSED_INIT(cpt_sources_array[source_idx].compl_start_tv);
+       compl_time_slice_expired = FALSE;
+    }
+#endif
+}
+
 /*
  * Safely advance the cpt_sources_index by one.
  */
@@ -5188,6 +5254,8 @@ advance_cpt_sources_index_safe(void)
     return FAIL;
 }
 
+#define COMPL_FUNC_TIMEOUT_MS          300
+#define COMPL_FUNC_TIMEOUT_NON_KW_MS   1000
 /*
  * Get the next expansion(s), using "compl_pattern".
  * The search starts at position "ini" in curbuf and in the direction
@@ -5206,6 +5274,7 @@ ins_compl_get_exp(pos_T *ini)
     int                found_new_match;
     int                type = ctrl_x_mode;
     int                may_advance_cpt_idx = FALSE;
+    pos_T      start_pos = *ini;
 
     if (!compl_started)
     {
@@ -5226,7 +5295,15 @@ ins_compl_get_exp(pos_T *ini)
                                            ? (char_u *)"." : curbuf->b_p_cpt);
        strip_caret_numbers_in_place(st.e_cpt_copy);
        st.e_cpt = st.e_cpt_copy == NULL ? (char_u *)"" : st.e_cpt_copy;
-       st.last_match_pos = st.first_match_pos = *ini;
+
+       // In large buffers, timeout may miss nearby matches — search above 
cursor
+#define LOOKBACK_LINE_COUNT    1000
+       if (compl_autocomplete && is_nearest_active())
+       {
+           start_pos.lnum = MAX(1, start_pos.lnum - LOOKBACK_LINE_COUNT);
+           start_pos.col = 0;
+       }
+       st.last_match_pos = st.first_match_pos = start_pos;
     }
     else if (st.ins_buf != curbuf && !buf_valid(st.ins_buf))
        st.ins_buf = curbuf;  // In case the buffer was wiped out.
@@ -5238,7 +5315,14 @@ ins_compl_get_exp(pos_T *ini)
     if (cpt_sources_array != NULL && ctrl_x_mode_normal()
            && !ctrl_x_mode_line_or_eval()
            && !(compl_cont_status & CONT_LOCAL))
+    {
        cpt_sources_index = 0;
+       if (compl_autocomplete)
+       {
+           compl_source_start_timer(0);
+           compl_timeout_ms = COMPL_INITIAL_TIMEOUT_MS;
+       }
+    }
 
     // For ^N/^P loop over all the flags/windows/buffers in 'complete'.
     for (;;)
@@ -5252,15 +5336,19 @@ ins_compl_get_exp(pos_T *ini)
        if ((ctrl_x_mode_normal() || ctrl_x_mode_line_or_eval())
                                        && (!compl_started || st.found_all))
        {
-           int status = process_next_cpt_value(&st, &type, ini,
+           int status = process_next_cpt_value(&st, &type, &start_pos,
                    cfc_has_mode(), &may_advance_cpt_idx);
 
            if (status == INS_COMPL_CPT_END)
                break;
            if (status == INS_COMPL_CPT_CONT)
            {
-               if (may_advance_cpt_idx && !advance_cpt_sources_index_safe())
-                   break;
+               if (may_advance_cpt_idx)
+               {
+                   if (!advance_cpt_sources_index_safe())
+                       break;
+                   compl_source_start_timer(cpt_sources_index);
+               }
                continue;
            }
        }
@@ -5270,11 +5358,24 @@ ins_compl_get_exp(pos_T *ini)
        if (compl_pattern.string == NULL)
            break;
 
+       if (compl_autocomplete && type == CTRL_X_FUNCTION)
+           // LSP servers may sporadically take >1s to respond (e.g., while
+           // loading modules), but other sources might already have matches.
+           // To show results quickly use a short timeout for keyword
+           // completion. Allow longer timeout for non-keyword completion
+           // where only function based sources (e.g. LSP) are active.
+           compl_timeout_ms = compl_from_nonkeyword
+               ? COMPL_FUNC_TIMEOUT_NON_KW_MS : COMPL_FUNC_TIMEOUT_MS;
+
        // get the next set of completion matches
-       found_new_match = get_next_completion_match(type, &st, ini);
+       found_new_match = get_next_completion_match(type, &st, &start_pos);
 
-       if (may_advance_cpt_idx && !advance_cpt_sources_index_safe())
-           break;
+       if (may_advance_cpt_idx)
+       {
+           if (!advance_cpt_sources_index_safe())
+               break;
+           compl_source_start_timer(cpt_sources_index);
+       }
 
        // break the loop for specialized modes (use 'complete' just for the
        // generic ctrl_x_mode == CTRL_X_NORMAL) or when we've found a new
@@ -5291,7 +5392,7 @@ ins_compl_get_exp(pos_T *ini)
            if ((ctrl_x_mode_not_default()
                        && !ctrl_x_mode_line_or_eval()) || compl_interrupted)
                break;
-           compl_started = TRUE;
+           compl_started = compl_time_slice_expired ? FALSE : TRUE;
        }
        else
        {
@@ -5302,6 +5403,10 @@ ins_compl_get_exp(pos_T *ini)
            compl_started = FALSE;
        }
 
+       // Reset the timeout after collecting matches from function source
+       if (compl_autocomplete && type == CTRL_X_FUNCTION)
+           compl_timeout_ms = COMPL_INITIAL_TIMEOUT_MS;
+
        // For `^P` completion, reset `compl_curr_match` to the head to avoid
        // mixing matches from different sources.
        if (!compl_dir_forward())
@@ -5317,7 +5422,7 @@ ins_compl_get_exp(pos_T *ini)
 
     i = -1;            // total of matches, unknown
     if (found_new_match == FAIL || (ctrl_x_mode_not_default()
-                                              && !ctrl_x_mode_line_or_eval()))
+               && !ctrl_x_mode_line_or_eval()))
        i = ins_compl_make_cyclic();
 
     if (cfc_has_mode() && compl_get_longest && compl_num_bests > 0)
@@ -5624,7 +5729,8 @@ find_next_completion_match(
     int                found_end = FALSE;
     compl_T    *found_compl = NULL;
     unsigned int cur_cot_flags = get_cot_flags();
-    int                compl_no_select = (cur_cot_flags & COT_NOSELECT) != 0;
+    int                compl_no_select = (cur_cot_flags & COT_NOSELECT) != 0
+                               || compl_autocomplete;
     int                compl_fuzzy_match = (cur_cot_flags & COT_FUZZY) != 0;
     string_T   *leader;
 
@@ -5752,7 +5858,8 @@ ins_compl_next(
     int            started = compl_started;
     buf_T   *orig_curbuf = curbuf;
     unsigned int cur_cot_flags = get_cot_flags();
-    int            compl_no_insert = (cur_cot_flags & COT_NOINSERT) != 0;
+    int            compl_no_insert = (cur_cot_flags & COT_NOINSERT) != 0
+                               || compl_autocomplete;
     int            compl_fuzzy_match = (cur_cot_flags & COT_FUZZY) != 0;
     int            compl_preinsert = ins_compl_has_preinsert();
 
@@ -5843,7 +5950,7 @@ ins_compl_next(
 
     // Enter will select a match when the match wasn't inserted and the popup
     // menu is visible.
-    if (compl_no_insert && !started)
+    if (compl_no_insert && !started && compl_selected_item != -1)
        compl_enter_selects = TRUE;
     else
        compl_enter_selects = !insert_match && compl_match_array != NULL;
@@ -5855,6 +5962,29 @@ ins_compl_next(
     return num_matches;
 }
 
+/*
+ * Check if the current completion source exceeded its timeout. If so, stop
+ * collecting, and halve the timeout.
+ */
+    static void
+check_elapsed_time(void)
+{
+#ifdef ELAPSED_FUNC
+    if (cpt_sources_array == NULL)
+       return;
+
+    elapsed_T  *start_tv
+       = &cpt_sources_array[cpt_sources_index].compl_start_tv;
+    long       elapsed_ms = ELAPSED_FUNC(*start_tv);
+
+    if (elapsed_ms > compl_timeout_ms)
+    {
+       compl_time_slice_expired = TRUE;
+       DECAY_COMPL_TIMEOUT();
+    }
+#endif
+}
+
 /*
  * Call this while finding completions, to check whether the user has hit a key
  * that should change the currently displayed completion, or exit completion
@@ -5915,8 +6045,14 @@ ins_compl_check_keys(int frequency, int in_compl_func)
            }
        }
     }
-    if (compl_pending != 0 && !got_int && !(cot_flags & COT_NOINSERT))
+    else if (compl_autocomplete)
+       check_elapsed_time();
+
+    if (compl_pending != 0 && !got_int && !(cot_flags & COT_NOINSERT)
+           && !compl_autocomplete)
     {
+       // Insert the first match immediately and advance compl_shown_match,
+       // before finding other matches.
        int todo = compl_pending > 0 ? compl_pending : -compl_pending;
 
        compl_pending = 0;
@@ -6070,6 +6206,7 @@ get_normal_compl_info(char_u *line, int startcol, colnr_T 
curs_col)
        compl_pattern.length = len;
        compl_col += curs_col;
        compl_length = 0;
+       compl_from_nonkeyword = TRUE;
     }
     else
     {
@@ -6631,7 +6768,7 @@ ins_compl_start(void)
        compl_startpos.col = compl_col;
     }
 
-    if (!shortmess(SHM_COMPLETIONMENU))
+    if (!shortmess(SHM_COMPLETIONMENU) && !compl_autocomplete)
     {
        if (compl_cont_status & CONT_LOCAL)
            edit_submode = (char_u *)_(ctrl_x_msgs[CTRL_X_LOCAL_MSG]);
@@ -6662,7 +6799,7 @@ ins_compl_start(void)
     // showmode might reset the internal line pointers, so it must
     // be called before line = ml_get(), or when this address is no
     // longer needed.  -- Acevedo.
-    if (!shortmess(SHM_COMPLETIONMENU))
+    if (!shortmess(SHM_COMPLETIONMENU) && !compl_autocomplete)
     {
        edit_submode_extra = (char_u *)_("-- Searching...");
        edit_submode_highl = HLF_COUNT;
@@ -6831,7 +6968,7 @@ ins_complete(int c, int enable_pum)
     else
        compl_cont_status &= ~CONT_S_IPOS;
 
-    if (!shortmess(SHM_COMPLETIONMENU))
+    if (!shortmess(SHM_COMPLETIONMENU) && !compl_autocomplete)
        ins_compl_show_statusmsg();
 
     // Show the popup menu, unless we got interrupted.
@@ -6844,6 +6981,23 @@ ins_complete(int c, int enable_pum)
     return OK;
 }
 
+/*
+ * Returns TRUE if the given character 'c' can be used to trigger
+ * autocompletion.
+ */
+    int
+ins_compl_setup_autocompl(int c)
+{
+#ifdef ELAPSED_FUNC
+    if (vim_isprintc(c))
+    {
+       compl_autocomplete = TRUE;
+       return TRUE;
+    }
+#endif
+    return FALSE;
+}
+
 /*
  * Remove (if needed) and show the popup menu
  */
@@ -7144,6 +7298,7 @@ get_cpt_func_completion_matches(callback_T *cb UNUSED)
     if (set_compl_globals(startcol, curwin->w_cursor.col, TRUE) == OK)
     {
        expand_by_function(0, cpt_compl_pattern.string, cb);
+
        cpt_sources_array[cpt_sources_index].cs_refresh_always =
            compl_opt_refresh_always;
        compl_opt_refresh_always = FALSE;
@@ -7196,7 +7351,10 @@ cpt_compl_refresh(void)
                }
                cpt_sources_array[cpt_sources_index].cs_startcol = startcol;
                if (ret == OK)
+               {
+                   compl_source_start_timer(cpt_sources_index);
                    get_cpt_func_completion_matches(cb);
+               }
            }
            else
                cpt_sources_array[cpt_sources_index].cs_startcol
diff --git a/src/misc1.c b/src/misc1.c
index 4571ff27f..7f4b619b4 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -565,6 +565,26 @@ gchar_cursor(void)
     return (int)*ml_get_cursor();
 }
 
+/*
+ * Return the character immediately before the cursor.
+ */
+    int
+char_before_cursor(void)
+{
+    if (curwin->w_cursor.col == 0)
+       return -1;
+
+    char_u *line = ml_get_curline();
+
+    if (has_mbyte)
+    {
+       char_u *p = line + curwin->w_cursor.col;
+       int prev_len = (*mb_head_off)(line, p - 1) + 1;
+       return mb_ptr2char(p - prev_len);
+    }
+    return line[curwin->w_cursor.col - 1];
+}
+
 /*
  * Write a character at the current cursor position.
  * It is directly written into the block.
diff --git a/src/option.h b/src/option.h
index 1706ac1a7..52fcfefcf 100644
--- a/src/option.h
+++ b/src/option.h
@@ -523,6 +523,7 @@ EXTERN char_u       *p_cia;         // 'completeitemalign'
 EXTERN unsigned cia_flags;     // order flags of 'completeitemalign'
 EXTERN char_u  *p_cot;         // 'completeopt'
 EXTERN unsigned        cot_flags;      // flags from 'completeopt'
+EXTERN int     p_ac;           // 'autocomplete'
 // Keep in sync with p_cot_values in optionstr.c
 #define COT_MENU       0x001
 #define COT_MENUONE    0x002
diff --git a/src/optiondefs.h b/src/optiondefs.h
index 3144e2330..632ccf25f 100644
--- a/src/optiondefs.h
+++ b/src/optiondefs.h
@@ -388,6 +388,11 @@ static struct vimoption options[] =
                            {(char_u *)0L, (char_u *)0L}
 #endif
                            SCTX_INIT},
+#ifdef ELAPSED_FUNC
+    {"autocomplete",  "ac", P_BOOL|P_VI_DEF,
+                           (char_u *)&p_ac, PV_NONE, NULL,
+                           NULL, {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
+#endif
     {"autoindent",  "ai",   P_BOOL|P_VI_DEF,
                            (char_u *)&p_ai, PV_AI, NULL, NULL,
                            {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
diff --git a/src/po/vim.pot b/src/po/vim.pot
index be30ce557..4948309af 100644
--- a/src/po/vim.pot
+++ b/src/po/vim.pot
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION
"
 "Report-Msgid-Bugs-To: 
"
-"POT-Creation-Date: 2025-07-24 19:13+0200
"
+"POT-Creation-Date: 2025-07-25 18:40+0200
"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE
"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>
"
 "Language-Team: LANGUAGE <l...@li.org>
"
@@ -9914,7 +9914,7 @@ msgstr ""
 msgid "specifies how Insert mode completion works for CTRL-N and CTRL-P"
 msgstr ""
 
-msgid "use fuzzy collection for specific completion modes"
+msgid "automatic completion in insert mode"
 msgstr ""
 
 msgid "whether to use a popup menu for Insert mode completion"
@@ -9923,6 +9923,9 @@ msgstr ""
 msgid "popup menu item align order"
 msgstr ""
 
+msgid "use fuzzy collection for specific completion modes"
+msgstr ""
+
 msgid "options for the Insert mode completion info popup"
 msgstr ""
 
diff --git a/src/proto/insexpand.pro b/src/proto/insexpand.pro
index 05640087c..5c0b0e30b 100644
--- a/src/proto/insexpand.pro
+++ b/src/proto/insexpand.pro
@@ -69,4 +69,6 @@ int ins_complete(int c, int enable_pum);
 void free_insexpand_stuff(void);
 int ins_compl_cancel(void);
 void f_complete_match(typval_T *argvars, typval_T *rettv);
+int ins_compl_setup_autocompl(int c);
+// void ins_compl_disable_autocompl(void);
 /* vim: set ft=c : */
diff --git a/src/proto/misc1.pro b/src/proto/misc1.pro
index d7c187af6..d24a61d15 100644
--- a/src/proto/misc1.pro
+++ b/src/proto/misc1.pro
@@ -10,6 +10,7 @@ int plines_win_col(win_T *wp, linenr_T lnum, long column);
 int plines_m_win(win_T *wp, linenr_T first, linenr_T last, int max);
 int gchar_pos(pos_T *pos);
 int gchar_cursor(void);
+int char_before_cursor(void);
 void pchar_cursor(int c);
 char_u *skip_to_option_part(char_u *p);
 void check_status(buf_T *buf);
diff --git a/src/testdir/test_ins_complete.vim 
b/src/testdir/test_ins_complete.vim
index 1573fbee0..3a92d5298 100644
--- a/src/testdir/test_ins_complete.vim
+++ b/src/testdir/test_ins_complete.vim
@@ -586,30 +586,40 @@ endfunc
 func Test_cpt_func_cursorcol()
   func CptColTest(findstart, query)
     if a:findstart
-      call assert_equal("foo bar", getline(1))
-      call assert_equal(8, col('.'))
+      call assert_equal(b:info_compl_line, getline(1))
+      call assert_equal(b:info_cursor_col, col('.'))
       return col('.')
     endif
-    call assert_equal("foo ", getline(1))
-    call assert_equal(5, col('.'))
+    call assert_equal(b:expn_compl_line, getline(1))
+    call assert_equal(b:expn_cursor_col, col('.'))
     return v:none
   endfunc
 
   set complete=FCptColTest
   new
-  call feedkeys("ifoo bar\<C-N>", "tx")
-  bwipe!
-  new
+
+  " Replace mode
+  let b:info_compl_line = "foo barxyz"
+  let b:expn_compl_line = "foo barbaz"
+  let b:info_cursor_col = 10
+  let b:expn_cursor_col = 5
+  call feedkeys("ifoo barbaz\<Esc>2hRxy\<C-N>", "tx")
+
+  " Insert mode
+  let b:info_compl_line = "foo bar"
+  let b:expn_compl_line = "foo "
+  let b:info_cursor_col = 8
+  let b:expn_cursor_col = 5
+  call feedkeys("Sfoo bar\<C-N>", "tx")
+
   set completeopt=longest
-  call feedkeys("ifoo bar\<C-N>", "tx")
-  bwipe!
-  new
+  call feedkeys("Sfoo bar\<C-N>", "tx")
+
   set completeopt=menuone
-  call feedkeys("ifoo bar\<C-N>", "tx")
-  bwipe!
-  new
+  call feedkeys("Sfoo bar\<C-N>", "tx")
+
   set completeopt=menuone,preinsert
-  call feedkeys("ifoo bar\<C-N>", "tx")
+  call feedkeys("Sfoo bar\<C-N>", "tx")
   bwipe!
   set complete& completeopt&
   delfunc CptColTest
@@ -3643,7 +3653,7 @@ func Test_cfc_with_longest()
   exe "normal ggdGShello helio heo\<C-X>\<C-N>\<ESC>"
   call assert_equal("hello helio heo", getline('.'))
 
-  " kdcit
+  " dict
   call writefile(['help'], 'test_keyword.txt', 'D')
   set complete=ktest_keyword.txt
   exe "normal ggdGSh\<C-N>\<ESC>"
@@ -4860,6 +4870,27 @@ func Test_complete_fuzzy_omnifunc_backspace()
   unlet g:do_complete
 endfunc
 
+" Test that option shortmess=c turns off completion messages
+func Test_shortmess()
+  CheckScreendump
+
+  let lines =<< trim END
+    call setline(1, ['hello', 'hullo', 'heee'])
+  END
+
+  call writefile(lines, 'Xpumscript', 'D')
+  let buf = RunVimInTerminal('-S Xpumscript', #{rows: 12})
+  call term_sendkeys(buf, "Goh\<C-N>")
+  call TermWait(buf, 200)
+  call VerifyScreenDump(buf, 'Test_shortmess_complmsg_1', {})
+  call term_sendkeys(buf, "\<ESC>:set shm+=c\<CR>")
+  call term_sendkeys(buf, "Sh\<C-N>")
+  call TermWait(buf, 200)
+  call VerifyScreenDump(buf, 'Test_shortmess_complmsg_2', {})
+
+  call StopVimInTerminal(buf)
+endfunc
+
 " Test 'complete' containing F{func} that complete from nonkeyword
 func Test_nonkeyword_trigger()
 
@@ -4976,25 +5007,320 @@ func Test_nonkeyword_trigger()
   unlet g:CallCount
 endfunc
 
-" Test that option shortmess=c turns off completion messages
-func Test_shortmess()
-  CheckScreendump
+func Test_autocomplete_trigger()
+  " Trigger expansion even when another char is waiting in the typehead
+  call test_override("char_avail", 1)
 
-  let lines =<< trim END
-    call setline(1, ['hello', 'hullo', 'heee'])
-  END
+  let g:CallCount = 0
+  func! NonKeywordComplete(findstart, base)
+    let line = getline('.')->strpart(0, col('.') - 1)
+    let nonkeyword2 = len(line) > 1 && match(line[-2:-2], '\k') != 0
+    if a:findstart
+      return nonkeyword2 ? col('.') - 3 : (col('.') - 2)
+    else
+      let g:CallCount += 1
+      return [$"{a:base}foo", $"{a:base}bar"]
+    endif
+  endfunc
 
-  call writefile(lines, 'Xpumscript', 'D')
-  let buf = RunVimInTerminal('-S Xpumscript', #{rows: 12})
-  call term_sendkeys(buf, "Goh\<C-N>")
-  call TermWait(buf, 200)
-  call VerifyScreenDump(buf, 'Test_shortmess_complmsg_1', {})
-  call term_sendkeys(buf, "\<ESC>:set shm+=c\<CR>")
-  call term_sendkeys(buf, "Sh\<C-N>")
-  call TermWait(buf, 200)
-  call VerifyScreenDump(buf, 'Test_shortmess_complmsg_2', {})
+  new
+  inoremap <buffer> <F2> <Cmd>let b:matches = 
complete_info(["matches"]).matches<CR>
+  inoremap <buffer> <F3> <Cmd>let b:selected = 
complete_info(["selected"]).selected<CR>
 
-  call StopVimInTerminal(buf)
+  call setline(1, ['abc', 'abcd', 'fo', 'b', ''])
+  set autocomplete
+
+  " Test 1a: Nonkeyword doesn't open menu without F{func} when autocomplete
+  call feedkeys("GS=\<F2>\<Esc>0", 'tx!')
+  call assert_equal([], b:matches)
+  call assert_equal('=', getline('.'))
+  " ^N opens menu of keywords (of len > 1)
+  call feedkeys("S=\<C-E>\<C-N>\<F2>\<Esc>0", 'tx!')
+  call assert_equal(['abc', 'abcd', 'fo'], b:matches->mapnew('v:val.word'))
+  call assert_equal('=abc', getline('.'))
+
+  " Test 1b: With F{func} nonkeyword collects matches
+  set complete=.,FNonKeywordComplete
+  let g:CallCount = 0
+  call feedkeys("S=\<F2>\<Esc>0", 'tx!')
+  call assert_equal(['=foo', '=bar'], b:matches->mapnew('v:val.word'))
+  call assert_equal(1, g:CallCount)
+  call assert_equal('=', getline('.'))
+  let g:CallCount = 0
+  call feedkeys("S->\<F2>\<Esc>0", 'tx!')
+  call assert_equal(['->foo', '->bar'], b:matches->mapnew('v:val.word'))
+  call assert_equal(2, g:CallCount)
+  call assert_equal('->', getline('.'))
+
+  " Test 1c: Keyword after nonkeyword can collect both types of items
+  let g:CallCount = 0
+  call feedkeys("S#a\<F2>\<Esc>0", 'tx!')
+  call assert_equal(['abcd', 'abc', '#afoo', '#abar'], 
b:matches->mapnew('v:val.word'))
+  call assert_equal(2, g:CallCount)
+  call assert_equal('#a', getline('.'))
+  let g:CallCount = 0
+  call feedkeys("S#a.\<F2>\<Esc>0", 'tx!')
+  call assert_equal(['.foo', '.bar'], b:matches->mapnew('v:val.word'))
+  call assert_equal(3, g:CallCount)
+  call assert_equal('#a.', getline('.'))
+  let g:CallCount = 0
+  call feedkeys("S#a.a\<F2>\<Esc>0", 'tx!')
+  call assert_equal(['abcd', 'abc', '.afoo', '.abar'], 
b:matches->mapnew('v:val.word'))
+  call assert_equal(4, g:CallCount)
+  call assert_equal('#a.a', getline('.'))
+
+  " Test 1d: Nonkeyword after keyword collects items again
+  let g:CallCount = 0
+  call feedkeys("Sa\<F2>\<Esc>0", 'tx!')
+  call assert_equal(['abcd', 'abc', 'afoo', 'abar'], 
b:matches->mapnew('v:val.word'))
+  call assert_equal(1, g:CallCount)
+  call assert_equal('a', getline('.'))
+  let g:CallCount = 0
+  call feedkeys("Sa#\<F2>\<Esc>0", 'tx!')
+  call assert_equal(['#foo', '#bar'], b:matches->mapnew('v:val.word'))
+  call assert_equal(2, g:CallCount)
+  call assert_equal('a#', getline('.'))
+
+  " Test 2: Filter nonkeyword and keyword matches with differet startpos
+  for fuzzy in range(2)
+    if fuzzy
+      set completeopt+=fuzzy
+    endif
+    call feedkeys("S#ab\<F2>\<F3>\<Esc>0", 'tx!')
+    if fuzzy
+      call assert_equal(['#abar', 'abc', 'abcd'], 
b:matches->mapnew('v:val.word'))
+    else " Ordering of items is by 'nearest' to cursor by default
+      call assert_equal(['abcd', 'abc', '#abar'], 
b:matches->mapnew('v:val.word'))
+    endif
+    call assert_equal(-1, b:selected)
+    call assert_equal('#ab', getline('.'))
+    call feedkeys("S#ab" . repeat("\<C-N>", 3) . "\<F3>\<Esc>0", 'tx!')
+    call assert_equal(fuzzy ? '#abcd' : '#abar', getline('.'))
+    call assert_equal(2, b:selected)
+
+    let g:CallCount = 0
+    call feedkeys("GS#aba\<F2>\<Esc>0", 'tx!')
+    call assert_equal(['#abar'], b:matches->mapnew('v:val.word'))
+    call assert_equal(2, g:CallCount)
+    call assert_equal('#aba', getline('.'))
+
+    let g:CallCount = 0
+    call feedkeys("S#abc\<F2>\<Esc>0", 'tx!')
+    if fuzzy
+      call assert_equal(['abc', 'abcd'], b:matches->mapnew('v:val.word'))
+    else
+      call assert_equal(['abcd', 'abc'], b:matches->mapnew('v:val.word'))
+    endif
+    call assert_equal(2, g:CallCount)
+    set completeopt&
+  endfor
+
+  " Test 3: Navigate menu containing nonkeyword and keyword items
+  call feedkeys("S#a\<F2>\<Esc>0", 'tx!')
+  call assert_equal(['abcd', 'abc', '#afoo', '#abar'], 
b:matches->mapnew('v:val.word'))
+  call feedkeys("S#a" . repeat("\<C-N>", 3) . "\<Esc>0", 'tx!')
+  call assert_equal('#afoo', getline('.'))
+  call feedkeys("S#a" . repeat("\<C-N>", 3) . "\<C-P>\<Esc>0", 'tx!')
+  call assert_equal('#abc', getline('.'))
+
+  call feedkeys("S#a.a\<F2>\<Esc>0", 'tx!')
+  call assert_equal(['abcd', 'abc', '.afoo', '.abar'], 
b:matches->mapnew('v:val.word'))
+  call feedkeys("S#a.a" . repeat("\<C-N>", 2) . "\<Esc>0", 'tx!')
+  call assert_equal('#a.abc', getline('.'))
+  call feedkeys("S#a.a" . repeat("\<C-N>", 3) . "\<Esc>0", 'tx!')
+  call assert_equal('#a.afoo', getline('.'))
+  call feedkeys("S#a.a" . repeat("\<C-N>", 3) . "\<C-P>\<Esc>0", 'tx!')
+  call assert_equal('#a.abc', getline('.'))
+  call feedkeys("S#a.a" . repeat("\<C-P>", 6) . "\<Esc>0", 'tx!')
+  call assert_equal('#a.abar', getline('.'))
+
+  " Test 4a: When autocomplete menu is active, ^X^N completes buffer keywords
+  let g:CallCount = 0
+  call feedkeys("S#a\<C-X>\<C-N>\<F2>\<Esc>0", 'tx!')
+  call assert_equal(['abc', 'abcd'], b:matches->mapnew('v:val.word'))
+  call assert_equal(2, g:CallCount)
+
+  " Test 4b: When autocomplete menu is active, ^X^O completes omnifunc
+  let g:CallCount = 0
+  set omnifunc=NonKeywordComplete
+  call feedkeys("S#a\<C-X>\<C-O>\<F2>\<Esc>0", 'tx!')
+  call assert_equal(['#afoo', '#abar'], b:matches->mapnew('v:val.word'))
+  call assert_equal(3, g:CallCount)
+
+  " Test 4c: When autocomplete menu is active, ^E^N completes keyword
+  call feedkeys("Sa\<C-E>\<F2>\<Esc>0", 'tx!')
+  call assert_equal([], b:matches->mapnew('v:val.word'))
+  let g:CallCount = 0
+  call feedkeys("Sa\<C-E>\<C-N>\<F2>\<Esc>0", 'tx!')
+  call assert_equal(['abc', 'abcd', 'afoo', 'abar'], 
b:matches->mapnew('v:val.word'))
+  call assert_equal(2, g:CallCount)
+
+  " Test 4d: When autocomplete menu is active, ^X^L completes lines
+  %d
+  let g:CallCount = 0
+  call setline(1, ["afoo bar", "barbar foo", "foo bar", "and"])
+  call feedkeys("Goa\<C-X>\<C-L>\<F2>\<Esc>0", 'tx!')
+  call assert_equal(['afoo bar', 'and'], b:matches->mapnew('v:val.word'))
+  call assert_equal(1, g:CallCount)
+
+  " Test 5: When invalid prefix stops completion, backspace should restart it
+  %d
+  set complete&
+  call setline(1, ["afoo bar", "barbar foo", "foo bar", "and"])
+  call feedkeys("Goabc\<F2>\<Esc>0", 'tx!')
+  call assert_equal([], b:matches->mapnew('v:val.word'))
+  call feedkeys("Sabc\<BS>\<BS>\<F2>\<Esc>0", 'tx!')
+  call assert_equal(['and', 'afoo'], b:matches->mapnew('v:val.word'))
+  call feedkeys("Szx\<BS>\<F2>\<Esc>0", 'tx!')
+  call assert_equal([], b:matches->mapnew('v:val.word'))
+  call feedkeys("Sazx\<Left>\<BS>\<F2>\<Esc>0", 'tx!')
+  call assert_equal(['and', 'afoo'], b:matches->mapnew('v:val.word'))
+
+  bw!
+  call test_override("char_avail", 0)
+  delfunc NonKeywordComplete
+  set autocomplete&
+  unlet g:CallCount
+endfunc
+
+" Test autocomplete timing
+func Test_autocomplete_timer()
+
+  let g:CallCount = 0
+  func! TestComplete(delay, check, refresh, findstart, base)
+    if a:findstart
+      return col('.') - 1
+    else
+      let g:CallCount += 1
+      if a:delay
+        sleep 310m  " Exceed timeout
+      endif
+      if a:check
+        while !complete_check()
+          sleep 2m
+        endwhile
+        return v:none  " This should trigger after interrupted by timeout
+      endif
+      let res = [["ab", "ac", "ad"], ["abb", "abc", "abd"], ["acb", "cc", 
"cd"]]
+      if a:refresh
+        return #{words: res[g:CallCount - 1], refresh: 'always'}
+      endif
+      return res[g:CallCount - 1]
+    endif
+  endfunc
+
+  " Trigger expansion even when another char is waiting in the typehead
+  call test_override("char_avail", 1)
+
+  new
+  inoremap <buffer> <F2> <Cmd>let b:matches = 
complete_info(["matches"]).matches<CR>
+  inoremap <buffer> <F3> <Cmd>let b:selected = 
complete_info(["selected"]).selected<CR>
+  set autocomplete
+
+  call setline(1, ['abc', 'bcd', 'cde'])
+
+  " Test 1: When matches are found before timeout expires, it exits
+  " 'collection' mode and transitions to 'filter' mode.
+  set complete=.,Ffunction('TestComplete'\,\ [0\,\ 0\,\ 0])
+  let g:CallCount = 0
+  call feedkeys("Goa\<F2>\<Esc>0", 'tx!')
+  call assert_equal(['abc', 'ab', 'ac', 'ad'], b:matches->mapnew('v:val.word'))
+  call assert_equal(1, g:CallCount)
+
+  let g:CallCount = 0
+  call feedkeys("Sab\<F2>\<Esc>0", 'tx!')
+  call assert_equal(['abc', 'ab'], b:matches->mapnew('v:val.word'))
+  call assert_equal(1, g:CallCount)
+
+  " Test 2: When timeout expires before all matches are found, it returns
+  " with partial list but still transitions to 'filter' mode.
+  set complete=.,Ffunction('TestComplete'\,\ [1\,\ 0\,\ 0])
+  let g:CallCount = 0
+  call feedkeys("Sab\<F2>\<Esc>0", 'tx!')
+  call assert_equal(['abc', 'ab'], b:matches->mapnew('v:val.word'))
+  call assert_equal(1, g:CallCount)
+
+  " Test 3: When interrupted by ^N before timeout expires, it remains in
+  " 'collection' mode without transitioning.
+  set complete=.,Ffunction('TestComplete'\,\ [0\,\ 1\,\ 0])
+  let g:CallCount = 0
+  call feedkeys("Sa\<C-N>b\<F2>\<Esc>0", 'tx!')
+  call assert_equal(2, g:CallCount)
+
+  let g:CallCount = 0
+  call feedkeys("Sa\<C-N>b\<C-N>c\<F2>\<Esc>0", 'tx!')
+  call assert_equal(3, g:CallCount)
+
+  " Test 4: Simulate long running func that is stuck in complete_check()
+  let g:CallCount = 0
+  set complete=.,Ffunction('TestComplete'\,\ [0\,\ 1\,\ 0])
+  call feedkeys("Sa\<F2>\<Esc>0", 'tx!')
+  call assert_equal(['abc'], b:matches->mapnew('v:val.word'))
+  call assert_equal(1, g:CallCount)
+
+  let g:CallCount = 0
+  call feedkeys("Sab\<F2>\<Esc>0", 'tx!')
+  call assert_equal(['abc'], b:matches->mapnew('v:val.word'))
+  call assert_equal(1, g:CallCount)
+
+  " Test 5: refresh:always stays in 'collection' mode
+  set complete=.,Ffunction('TestComplete'\,\ [0\,\ 0\,\ 1])
+  let g:CallCount = 0
+  call feedkeys("Sa\<F2>\<Esc>0", 'tx!')
+  call assert_equal(['abc', 'ab', 'ac', 'ad'], b:matches->mapnew('v:val.word'))
+  call assert_equal(1, g:CallCount)
+
+  let g:CallCount = 0
+  call feedkeys("Sab\<F2>\<Esc>0", 'tx!')
+  call assert_equal(['abc', 'abb', 'abd'], b:matches->mapnew('v:val.word'))
+  call assert_equal(2, g:CallCount)
+
+  " Test 6: <c-n> and <c-p> navigate menu
+  set complete=.,Ffunction('TestComplete'\,\ [0\,\ 0\,\ 0])
+  let g:CallCount = 0
+  call feedkeys("Sab\<c-n>\<F2>\<F3>\<Esc>0", 'tx!')
+  call assert_equal(['abc', 'ab'], b:matches->mapnew('v:val.word'))
+  call assert_equal(0, b:selected)
+  call assert_equal(1, g:CallCount)
+  call feedkeys("Sab\<c-n>\<c-n>\<F2>\<F3>\<Esc>0", 'tx!')
+  call assert_equal(1, b:selected)
+  call feedkeys("Sab\<c-n>\<c-p>\<F2>\<F3>\<Esc>0", 'tx!')
+  call assert_equal(-1, b:selected)
+
+  " Test 7: Following 'cot' option values have no effect
+  set completeopt=menu,menuone,noselect,noinsert,longest,preinsert
+  set complete=.,Ffunction('TestComplete'\,\ [0\,\ 0\,\ 0])
+  let g:CallCount = 0
+  call feedkeys("Sab\<c-n>\<F2>\<F3>\<Esc>0", 'tx!')
+  call assert_equal(['abc', 'ab'], b:matches->mapnew('v:val.word'))
+  call assert_equal(0, b:selected)
+  call assert_equal(1, g:CallCount)
+  call assert_equal('abc', getline(4))
+  set completeopt&
+
+  " Test 8: {func} completes after space, but not '.'
+  set complete=.,Ffunction('TestComplete'\,\ [0\,\ 0\,\ 0])
+  let g:CallCount = 0
+  call feedkeys("S \<F2>\<F3>\<Esc>0", 'tx!')
+  call assert_equal(['ab', 'ac', 'ad'], b:matches->mapnew('v:val.word'))
+  call assert_equal(1, g:CallCount)
+  set complete=.
+  call feedkeys("S \<F2>\<F3>\<Esc>0", 'tx!')
+  call assert_equal([], b:matches->mapnew('v:val.word'))
+
+  " Test 9: Matches nearest to the cursor are prioritized (by default)
+  %d
+  let g:CallCount = 0
+  set complete=.
+  call setline(1, ["fo", "foo", "foobar", "foobarbaz"])
+  call feedkeys("jof\<F2>\<Esc>0", 'tx!')
+  call assert_equal(['foo', 'foobar', 'fo', 'foobarbaz'], 
b:matches->mapnew('v:val.word'))
+
+  bw!
+  call test_override("char_avail", 0)
+  delfunc TestComplete
+  set autocomplete& complete&
+  unlet g:CallCount
 endfunc
 
 " vim: shiftwidth=2 sts=2 expandtab nofoldenable
diff --git a/src/version.c b/src/version.c
index 60cb58b4e..d06745272 100644
--- a/src/version.c
+++ b/src/version.c
@@ -719,6 +719,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1590,
 /**/
     1589,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1ufM0f-009zQ5-D7%40256bit.org.

Raspunde prin e-mail lui