import { fn } from "https://deno.land/x/ddc_vim@v4.0.2/deps.ts";
const { matchfuzzy } = fn;
If {list} is a list of strings, then returns a List
with all
the strings in {list} that fuzzy match {str}. The strings in
the returned list are sorted based on the matching score.
The optional {dict} argument always supports the following items: matchseq When this item is present return only matches that contain the characters in {str} in the given sequence. limit Maximum number of matches in {list} to be returned. Zero means no limit.
If {list} is a list of dictionaries, then the optional {dict}
argument supports the following additional items:
key Key of the item which is fuzzy matched against
{str}. The value of this item should be a
string.
text_cb Funcref
that will be called for every item
in {list} to get the text for fuzzy matching.
This should accept a dictionary item as the
argument and return the text for that item to
use for fuzzy matching.
{str} is treated as a literal string and regular expression matching is NOT supported. The maximum supported {str} length is 256.
When {str} has multiple words each separated by white space, then the list of strings that have all the words is returned.
If there are no matching strings or there is an error, then an empty list is returned. If length of {str} is greater than 256, then returns an empty list.
When {limit} is given, matchfuzzy() will find up to this number of matches in {list} and return them in sorted order.
Refer to fuzzy-matching
for more information about fuzzy
matching strings.
Example:
:echo matchfuzzy(["clay", "crow"], "cay")
results in ["clay"].
:echo getbufinfo()->map({_, v -> v.name})->matchfuzzy("ndl")
results in a list of buffer names fuzzy matching "ndl".
:echo getbufinfo()->matchfuzzy("ndl", {'key' : 'name'})
results in a list of buffer information dicts with buffer names fuzzy matching "ndl".
:echo getbufinfo()->matchfuzzy("spl",
\ {'text_cb' : {v -> v.name}})
results in a list of buffer information dicts with buffer names fuzzy matching "spl".
:echo v:oldfiles->matchfuzzy("test")
results in a list of file names fuzzy matching "test".
:let l = readfile("buffer.c")->matchfuzzy("str")
results in a list of lines in "buffer.c" fuzzy matching "str".
:echo ['one two', 'two one']->matchfuzzy('two one')
results in ['two one', 'one two'].
:echo ['one two', 'two one']->matchfuzzy('two one',
\ {'matchseq': 1})
results in ['two one'].