Add tsserver support

This commit is contained in:
w0rp
2017-06-08 17:28:38 +01:00
parent 64ad51048d
commit 5146332206
8 changed files with 247 additions and 72 deletions

View File

@@ -127,8 +127,8 @@ Execute(ale#lsp#tsserver_message#Change() should return correct messages):
\ 'file': b:dir . '/foo.ts',
\ 'line': 1,
\ 'offset': 1,
\ 'endLine': 3,
\ 'endOffset': 5,
\ 'endLine': 1073741824,
\ 'endOffset': 1,
\ 'insertString': "foo()\nbar()\nbaz()",
\ }
\ ],
@@ -139,7 +139,7 @@ Execute(ale#lsp#tsserver_message#Geterr() should return correct messages):
AssertEqual
\ [
\ 1,
\ 0,
\ 'ts@geterr',
\ {
\ 'files': [b:dir . '/foo.ts'],

View File

@@ -110,55 +110,63 @@ Execute(ale#lsp#CreateMessageData() should create tsserver notification messages
AssertEqual
\ [
\ 0,
\ '{"seq": null, "type": "request", "command": "someNotification"}',
\ '{"seq": null, "type": "request", "command": "someNotification"}'
\ . "\n",
\ ],
\ ale#lsp#CreateMessageData([1, 'ts@someNotification'])
AssertEqual
\ [
\ 0,
\ '{"seq": null, "arguments": {"foo": "bar"}, "type": "request", "command": "someNotification"}',
\ '{"seq": null, "arguments": {"foo": "bar"}, "type": "request", "command": "someNotification"}'
\ . "\n",
\ ],
\ ale#lsp#CreateMessageData([1, 'ts@someNotification', {'foo': 'bar'}])
else
AssertEqual
\ [
\ 0,
\ '{"seq":null,"type":"request","command":"someNotification"}',
\ '{"seq":null,"type":"request","command":"someNotification"}'
\ . "\n",
\ ],
\ ale#lsp#CreateMessageData([1, 'ts@someNotification'])
AssertEqual
\ [
\ 0,
\ '{"seq":null,"arguments":{"foo":"bar"},"type":"request","command":"someNotification"}',
\ '{"seq":null,"arguments":{"foo":"bar"},"type":"request","command":"someNotification"}'
\ . "\n",
\ ],
\ ale#lsp#CreateMessageData([1, 'ts@someNotification', {'foo': 'bar'}])
endif
Execute(ale#lsp#CreateMessageData() should create tsserver messages excepting responses):
Execute(ale#lsp#CreateMessageData() should create tsserver messages expecting responses):
if has('nvim')
AssertEqual
\ [
\ 1,
\ '{"seq": 1, "type": "request", "command": "someMessage"}',
\ '{"seq": 1, "type": "request", "command": "someMessage"}'
\ . "\n",
\ ],
\ ale#lsp#CreateMessageData([0, 'ts@someMessage'])
AssertEqual
\ [
\ 2,
\ '{"seq": 2, "arguments": {"foo": "bar"}, "type": "request", "command": "someMessage"}',
\ '{"seq": 2, "arguments": {"foo": "bar"}, "type": "request", "command": "someMessage"}'
\ . "\n",
\ ],
\ ale#lsp#CreateMessageData([0, 'ts@someMessage', {'foo': 'bar'}])
else
AssertEqual
\ [
\ 1,
\ '{"seq":1,"type":"request","command":"someMessage"}',
\ '{"seq":1,"type":"request","command":"someMessage"}'
\ . "\n",
\ ],
\ ale#lsp#CreateMessageData([0, 'ts@someMessage'])
AssertEqual
\ [
\ 2,
\ '{"seq":2,"arguments":{"foo":"bar"},"type":"request","command":"someMessage"}',
\ '{"seq":2,"arguments":{"foo":"bar"},"type":"request","command":"someMessage"}'
\ . "\n",
\ ],
\ ale#lsp#CreateMessageData([0, 'ts@someMessage', {'foo': 'bar'}])
endif

View File

@@ -13,7 +13,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle errors):
AssertEqual ['filename.ts', [
\ {
\ 'type': 'E',
\ 'message': 'Something went wrong!',
\ 'text': 'Something went wrong!',
\ 'lnum': 3,
\ 'col': 11,
\ 'end_lnum': 5,
@@ -34,7 +34,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle warnings):
AssertEqual ['filename.ts', [
\ {
\ 'type': 'W',
\ 'message': 'Something went wrong!',
\ 'text': 'Something went wrong!',
\ 'lnum': 2,
\ 'col': 4,
\ 'end_lnum': 2,
@@ -55,7 +55,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should treat messages with missing se
AssertEqual ['filename.ts', [
\ {
\ 'type': 'E',
\ 'message': 'Something went wrong!',
\ 'text': 'Something went wrong!',
\ 'lnum': 3,
\ 'col': 11,
\ 'end_lnum': 5,
@@ -75,7 +75,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle messages without codes)
AssertEqual ['filename.ts', [
\ {
\ 'type': 'E',
\ 'message': 'Something went wrong!',
\ 'text': 'Something went wrong!',
\ 'lnum': 3,
\ 'col': 11,
\ 'end_lnum': 5,
@@ -93,7 +93,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle multiple messages):
AssertEqual ['filename.ts', [
\ {
\ 'type': 'E',
\ 'message': 'Something went wrong!',
\ 'text': 'Something went wrong!',
\ 'lnum': 1,
\ 'col': 3,
\ 'end_lnum': 1,
@@ -101,7 +101,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle multiple messages):
\ },
\ {
\ 'type': 'W',
\ 'message': 'A warning',
\ 'text': 'A warning',
\ 'lnum': 2,
\ 'col': 5,
\ 'end_lnum': 2,
@@ -119,3 +119,17 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle multiple messages):
\ 'message': 'A warning',
\ },
\ ]})
Execute(ale#lsp#response#ReadTSServerDiagnostics() should handle tsserver responses):
AssertEqual [
\ {
\ 'type': 'E',
\ 'nr': 2365,
\ 'text': 'Operator ''''+'''' cannot be applied to types ''''3'''' and ''''{}''''.',
\ 'lnum': 1,
\ 'col': 11,
\ 'end_lnum': 1,
\ 'end_col': 17,
\ },
\],
\ ale#lsp#response#ReadTSServerDiagnostics({"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/bar/foo.ts","diagnostics":[{"start":{"line":1,"offset":11},"end":{"line":1,"offset":17},"text":"Operator ''+'' cannot be applied to types ''3'' and ''{}''.","code":2365}]}})