]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
fix: add filter to ultisnip list
authorOleksiy Hryshchenko <greeschenko@gmail.com>
Wed, 5 Apr 2023 17:53:54 +0000 (20:53 +0300)
committerOleksiy Hryshchenko <greeschenko@gmail.com>
Wed, 5 Apr 2023 17:53:54 +0000 (20:53 +0300)
autoload/lsp/completion.vim

index 4d04190e0ae879f47f8e7681e64dde5adc12daf6..2928d65260fffeb84e5cd0f8e32c970084b9d8e6 100644 (file)
@@ -92,9 +92,22 @@ export def CompletionReply(lspserver: dict<any>, 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<any>, 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<dict<any>> = []