]> git.madduck.net Git - etc/vim.git/blob - .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
1 function! lsp#test#projectdir(name) abort
2     if a:name ==# 'rust'
3         return expand('%:p:h') .'/test/testproject-rust'
4     elseif a:name ==# 'go'
5         return expand('%:p:h') .'/test/testproject-go'
6     else
7         throw 'projectdir not supported for ' . a:name
8     endif
9 endfunction
10
11 function! lsp#test#openproject(name, options) abort
12     if a:name ==# 'go'
13         filetype on
14
15         call lsp#register_server({
16             \ 'name': 'gopls',
17             \ 'cmd': ['gopls'],
18             \ 'allowlist': ['go'],
19             \ })
20
21         call lsp#enable()
22
23         " open .go file to trigger gopls then close it
24         execute printf('keepalt keepjumps edit %s', lsp#test#projectdir(a:name) . '/documentformat.go')
25         " wait for server starting
26         call lsp#test#wait(10000, {-> lsp#get_server_status('gopls') ==# 'running' })
27
28         %bwipeout!
29     else
30         throw 'open project not not supported for ' . a:name
31     endif
32 endfunction
33
34 function! lsp#test#closeproject(name) abort
35     if lsp#test#hasproject(a:name)
36         silent! call lsp#stop_sserver(a:name)
37     endif
38 endfunction
39
40 function! lsp#test#hasproject(name) abort
41     if a:name ==# 'go' && executable('gopls')
42         return 1
43     else
44         return 0
45     endif
46 endfunction
47
48 function! lsp#test#wait(timeout, condition) abort
49     call lsp#utils#_wait(a:timeout, a:condition)
50 endfunction