]> git.madduck.net Git - etc/vim.git/blobdiff - .vim/bundle/vim-lsp/test/utils/autoload/lsp/test.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit 'a39f715c13be3352193ffd9c5b7536b8786eff64' as '.vim/bundle/vim-lsp'
[etc/vim.git] / .vim / bundle / vim-lsp / test / utils / autoload / lsp / test.vim
diff --git a/.vim/bundle/vim-lsp/test/utils/autoload/lsp/test.vim b/.vim/bundle/vim-lsp/test/utils/autoload/lsp/test.vim
new file mode 100644 (file)
index 0000000..57c524e
--- /dev/null
@@ -0,0 +1,50 @@
+function! lsp#test#projectdir(name) abort
+    if a:name ==# 'rust'
+        return expand('%:p:h') .'/test/testproject-rust'
+    elseif a:name ==# 'go'
+        return expand('%:p:h') .'/test/testproject-go'
+    else
+        throw 'projectdir not supported for ' . a:name
+    endif
+endfunction
+
+function! lsp#test#openproject(name, options) abort
+    if a:name ==# 'go'
+        filetype on
+
+        call lsp#register_server({
+            \ 'name': 'gopls',
+            \ 'cmd': ['gopls'],
+            \ 'allowlist': ['go'],
+            \ })
+
+        call lsp#enable()
+
+        " open .go file to trigger gopls then close it
+        execute printf('keepalt keepjumps edit %s', lsp#test#projectdir(a:name) . '/documentformat.go')
+        " wait for server starting
+        call lsp#test#wait(10000, {-> lsp#get_server_status('gopls') ==# 'running' })
+
+        %bwipeout!
+    else
+        throw 'open project not not supported for ' . a:name
+    endif
+endfunction
+
+function! lsp#test#closeproject(name) abort
+    if lsp#test#hasproject(a:name)
+        silent! call lsp#stop_sserver(a:name)
+    endif
+endfunction
+
+function! lsp#test#hasproject(name) abort
+    if a:name ==# 'go' && executable('gopls')
+        return 1
+    else
+        return 0
+    endif
+endfunction
+
+function! lsp#test#wait(timeout, condition) abort
+    call lsp#utils#_wait(a:timeout, a:condition)
+endfunction