From 5e35015c09b256c033d8ed2005c7ecd1d31b9a8a Mon Sep 17 00:00:00 2001 From: Oleksiy Hryshchenko Date: Wed, 5 Apr 2023 20:53:54 +0300 Subject: [PATCH] fix: add filter to ultisnip list --- autoload/lsp/completion.vim | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/autoload/lsp/completion.vim b/autoload/lsp/completion.vim index 4d04190..2928d65 100644 --- a/autoload/lsp/completion.vim +++ b/autoload/lsp/completion.vim @@ -92,9 +92,22 @@ export def CompletionReply(lspserver: dict, cItems: any) lspserver.completeItemsIsIncomplete = cItems.isIncomplete endif + # Get the keyword prefix before the current cursor column. + var chcol = charcol('.') + var starttext = chcol == 1 ? '' : getline('.')[ : chcol - 2] + var [prefix, start_idx, end_idx] = starttext->matchstrpos('\k*$') + if opt.lspOptions.completionMatcher == 'icase' + prefix = prefix->tolower() + endif + + var start_col = start_idx + 1 + if opt.lspOptions.ultisnipsSupport call UltiSnips#SnippetsInCurrentScope(1) for [key, info] in items(g:current_ulti_dict_info) + if matchfuzzy([key], prefix)->empty() + continue + endif var parts = split(info.location, ':') var txt = readfile(parts[0])[str2nr(parts[1]) : str2nr(parts[1]) + 20] var restxt = info.description .. "\n\n" @@ -117,16 +130,6 @@ export def CompletionReply(lspserver: dict, cItems: any) endfor endif - # Get the keyword prefix before the current cursor column. - var chcol = charcol('.') - var starttext = chcol == 1 ? '' : getline('.')[ : chcol - 2] - var [prefix, start_idx, end_idx] = starttext->matchstrpos('\k*$') - if opt.lspOptions.completionMatcher == 'icase' - prefix = prefix->tolower() - endif - - var start_col = start_idx + 1 - #writefile([$'chcol = {chcol}, starttext = [{starttext}], prefix = [{prefix}], start_idx = {start_idx}, end_idx = {end_idx}, start_col = {start_col}'], '/tmp/lspcomplete.log', 'a') var completeItems: list> = [] -- 2.48.1