]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Respect "isIncomplete" when omni completing
authorAndreas Louv <andreas@louv.dk>
Sun, 19 Mar 2023 10:30:38 +0000 (11:30 +0100)
committerAndreas Louv <andreas@louv.dk>
Sun, 19 Mar 2023 10:52:16 +0000 (11:52 +0100)
The specifications states:

> for speed clients should be able to filter an already received
> completion list if the user continues typing. Servers can opt out of
> this using a CompletionList and mark it as isIncomplete

autoload/lsp/completion.vim

index e50f2a01b25cda21ce59ab17d8701150d74d1190..5932990412450cfcc246da3c98897e920e0660e3 100644 (file)
@@ -78,11 +78,14 @@ export def CompletionReply(lspserver: dict<any>, cItems: any)
     return
   endif
 
+  lspserver.completeItemsIsIncomplete = false
+
   var items: list<dict<any>>
   if cItems->type() == v:t_list
     items = cItems
   else
     items = cItems.items
+    lspserver.completeItemsIsIncomplete = cItems.isIncomplete
   endif
 
   # Get the keyword prefix before the current cursor column.
@@ -301,6 +304,12 @@ def g:LspOmniFunc(findstart: number, base: string): any
     endwhile
 
     var res: list<dict<any>> = lspserver.completeItems
+
+    # Don't attempt to filter on the items, when "isIncomplete" is set
+    if lspserver.completeItemsIsIncomplete
+      return res->empty() ? v:none : res
+    endif
+
     return res->empty() ? v:none : res->filter((i, v) => v.word =~# '^' .. lspserver.omniCompleteKeyword)
   endif
 enddef