autoload/lsp.vim | 7 +++++-- autoload/symbol.vim | 6 +++--- test/run_tests.sh | 4 +++- test/unit_tests.vim | 26 ++++++++++++++++++++++++++ diff --git a/autoload/lsp.vim b/autoload/lsp.vim index 772da603016cf563bbfb570bd86996ecf3c4001e..45807827a0ada708f3b328ccc4ae088cfeb2c01a 100644 --- a/autoload/lsp.vim +++ b/autoload/lsp.vim @@ -622,9 +622,12 @@ start -= 1 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 diff --git a/autoload/symbol.vim b/autoload/symbol.vim index 2bdb062f6f8d037f481ccfe439bd3ff27b443c1c..e46887df0f1444adb38ce75d963cabda1677aa2a 100644 --- a/autoload/symbol.vim +++ b/autoload/symbol.vim @@ -261,7 +261,6 @@ # jump to the file and line containing the symbol 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 @@ else 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 diff --git a/test/run_tests.sh b/test/run_tests.sh index 39d5cec35a06a6533e9187144a699d4f7fef27fb..040395958167998ac9bd48d50099e8dc3e5e3efc 100755 --- a/test/run_tests.sh +++ b/test/run_tests.sh @@ -2,7 +2,9 @@ #!/bin/bash # 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 diff --git a/test/unit_tests.vim b/test/unit_tests.vim index 0b3057da2a76b87d75aa5a624d87297fdef2af05..a7d6e1d9632b00d408f20a4cb27b3aac023186c2 100644 --- a/test/unit_tests.vim +++ b/test/unit_tests.vim @@ -630,6 +630,32 @@ popup_close(p[0]) :%bw! enddef +# Test for LSP omni completion +def Test_omnicomplete() + lsp#setOptions({'autoComplete': v:false}) + silent! edit Xtest.c + var lines: list =<< trim END + void MyFunc1(void) + { + } + + void MyFunc2(void) + { + } + + void f1(void) + { + } + END + setline(1, lines) + :sleep 1 + cursor(10, 1) + feedkeys("oMy\\\();", "xt") + assert_equal("\tMyFunc2();", getline('.')) + :%bw! + lsp#setOptions({'autoComplete': v:true}) +enddef + def LspRunTests() :set nomore :set debug=beep