[mini.completion] Fuzzy matching with blink.cmp algorithm #1771
Replies: 1 comment 4 replies
-
Yes, this is because there is a high bonus in built-in Vim's fuzzy matching for camel case word start. It also seems to favor matches at the end and not the start. This was addressed in neovim/neovim#32953, which unfortunately is a Neovim>=0.12 only. So local lsp_get_filterword = function(x) return x.filterText or x.label end
local filtersort = function(items, base)
if base == '' then return vim.deepcopy(items) end
return vim.fn.matchfuzzy(items, base, { text_cb = lsp_get_filterword, camelcase = false })
end
local process_opts = { filtersort = filtersort }
local process_items = function(items, base) return MiniCompletion.default_process_items(items, base, process_opts) end
require('mini.completion').setup({ lsp_completion = { process_items = process_items } }) The problem with using this as default is because it will work only if LSP server always returns Unfortunately, currently there is no way to tweak built-in fuzzy completion behavior (beyond just enabling that). Maybe @glepnir can help with that 👀? |
Beta Was this translation helpful? Give feedback.
-
mini_completion_blinked.mp4
Init.lua
Example code(rust)
Sometimes, using provided
fuzzy
matching does not result in optimal code completion.In the video above, I am adding
PhantomData<State>
to the line containing// d2:
.As demonstrated, I need to type
State
completely before it shows at the top of the completion list. Apparently,State
is a word used often inside core rust libraries ...)The fuzzy-matching part of
blink.cmp
uses afrecency
andproximity
bonus. As such,State
becomes first in the completion list when I typeS
.I want to keep using
mini.completion
and wrote some code to bridgemini
withblink.cmp
. The core idea is to override process_items, providing a custom function for opts.filtersort.I am using blink's fuzzy in the following way:
Beta Was this translation helpful? Give feedback.
All reactions