]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Support partially typing the omni completed keyword
authorAndreas Louv <andreas@louv.dk>
Thu, 1 Dec 2022 13:18:41 +0000 (14:18 +0100)
committerAndreas Louv <andreas@louv.dk>
Thu, 9 Mar 2023 21:08:43 +0000 (22:08 +0100)
autoload/lsp/completion.vim

index 5c6554e382459bd7a2645b1c2c5ef74c24d1423f..ce4d9495d2b9ec898d05f38ac9c926267819d80d 100644 (file)
@@ -273,9 +273,12 @@ def g:LspOmniFunc(findstart: number, base: string): any
     # locate the start of the word
     var line = getline('.')
     var start = charcol('.') - 1
+    var keyword: string = ''
     while start > 0 && line[start - 1] =~ '\k'
+      keyword = line[start - 1] .. keyword
       start -= 1
     endwhile
+    lspserver.omniCompleteKeyword = keyword
     return start
   else
     # Wait for the list of matches from the LSP server
@@ -289,7 +292,7 @@ def g:LspOmniFunc(findstart: number, base: string): any
     endwhile
 
     var res: list<dict<any>> = lspserver.completeItems
-    return res->empty() ? v:none : res
+    return res->empty() ? v:none : res->filter((i, v) => v.word =~# '^' .. lspserver.omniCompleteKeyword)
   endif
 enddef