]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Respect when "&completeopt" doesn't contain "preview"
authorAndreas Louv <andreas@louv.dk>
Mon, 22 May 2023 20:57:03 +0000 (22:57 +0200)
committerAndreas Louv <andreas@louv.dk>
Mon, 22 May 2023 21:05:27 +0000 (23:05 +0200)
autoload/lsp/completion.vim

index 444ec0827ffe351f30deacfbe44ae0c368d39f33..a8ef1a9cd6a4e3ab374994a77c92658c88a5f248 100644 (file)
@@ -404,15 +404,16 @@ def ShowCompletionDocumentation(cItem: any)
     id->popup_show()
   else
     # &omnifunc with &completeopt =~ 'preview'
-    execute $':silent! pedit Completion'
-    :wincmd P
-    :setlocal buftype=nofile
-    :setlocal bufhidden=delete
-    bufnr()->deletebufline(1, '$')
-    infoText->append(0)
-    [1, 1]->cursor()
-    exe $'setlocal ft={infoKind}'
-    :wincmd p
+    try
+      :wincmd P
+      :setlocal modifiable
+      bufnr()->deletebufline(1, '$')
+      infoText->append(0)
+      [1, 1]->cursor()
+      exe $'setlocal ft={infoKind}'
+      :wincmd p
+    catch /E441/ # No preview window
+    endtry
   endif
 enddef