patch 9.1.1742: complete: preinsert does not work well with preinsert
Problem: complete: preinsert does not work well with preinsert
Solution: Make "preinsert" completeopt value work with autocompletion
(Girish Palya)
This change extends Insert mode autocompletion so that 'preinsert' also
works when 'autocomplete' is enabled.
Try: `:set ac cot=preinsert`
See `:help 'cot'` for more details.
closes: #18213
Signed-off-by: Girish Palya <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
4ed19fd336
commit
fa6fd41a94
@ -1,4 +1,4 @@
|
||||
*insert.txt* For Vim version 9.1. Last change: 2025 Aug 25
|
||||
*insert.txt* For Vim version 9.1. Last change: 2025 Sep 08
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@ -1150,7 +1150,26 @@ any of them at any time by typing |CTRL-X|, which temporarily suspends
|
||||
autocompletion. To use |i_CTRL-N| or |i_CTRL-X_CTRL-N| specifically, press
|
||||
|CTRL-E| first to dismiss the popup menu (see |complete_CTRL-E|).
|
||||
|
||||
See also 'autocomplete', 'autocompletetimeout' and 'autocompletedelay'.
|
||||
*ins-autocompletion-example*
|
||||
Example setup~
|
||||
A typical configuration for automatic completion with a popup menu: >
|
||||
set autocomplete
|
||||
set complete=.^5,w^5,b^5,u^5
|
||||
set completeopt=popup
|
||||
|
||||
inoremap <silent><expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
|
||||
inoremap <silent><expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
|
||||
<
|
||||
This enables automatic completion with suggestions from the current buffer,
|
||||
other windows, and listed buffers, displayed in a popup menu. Each source is
|
||||
limited to 5 candidates. <Tab> and <S-Tab> move through the items when the
|
||||
menu is visible. Optionally, add "preinsert" to 'completeopt' to insert the
|
||||
longest common prefix automatically. You can also add other completion
|
||||
sources to 'complete' as needed.
|
||||
|
||||
See also 'autocomplete', 'autocompletedelay' and 'autocompletetimeout'.
|
||||
|
||||
For command-line autocompletion, see |cmdline-autocompletion|.
|
||||
|
||||
|
||||
FUNCTIONS FOR FINDING COMPLETIONS *complete-functions*
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
*options.txt* For Vim version 9.1. Last change: 2025 Sep 02
|
||||
*options.txt* For Vim version 9.1. Last change: 2025 Sep 08
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@ -2124,10 +2124,11 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
*'complete'* *'cpt'* *E535*
|
||||
'complete' 'cpt' string (default: ".,w,b,u,t,i")
|
||||
local to buffer
|
||||
This option specifies how keyword completion |ins-completion| works
|
||||
when CTRL-P or CTRL-N are used. It is also used for whole-line
|
||||
completion |i_CTRL-X_CTRL-L|. It indicates the type of completion
|
||||
and the places to scan. It is a comma-separated list of flags:
|
||||
This option controls how completion |ins-completion| behaves when
|
||||
using CTRL-P, CTRL-N, or |ins-autocompletion|. It is also used for
|
||||
whole-line completion |i_CTRL-X_CTRL-L|. It indicates the type of
|
||||
completion and the places to scan. It is a comma-separated list of
|
||||
flags:
|
||||
. scan the current buffer ('wrapscan' is ignored)
|
||||
w scan buffers from other windows
|
||||
b scan other loaded buffers that are in the buffer list
|
||||
@ -2179,9 +2180,11 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
5. tags
|
||||
6. included files
|
||||
|
||||
As you can see, CTRL-N and CTRL-P can be used to do any 'iskeyword'-
|
||||
based expansion (e.g., dictionary |i_CTRL-X_CTRL-K|, included patterns
|
||||
|i_CTRL-X_CTRL-I|, tags |i_CTRL-X_CTRL-]| and normal expansions).
|
||||
CTRL-N, CTRL-P, and |ins-autocompletion| can be used for any
|
||||
'iskeyword'-based completion (dictionary |i_CTRL-X_CTRL-K|, included
|
||||
patterns |i_CTRL-X_CTRL-I|, tags |i_CTRL-X_CTRL-]|, and normal
|
||||
expansions). With the "F" and "o" flags in 'complete', non-keywords
|
||||
can also be completed.
|
||||
|
||||
An optional match limit can be specified for a completion source by
|
||||
appending a caret ("^") followed by a {count} to the source flag.
|
||||
@ -2298,17 +2301,22 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
{only works when compiled with the |+textprop| feature}
|
||||
|
||||
preinsert
|
||||
Preinsert the portion of the first candidate word that is
|
||||
not part of the current completion leader and using the
|
||||
|hl-ComplMatchIns| highlight group. In order for it to
|
||||
work, "fuzzy" must not be set and "menuone" must be set.
|
||||
When autocompletion is not enabled, inserts the part of the
|
||||
first candidate word beyond the current completion leader,
|
||||
highlighted with |hl-ComplMatchIns|. The cursor does not
|
||||
move. Requires 'fuzzy' unset and 'menuone' in 'completeopt'.
|
||||
|
||||
When 'autocomplete' is enabled, inserts the longest common
|
||||
prefix of matches (from all shown items or buffer-specific
|
||||
matches), highlighted with |hl-PreInsert|. This occurs only
|
||||
when no menu item is selected. Press CTRL-Y to accept.
|
||||
|
||||
preview Show extra information about the currently selected
|
||||
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.
|
||||
Only "fuzzy", "popup", "popuphidden", "preinsert" and "preview" have
|
||||
an effect when 'autocomplete' is enabled.
|
||||
|
||||
This option does not apply to |cmdline-completion|. See 'wildoptions'
|
||||
for that.
|
||||
@ -4654,7 +4662,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
#:TabLineSel,_:TabLineFill,!:CursorColumn,
|
||||
.:CursorLine,o:ColorColumn,q:QuickFixLine,
|
||||
z:StatusLineTerm,Z:StatusLineTermNC,
|
||||
g:MsgArea,h:ComplMatchIns")
|
||||
g:MsgArea,h:ComplMatchIns,I:PreInsert")
|
||||
global
|
||||
This option can be used to set highlighting mode for various
|
||||
occasions. It is a comma-separated list of character pairs. The
|
||||
@ -4717,6 +4725,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
|hl-PmenuThumb| X popup menu scrollbar thumb
|
||||
|hl-PmenuMatch| k popup menu matched text
|
||||
|hl-PmenuMatchSel| < popup menu matched text in selected line
|
||||
|hl-PreInsert| I text inserted when "preinsert" and 'autocomplete'
|
||||
|
||||
The display modes are:
|
||||
r reverse (termcap entry "mr" and "me")
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
*syntax.txt* For Vim version 9.1. Last change: 2025 Aug 18
|
||||
*syntax.txt* For Vim version 9.1. Last change: 2025 Sep 08
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@ -5998,6 +5998,8 @@ PmenuMatchSel Popup menu: Matched text in selected item. Applied in
|
||||
combination with |hl-PmenuSel|.
|
||||
*hl-ComplMatchIns*
|
||||
ComplMatchIns Matched text of the currently inserted completion.
|
||||
*hl-PreInsert*
|
||||
PreInsert Text inserted during autocompletion when "preinsert".
|
||||
*hl-PopupSelected*
|
||||
PopupSelected Popup window created with |popup_menu()|. Linked to
|
||||
|hl-PmenuSel| by default.
|
||||
|
||||
@ -8366,6 +8366,7 @@ hl-PmenuSel syntax.txt /*hl-PmenuSel*
|
||||
hl-PmenuThumb syntax.txt /*hl-PmenuThumb*
|
||||
hl-PopupNotification syntax.txt /*hl-PopupNotification*
|
||||
hl-PopupSelected syntax.txt /*hl-PopupSelected*
|
||||
hl-PreInsert syntax.txt /*hl-PreInsert*
|
||||
hl-Question syntax.txt /*hl-Question*
|
||||
hl-QuickFixLine syntax.txt /*hl-QuickFixLine*
|
||||
hl-Scrollbar syntax.txt /*hl-Scrollbar*
|
||||
@ -8627,6 +8628,7 @@ inputrestore() builtin.txt /*inputrestore()*
|
||||
inputsave() builtin.txt /*inputsave()*
|
||||
inputsecret() builtin.txt /*inputsecret()*
|
||||
ins-autocompletion insert.txt /*ins-autocompletion*
|
||||
ins-autocompletion-example insert.txt /*ins-autocompletion-example*
|
||||
ins-completion insert.txt /*ins-completion*
|
||||
ins-completion-menu insert.txt /*ins-completion-menu*
|
||||
ins-expandtab insert.txt /*ins-expandtab*
|
||||
|
||||
Reference in New Issue
Block a user