5 # Integration with the UltiSnips plugin
6 export def CompletionUltiSnips(prefix: string, items: list<dict<any>>)
7 call UltiSnips#SnippetsInCurrentScope(1)
8 for key in matchfuzzy(g:current_ulti_dict_info->keys(), prefix)
9 var item = g:current_ulti_dict_info[key]
10 var parts = split(item.location, ':')
11 var txt = parts[0]->readfile()[parts[1]->str2nr() : parts[1]->str2nr() + 20]
12 var restxt = item.description .. "\n\n"
14 if line->empty() || line[0 : 6] == "snippet"
17 restxt = restxt .. line .. "\n"
26 documentation: restxt,
31 # Integration with the vim-vsnip plugin
32 export def CompletionVsnip(items: list<dict<any>>)
33 def Pattern(abbr: string): string
34 var chars = escape(abbr, '\/?')->split('\zs')
35 var chars_pattern = '\%(\V' .. chars->join('\m\|\V') .. '\m\)'
36 var separator = chars[0] =~ '\a' ? '\<' : ''
37 return $'{separator}\V{chars[0]}\m{chars_pattern}*$'
43 var starttext = getline('.')->slice(0, charcol('.') - 1)
44 for item in vsnip#get_complete_items(bufnr())
45 var match = starttext->matchstrpos(Pattern(item.abbr))
47 var user_data = item.user_data->json_decode()
48 var documentation = []
49 for line in vsnip#to_string(user_data.vsnip.snippet)->split("\n")
50 documentation->add(line)
54 filterText: item.word,
57 newText: user_data.vsnip.snippet->join("\n"),
70 entryNames: [item.word],
75 value: documentation->join("\n"),
82 # vim: tabstop=8 shiftwidth=2 softtabstop=2