]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Update the loop that waits for matches for omni-completion
authorYegappan Lakshmanan <yegappan@yahoo.com>
Thu, 27 Jan 2022 04:35:36 +0000 (20:35 -0800)
committerYegappan Lakshmanan <yegappan@yahoo.com>
Thu, 27 Jan 2022 04:35:36 +0000 (20:35 -0800)
autoload/lsp.vim
autoload/symbol.vim
test/run_tests.sh
test/unit_tests.vim

index 772da603016cf563bbfb570bd86996ecf3c4001e..45807827a0ada708f3b328ccc4ae088cfeb2c01a 100644 (file)
@@ -622,9 +622,12 @@ def lsp#omniFunc(findstart: number, base: string): any
     endwhile
     return start
   else
+    # Wait for the list of matches from the LSP server
     var count: number = 0
-    while !complete_check() && lspserver.completePending
-                               && count < 1000
+    while lspserver.completePending && count < 1000
+      if complete_check()
+       return v:none
+      endif
       sleep 2m
       count += 1
     endwhile
index 2bdb062f6f8d037f481ccfe439bd3ff27b443c1c..e46887df0f1444adb38ce75d963cabda1677aa2a 100644 (file)
@@ -261,7 +261,6 @@ export def GotoSymbol(lspserver: dict<any>, location: dict<any>, type: string)
     var wid = fname->bufwinid()
     if wid != -1
       wid->win_gotoid()
-      normal! m`
     else
       var bnr: number = fname->bufnr()
       if bnr != -1
@@ -279,9 +278,10 @@ export def GotoSymbol(lspserver: dict<any>, location: dict<any>, type: string)
           exe 'edit  ' .. fname
         endif
       endif
-      setpos("'`", getcurpos())
     endif
-    # Set the previous cursor location mark
+    # Set the previous cursor location mark. Instead of using setpos(), m' is
+    # used so that the current location is added to the jump list.
+    normal m'
     setcursorcharpos(location.range.start.line + 1,
                        location.range.start.character + 1)
   endif
index 39d5cec35a06a6533e9187144a699d4f7fef27fb..040395958167998ac9bd48d50099e8dc3e5e3efc 100755 (executable)
@@ -2,7 +2,9 @@
 
 # Script to run the unit-tests for the LSP Vim plugin
 
-VIMPRG=${VIMPRG:=/usr/bin/vim}
+#VIMPRG=${VIMPRG:=/usr/bin/vim}
+export VIMRUNTIME=/home/yega/Documents/vim/opfunc/vim/runtime
+VIMPRG=/home/yega/Documents/vim/opfunc/vim/src/vim
 VIM_CMD="$VIMPRG -u NONE -U NONE -i NONE --noplugin -N --not-a-term"
 
 $VIM_CMD -S unit_tests.vim
index 0b3057da2a76b87d75aa5a624d87297fdef2af05..a7d6e1d9632b00d408f20a4cb27b3aac023186c2 100644 (file)
@@ -630,6 +630,32 @@ def Test_LspShowSignature()
   :%bw!
 enddef
 
+# Test for LSP omni completion
+def Test_omnicomplete()
+  lsp#setOptions({'autoComplete': v:false})
+  silent! edit Xtest.c
+  var lines: list<string> =<< trim END
+    void MyFunc1(void)
+    {
+    }
+
+    void MyFunc2(void)
+    {
+    }
+
+    void f1(void)
+    {
+    }
+  END
+  setline(1, lines)
+  :sleep 1
+  cursor(10, 1)
+  feedkeys("oMy\<C-X>\<C-O>\<C-N>();", "xt")
+  assert_equal("\tMyFunc2();", getline('.'))
+  :%bw!
+  lsp#setOptions({'autoComplete': v:true})
+enddef
+
 def LspRunTests()
   :set nomore
   :set debug=beep