summaryrefslogtreecommitdiff
path: root/vim/pack/downloads/opt/lsp/test/tsserver_tests.vim
blob: 99e28368beeba952da377a3d0d0f28582ef8ff14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
vim9script
# Unit tests for Vim Language Server Protocol (LSP) typescript client

source common.vim
source term_util.vim
source screendump.vim

var lspServers = [{
      filetype: ['typescript', 'javascript'],
      path: exepath('typescript-language-server'),
      args: ['--stdio']
  }]
call LspAddServer(lspServers)
echomsg systemlist($'{lspServers[0].path} --version')

# Test for auto-completion.  Make sure that only keywords that matches with the
# keyword before the cursor are shown.
# def g:Test_LspCompletion1()
#   var lines =<< trim END
#     const http = require('http')
#     http.cr
#   END
#   writefile(lines, 'Xcompletion1.js')
#   var buf = g:RunVimInTerminal('--cmd "silent so start_tsserver.vim" Xcompletion1.js', {rows: 10, wait_for_ruler: 1})
#   sleep 5
#   term_sendkeys(buf, "GAe")
#   g:TermWait(buf)
#   g:VerifyScreenDump(buf, 'Test_tsserver_completion_1', {})
#   term_sendkeys(buf, "\<BS>")
#   g:TermWait(buf)
#   g:VerifyScreenDump(buf, 'Test_tsserver_completion_2', {})
# 
#   g:StopVimInTerminal(buf)
#   delete('Xcompletion1.js')
# enddef

# Start the typescript language server.  Returns true on success and false on
# failure.
def g:StartLangServer(): bool
  return g:StartLangServerWithFile('Xtest.ts')
enddef

# vim: shiftwidth=2 softtabstop=2 noexpandtab