Skip to main content
Deno 2 is finally here ๐ŸŽ‰๏ธ
Learn more
Module

x/denops_std/function/vim/mod.ts>matchfuzzy

๐Ÿ“š Standard module for denops.vim
Go to Latest
function matchfuzzy
import { matchfuzzy } from "https://deno.land/x/denops_std@v3.6.0/function/vim/mod.ts";

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 and {str} contains multiple words separated by white space, then returns only matches that contain the words in the given sequence. 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. Refer to |fuzzy-match| 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'].

Parameters

denops: Denops
list: unknown
str: unknown
optional
dict: unknown

Returns

Promise<unknown>