aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2025-03-27 08:02:45 +0800
committerGitHub <noreply@github.com>2025-03-27 08:02:45 +0800
commitce590e207720ec53a4592882840725bf8540c7d5 (patch)
tree6dc54fcd969c977ad35c02fc6ad3c5ce91f74e27 /runtime
parent9acb52c8f386ea0a026ba4e314e1294da66f8e79 (diff)
parent0af780e8df849f6d393873124afaa31681ab43ec (diff)
downloadrneovim-ce590e207720ec53a4592882840725bf8540c7d5.tar.gz
rneovim-ce590e207720ec53a4592882840725bf8540c7d5.tar.bz2
rneovim-ce590e207720ec53a4592882840725bf8540c7d5.zip
Merge pull request #30189 from zeertzjq/vim-9.1.0598
vim-patch: 'completefuzzycollect' option
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/news.txt3
-rw-r--r--runtime/doc/options.txt32
-rw-r--r--runtime/lua/vim/_meta/options.lua35
-rw-r--r--runtime/optwin.vim4
4 files changed, 64 insertions, 10 deletions
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index c0f3b31cf7..7bdacd73bf 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -131,7 +131,8 @@ LUA
OPTIONS
-• todo
+• 'completefuzzycollect' enables fuzzy collection of candidates for (some)
+ |ins-completion| modes.
PERFORMANCE
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index ba1d353f40..dd2460722e 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -1517,6 +1517,28 @@ A jump table for the options with a short description can be found at |Q_op|.
This option cannot be set from a |modeline| or in the |sandbox|, for
security reasons.
+ *'completefuzzycollect'* *'cfc'*
+'completefuzzycollect' 'cfc' string (default "")
+ global
+ A comma-separated list of strings to enable fuzzy collection for
+ specific |ins-completion| modes, affecting how matches are gathered
+ during completion. For specified modes, fuzzy matching is used to
+ find completion candidates instead of the standard prefix-based
+ matching. This option can contain the following values:
+
+ keyword keywords in the current file |i_CTRL-X_CTRL-N|
+ keywords with flags ".", "w", |i_CTRL-N| |i_CTRL-P|
+ "b", "u", "U" and "k{dict}" in 'complete'
+ keywords in 'dictionary' |i_CTRL-X_CTRL-K|
+
+ files file names |i_CTRL-X_CTRL-F|
+
+ whole_line whole lines |i_CTRL-X_CTRL-L|
+
+ When using the 'completeopt' "longest" option value, fuzzy collection
+ can identify the longest common string among the best fuzzy matches
+ and insert it automatically.
+
*'completeitemalign'* *'cia'*
'completeitemalign' 'cia' string (default "abbr,kind,menu")
global
@@ -1536,10 +1558,12 @@ A jump table for the options with a short description can be found at |Q_op|.
fuzzy Enable |fuzzy-matching| for completion candidates. This
allows for more flexible and intuitive matching, where
characters can be skipped and matches can be found even
- if the exact sequence is not typed. Only makes a
- difference how completion candidates are reduced from the
- list of alternatives, but not how the candidates are
- collected (using different completion types).
+ if the exact sequence is not typed. Note: This option
+ does not affect the collection of candidate list, it only
+ controls how completion candidates are reduced from the
+ list of alternatives. If you want to use |fuzzy-matching|
+ to gather more alternatives for your candidate list,
+ see |'completefuzzycollect'|.
longest Only insert the longest common text of the matches. If
the menu is displayed you can use CTRL-L to add more
diff --git a/runtime/lua/vim/_meta/options.lua b/runtime/lua/vim/_meta/options.lua
index 46366d585b..20d8ac3058 100644
--- a/runtime/lua/vim/_meta/options.lua
+++ b/runtime/lua/vim/_meta/options.lua
@@ -1044,6 +1044,31 @@ vim.o.cfu = vim.o.completefunc
vim.bo.completefunc = vim.o.completefunc
vim.bo.cfu = vim.bo.completefunc
+--- A comma-separated list of strings to enable fuzzy collection for
+--- specific `ins-completion` modes, affecting how matches are gathered
+--- during completion. For specified modes, fuzzy matching is used to
+--- find completion candidates instead of the standard prefix-based
+--- matching. This option can contain the following values:
+---
+--- keyword keywords in the current file `i_CTRL-X_CTRL-N`
+--- keywords with flags ".", "w", `i_CTRL-N` `i_CTRL-P`
+--- "b", "u", "U" and "k{dict}" in 'complete'
+--- keywords in 'dictionary' `i_CTRL-X_CTRL-K`
+---
+--- files file names `i_CTRL-X_CTRL-F`
+---
+--- whole_line whole lines `i_CTRL-X_CTRL-L`
+---
+--- When using the 'completeopt' "longest" option value, fuzzy collection
+--- can identify the longest common string among the best fuzzy matches
+--- and insert it automatically.
+---
+--- @type string
+vim.o.completefuzzycollect = ""
+vim.o.cfc = vim.o.completefuzzycollect
+vim.go.completefuzzycollect = vim.o.completefuzzycollect
+vim.go.cfc = vim.go.completefuzzycollect
+
--- A comma-separated list of strings that controls the alignment and
--- display order of items in the popup menu during Insert mode
--- completion. The supported values are "abbr", "kind", and "menu".
@@ -1063,10 +1088,12 @@ vim.go.cia = vim.go.completeitemalign
--- fuzzy Enable `fuzzy-matching` for completion candidates. This
--- allows for more flexible and intuitive matching, where
--- characters can be skipped and matches can be found even
---- if the exact sequence is not typed. Only makes a
---- difference how completion candidates are reduced from the
---- list of alternatives, but not how the candidates are
---- collected (using different completion types).
+--- if the exact sequence is not typed. Note: This option
+--- does not affect the collection of candidate list, it only
+--- controls how completion candidates are reduced from the
+--- list of alternatives. If you want to use `fuzzy-matching`
+--- to gather more alternatives for your candidate list,
+--- see `'completefuzzycollect'`.
---
--- longest Only insert the longest common text of the matches. If
--- the menu is displayed you can use CTRL-L to add more
diff --git a/runtime/optwin.vim b/runtime/optwin.vim
index dff3ce39a4..56fbb954a7 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 Feb 08
+" Last Change: 2025 Mar 07
" Former Maintainer: Bram Moolenaar <Bram@vim.org>
" If there already is an option window, jump to that one.
@@ -725,6 +725,8 @@ endif
if has("insert_expand")
call <SID>AddOption("complete", gettext("specifies how Insert mode completion works for CTRL-N and CTRL-P"))
call append("$", "\t" .. 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("completeopt", gettext("whether to use a popup menu for Insert mode completion"))
call <SID>OptionL("cot")