X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/5a4872f466ebd76ddd532bdf2798554421c53df4..fe3919e725e156d751069662d11e38f7b4791de1:/.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 index 00000000..57c524e6 --- /dev/null +++ b/.vim/bundle/vim-lsp/test/utils/autoload/lsp/test.vim @@ -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