From 31f3ec85ae2cd6d52c29bc6307063d2585ff0f34 Mon Sep 17 00:00:00 2001 From: Girish Palya Date: Tue, 6 Feb 2024 13:12:28 +0100 Subject: [PATCH 1/2] BUG: omnifuc throws E716 In LspOmniFunc() when cItems is empty (when findstart=1) it does not set the key 'completeItemsIsIncomplete' in the lspserver dictionary. When LspOmniFunc is called again with findstart=0, it fails. line 46: E716: Key not present in Dictionary: "completeItemsIsIncomplete" This affects rust, nix, and other lsp servers: https://github.com/girishji/vimcomplete/issues/14 M autoload/lsp/completion.vim --- autoload/lsp/completion.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autoload/lsp/completion.vim b/autoload/lsp/completion.vim index 4ea35777..aa93db1e 100644 --- a/autoload/lsp/completion.vim +++ b/autoload/lsp/completion.vim @@ -147,6 +147,7 @@ enddef # process the 'textDocument/completion' reply from the LSP server # Result: CompletionItem[] | CompletionList | null export def CompletionReply(lspserver: dict, cItems: any) + lspserver.completeItemsIsIncomplete = false if cItems->empty() if lspserver.omniCompletePending lspserver.completeItems = [] @@ -155,8 +156,6 @@ export def CompletionReply(lspserver: dict, cItems: any) return endif - lspserver.completeItemsIsIncomplete = false - var items: list> if cItems->type() == v:t_list items = cItems @@ -469,6 +468,7 @@ enddef # omni complete handler def g:LspOmniFunc(findstart: number, base: string): any + var lspserver: dict = buf.CurbufGetServerChecked('completion') if lspserver->empty() return -2 From 6b440f1a342bfca374ded247a0208001d19db326 Mon Sep 17 00:00:00 2001 From: Girish Palya Date: Tue, 6 Feb 2024 13:15:24 +0100 Subject: [PATCH 2/2] remove empty line M autoload/lsp/completion.vim --- autoload/lsp/completion.vim | 1 - 1 file changed, 1 deletion(-) diff --git a/autoload/lsp/completion.vim b/autoload/lsp/completion.vim index aa93db1e..de1b718e 100644 --- a/autoload/lsp/completion.vim +++ b/autoload/lsp/completion.vim @@ -468,7 +468,6 @@ enddef # omni complete handler def g:LspOmniFunc(findstart: number, base: string): any - var lspserver: dict = buf.CurbufGetServerChecked('completion') if lspserver->empty() return -2