- name: Install packages
run: |
sudo apt update
+ # install clangd language server
sudo apt install -y clangd-14
+ # install nodejs
sudo apt install -y curl
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo bash -
sudo apt install -y nodejs
+ # install typescript language server
sudo npm install -g typescript-language-server typescript
+ # install golang language server
+ sudo apt install -y golang
+ sudo apt install -y gopls
- name: Setup Vim
uses: rhysd/action-setup-vim@v1
id: vim
--- /dev/null
+vim9script
+# Unit tests for Vim Language Server Protocol (LSP) golang client
+
+source common.vim
+
+var lspServers = [{
+ filetype: ['go'],
+ path: exepath('gopls'),
+ args: ['serve']
+ }]
+call LspAddServer(lspServers)
+echomsg systemlist($'{lspServers[0].path} version')
+
+# Test for :LspGotoDefinition, :LspGotoDeclaration, etc.
+def g:Test_LspGoto()
+ :silent! edit Xtest.go
+ sleep 200m
+
+ var lines =<< trim END
+ package main
+
+ func foo() {
+ }
+
+ func bar() {
+ foo();
+ }
+ END
+
+ setline(1, lines)
+ :redraw!
+ g:WaitForServerFileLoad(0)
+
+ cursor(7, 1)
+ :LspGotoDefinition
+ assert_equal([3, 6], [line('.'), col('.')])
+ exe "normal! \<C-t>"
+ assert_equal([7, 1], [line('.'), col('.')])
+
+ bw!
+enddef
+
+# Start the gopls language server. Returns true on success and false on
+# failure.
+def g:StartLangServer(): bool
+ return g:StartLangServerWithFile('Xtest.go')
+enddef
+
+# vim: shiftwidth=2 softtabstop=2 noexpandtab
VIM_CMD="$VIMPRG -u NONE -U NONE -i NONE --noplugin -N --not-a-term"
-TESTS="tsserver_tests.vim clangd_tests.vim"
+TESTS="clangd_tests.vim tsserver_tests.vim gopls_tests.vim"
for testfile in $TESTS
do
endfor
g:LspOptionsSet({showDiagInPopup: true})
- :%bw!
+ bw!
enddef
+# Test for :LspGotoDefinition, :LspGotoDeclaration, etc.
def g:Test_LspGoto()
:silent! edit Xtest.ts
sleep 200m
assert_equal(3, line('.'))
assert_equal([], popup_list())
popup_clear()
+
+ bw!
enddef
# Test for auto-completion. Make sure that only keywords that matches with the