From 2768bf15ba5ca95f126405459c4a8180e814af18 Mon Sep 17 00:00:00 2001 From: Fred Emmott Date: Mon, 30 Jul 2018 15:19:59 -0700 Subject: Handle LSP codes for `%code%` in message formats fixes #1767 --- test/lsp/test_read_lsp_diagnostics.vader | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'test/lsp') diff --git a/test/lsp/test_read_lsp_diagnostics.vader b/test/lsp/test_read_lsp_diagnostics.vader index 444272aa..134a7161 100644 --- a/test/lsp/test_read_lsp_diagnostics.vader +++ b/test/lsp/test_read_lsp_diagnostics.vader @@ -18,7 +18,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle errors): \ 'col': 11, \ 'end_lnum': 5, \ 'end_col': 16, - \ 'nr': 'some-error', + \ 'code': 'some-error', \ } \ ], \ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [ @@ -39,7 +39,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle warnings): \ 'col': 4, \ 'end_lnum': 2, \ 'end_col': 4, - \ 'nr': 'some-warning', + \ 'code': 'some-warning', \ } \ ], \ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [ @@ -60,7 +60,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should treat messages with missing se \ 'col': 11, \ 'end_lnum': 5, \ 'end_col': 16, - \ 'nr': 'some-error', + \ 'code': 'some-error', \ } \ ], \ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [ @@ -126,6 +126,7 @@ Execute(ale#lsp#response#ReadTSServerDiagnostics() should handle tsserver respon \ { \ 'type': 'E', \ 'nr': 2365, + \ 'code': '2365', \ 'text': 'Operator ''''+'''' cannot be applied to types ''''3'''' and ''''{}''''.', \ 'lnum': 1, \ 'col': 11, @@ -142,6 +143,7 @@ Execute(ale#lsp#response#ReadTSServerDiagnostics() should handle warnings from t \ 'lnum': 27, \ 'col': 3, \ 'nr': 2515, + \ 'code': '2515', \ 'end_lnum': 27, \ 'type': 'W', \ 'end_col': 14, @@ -157,6 +159,7 @@ Execute(ale#lsp#response#ReadTSServerDiagnostics() should handle suggestions fro \ 'lnum': 27, \ 'col': 3, \ 'nr': 2515, + \ 'code': '2515', \ 'end_lnum': 27, \ 'type': 'I', \ 'end_col': 14, -- cgit v1.2.3 From 04362c746d7b73b03eb85d8936bd285a841a4704 Mon Sep 17 00:00:00 2001 From: Fred Emmott Date: Thu, 2 Aug 2018 09:30:22 -0700 Subject: Add test for LSP code of -1 --- test/lsp/test_read_lsp_diagnostics.vader | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/lsp') diff --git a/test/lsp/test_read_lsp_diagnostics.vader b/test/lsp/test_read_lsp_diagnostics.vader index 134a7161..df187a24 100644 --- a/test/lsp/test_read_lsp_diagnostics.vader +++ b/test/lsp/test_read_lsp_diagnostics.vader @@ -89,6 +89,26 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle messages without codes) \ }, \ ]}}) +Execute(ale#lsp#response#ReadDiagnostics() should consider -1 to be a meaningless code): + AssertEqual [ + \ { + \ 'type': 'E', + \ 'text': 'Something went wrong!', + \ 'lnum': 3, + \ 'col': 11, + \ 'end_lnum': 5, + \ 'end_col': 16, + \ } + \ ], + \ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [ + \ { + \ 'range': Range(2, 10, 4, 15), + \ 'message': 'Something went wrong!', + \ 'code': -1, + \ }, + \ ]}}) + + Execute(ale#lsp#response#ReadDiagnostics() should handle multiple messages): AssertEqual [ \ { -- cgit v1.2.3 From 484a70f0c0c9109ab6825fa67e481d862237207c Mon Sep 17 00:00:00 2001 From: Fred Emmott Date: Wed, 15 Aug 2018 14:19:32 -0700 Subject: Use new-ish LSP 'relatedInformation' field for :ALEDetail --- test/lsp/test_read_lsp_diagnostics.vader | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'test/lsp') diff --git a/test/lsp/test_read_lsp_diagnostics.vader b/test/lsp/test_read_lsp_diagnostics.vader index df187a24..c1df55f0 100644 --- a/test/lsp/test_read_lsp_diagnostics.vader +++ b/test/lsp/test_read_lsp_diagnostics.vader @@ -140,6 +140,35 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle multiple messages): \ }, \ ]}}) +Execute(ale#lsp#response#ReadDiagnostics() should use relatedInformation for detail): + AssertEqual [ + \ { + \ 'type': 'E', + \ 'text': 'Something went wrong!', + \ 'lnum': 1, + \ 'col': 3, + \ 'end_lnum': 1, + \ 'end_col': 3, + \ 'relatedInformation': [{ + \ 'message': 'might be this', + \ 'location': { + \ 'uri': 'file:///tmp/someotherfile.txt', + \ 'range': { + \ 'start': { 'line': 42, 'character': 79 }, + \ 'end': { 'line': 43, 'character': 80 }, + \ } + \ } + \ }] + \ } + \ ], + \ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [ + \ { + \ 'range': Range(0, 2, 0, 2), + \ 'message': 'Something went wrong!', + \ 'detail': 'file:///tmp/someotherfile.txt:42:79: might be this' + \ } + \ ]}}) + Execute(ale#lsp#response#ReadTSServerDiagnostics() should handle tsserver responses): AssertEqual \ [ -- cgit v1.2.3 From c467db3ed99dc7c911ddb1fefa9d66ac84fc76a6 Mon Sep 17 00:00:00 2001 From: Fred Emmott Date: Wed, 15 Aug 2018 14:31:30 -0700 Subject: Better formatting --- test/lsp/test_read_lsp_diagnostics.vader | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/lsp') diff --git a/test/lsp/test_read_lsp_diagnostics.vader b/test/lsp/test_read_lsp_diagnostics.vader index c1df55f0..6708ad2f 100644 --- a/test/lsp/test_read_lsp_diagnostics.vader +++ b/test/lsp/test_read_lsp_diagnostics.vader @@ -165,7 +165,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should use relatedInformation for det \ { \ 'range': Range(0, 2, 0, 2), \ 'message': 'Something went wrong!', - \ 'detail': 'file:///tmp/someotherfile.txt:42:79: might be this' + \ 'detail': "Something went wrong!\n/tmp/someotherfile.txt:42:79:\n\tmight be this" \ } \ ]}}) -- cgit v1.2.3 From 764da48c576c2be6b6d02ae6a7f59f9167b11de3 Mon Sep 17 00:00:00 2001 From: Fred Emmott Date: Wed, 15 Aug 2018 14:40:51 -0700 Subject: Test file was the wrong way around --- test/lsp/test_read_lsp_diagnostics.vader | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'test/lsp') diff --git a/test/lsp/test_read_lsp_diagnostics.vader b/test/lsp/test_read_lsp_diagnostics.vader index 6708ad2f..d795ae29 100644 --- a/test/lsp/test_read_lsp_diagnostics.vader +++ b/test/lsp/test_read_lsp_diagnostics.vader @@ -149,6 +149,13 @@ Execute(ale#lsp#response#ReadDiagnostics() should use relatedInformation for det \ 'col': 3, \ 'end_lnum': 1, \ 'end_col': 3, + \ 'detail': "Something went wrong!\n/tmp/someotherfile.txt:42:79:\n\tmight be this" + \ } + \ ], + \ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [ + \ { + \ 'range': Range(0, 2, 0, 2), + \ 'message': 'Something went wrong!', \ 'relatedInformation': [{ \ 'message': 'might be this', \ 'location': { @@ -160,13 +167,6 @@ Execute(ale#lsp#response#ReadDiagnostics() should use relatedInformation for det \ } \ }] \ } - \ ], - \ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [ - \ { - \ 'range': Range(0, 2, 0, 2), - \ 'message': 'Something went wrong!', - \ 'detail': "Something went wrong!\n/tmp/someotherfile.txt:42:79:\n\tmight be this" - \ } \ ]}}) Execute(ale#lsp#response#ReadTSServerDiagnostics() should handle tsserver responses): -- cgit v1.2.3 From 4923d48d53a2ca64d2a125ff5ea4e4c9aa744f48 Mon Sep 17 00:00:00 2001 From: Fred Emmott Date: Wed, 15 Aug 2018 14:46:57 -0700 Subject: Correct related information line numbers from 0-based to 1-based --- test/lsp/test_read_lsp_diagnostics.vader | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/lsp') diff --git a/test/lsp/test_read_lsp_diagnostics.vader b/test/lsp/test_read_lsp_diagnostics.vader index d795ae29..be50fbe8 100644 --- a/test/lsp/test_read_lsp_diagnostics.vader +++ b/test/lsp/test_read_lsp_diagnostics.vader @@ -149,7 +149,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should use relatedInformation for det \ 'col': 3, \ 'end_lnum': 1, \ 'end_col': 3, - \ 'detail': "Something went wrong!\n/tmp/someotherfile.txt:42:79:\n\tmight be this" + \ 'detail': "Something went wrong!\n/tmp/someotherfile.txt:43:80:\n\tmight be this" \ } \ ], \ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [ @@ -162,7 +162,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should use relatedInformation for det \ 'uri': 'file:///tmp/someotherfile.txt', \ 'range': { \ 'start': { 'line': 42, 'character': 79 }, - \ 'end': { 'line': 43, 'character': 80 }, + \ 'end': { 'line': 142, 'character': 179}, \ } \ } \ }] -- cgit v1.2.3 From ad8b26051913c8bcd58e362d45a9781697904bf9 Mon Sep 17 00:00:00 2001 From: w0rp Date: Thu, 16 Aug 2018 14:19:12 +0100 Subject: Fix #1816 - Fix a type error in the initialize message handler --- test/lsp/test_other_initialize_message_handling.vader | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test/lsp') diff --git a/test/lsp/test_other_initialize_message_handling.vader b/test/lsp/test_other_initialize_message_handling.vader index 45457979..f5e0f1da 100644 --- a/test/lsp/test_other_initialize_message_handling.vader +++ b/test/lsp/test_other_initialize_message_handling.vader @@ -181,3 +181,10 @@ Execute(Disabled capabilities should be recognised correctly): \ }, \ }, \ b:conn + +Execute(Results that are not dictionaries should be handled correctly): + call ale#lsp#HandleOtherInitializeResponses(b:conn, { + \ 'jsonrpc': '2.0', + \ 'id': 1, + \ 'result': v:null, + \}) -- cgit v1.2.3 From c4eca7c417945a684949342da8d0ab30e6c82b3a Mon Sep 17 00:00:00 2001 From: w0rp Date: Fri, 24 Aug 2018 13:16:58 +0100 Subject: Use one LSP connection per project --- test/lsp/test_did_save_event.vader | 15 +-- test/lsp/test_lsp_command_formatting.vader | 6 +- test/lsp/test_lsp_connections.vader | 54 ---------- .../test_other_initialize_message_handling.vader | 120 ++++++--------------- 4 files changed, 43 insertions(+), 152 deletions(-) (limited to 'test/lsp') diff --git a/test/lsp/test_did_save_event.vader b/test/lsp/test_did_save_event.vader index 428135fb..f8ff8f70 100644 --- a/test/lsp/test_did_save_event.vader +++ b/test/lsp/test_did_save_event.vader @@ -13,6 +13,7 @@ Before: let b:ale_enabled = 1 let g:ale_lsp_next_message_id = 1 let g:ale_run_synchronously = 1 + let g:conn_id = v:null let g:message_list = [] function! LanguageCallback() abort @@ -34,26 +35,29 @@ Before: let g:ale_linters = {'foobar': ['dummy_linter']} function! ale#lsp_linter#StartLSP(buffer, linter) abort - let l:conn = ale#lsp#NewConnection({}) - let l:conn.id = 347 - let l:conn.open_documents = {a:buffer : -1} + let g:conn_id = ale#lsp#Register('executable', '/foo/bar', {}) + call ale#lsp#MarkDocumentAsOpen(g:conn_id, a:buffer) return { \ 'buffer': a:buffer, - \ 'connection_id': 347, + \ 'connection_id': g:conn_id, \ 'project_root': '/foo/bar', \ 'language_id': 'foobar', \} endfunction " Replace the Send function for LSP, so we can monitor calls to it. - function! ale#lsp#Send(conn_id, message, ...) abort + function! ale#lsp#Send(conn_id, message) abort call add(g:message_list, a:message) endfunction After: Restore + if g:conn_id isnot v:null + call ale#lsp#RemoveConnectionWithID(g:conn_id) + endif + unlet! b:ale_enabled unlet! b:ale_linters unlet! g:message_list @@ -61,7 +65,6 @@ After: delfunction LanguageCallback delfunction ProjectRootCallback - call ale#lsp#RemoveConnectionWithID(347) call ale#test#RestoreDirectory() call ale#linter#Reset() diff --git a/test/lsp/test_lsp_command_formatting.vader b/test/lsp/test_lsp_command_formatting.vader index 9d2c84ee..9721f37f 100644 --- a/test/lsp/test_lsp_command_formatting.vader +++ b/test/lsp/test_lsp_command_formatting.vader @@ -5,7 +5,7 @@ Before: " Mock the StartProgram function so we can just capture the arguments. function! ale#lsp#StartProgram(...) abort - let g:args = a:000 + let g:args = a:000[1:] endfunction After: @@ -27,10 +27,10 @@ Execute(Command formatting should be applied correctly for LSP linters): if has('win32') AssertEqual - \ ['cmd', 'cmd /s/c "cmd --foo"', {}], + \ ['cmd', 'cmd /s/c "cmd --foo"'], \ g:args else AssertEqual - \ ['true', [&shell, '-c', '''true'' --foo'], {}], + \ ['true', [&shell, '-c', '''true'' --foo']], \ g:args endif diff --git a/test/lsp/test_lsp_connections.vader b/test/lsp/test_lsp_connections.vader index ae64eadb..1c2fceab 100644 --- a/test/lsp/test_lsp_connections.vader +++ b/test/lsp/test_lsp_connections.vader @@ -225,57 +225,3 @@ Execute(ale#lsp#ReadMessageData() should handle a message with part of a second \ . '{"id":2,"jsonrpc":"2.0","result":{"foo":"barÜ"}}' \ . b:data \ ) - -Execute(Projects with regular project roots should be registered correctly): - let b:conn = ale#lsp#NewConnection({}) - call ale#lsp#RegisterProject(b:conn.id, '/foo/bar') - - AssertEqual - \ { - \ '/foo/bar': { - \ 'root': '/foo/bar', - \ 'initialized': 0, - \ 'message_queue': [], - \ 'capabilities_queue': [], - \ 'init_request_id': 0, - \ }, - \ }, - \ b:conn.projects - -Execute(Projects with regular project roots should be fetched correctly): - let b:conn = { - \ 'projects': { - \ '/foo/bar': {'initialized': 0, 'message_queue': [], 'init_request_id': 0}, - \ }, - \} - - AssertEqual - \ {'initialized': 0, 'message_queue': [], 'init_request_id': 0}, - \ ale#lsp#GetProject(b:conn, '/foo/bar') - -Execute(Projects with empty project roots should be registered correctly): - let b:conn = ale#lsp#NewConnection({}) - call ale#lsp#RegisterProject(b:conn.id, '') - - AssertEqual - \ { - \ '<>': { - \ 'root': '', - \ 'initialized': 1, - \ 'message_queue': [], - \ 'capabilities_queue': [], - \ 'init_request_id': 0, - \ }, - \ }, - \ b:conn.projects - -Execute(Projects with empty project roots should be fetched correctly): - let b:conn = { - \ 'projects': { - \ '<>': {'initialized': 1, 'message_queue': [], 'init_request_id': 0}, - \ }, - \} - - AssertEqual - \ {'initialized': 1, 'message_queue': [], 'init_request_id': 0}, - \ ale#lsp#GetProject(b:conn, '') diff --git a/test/lsp/test_other_initialize_message_handling.vader b/test/lsp/test_other_initialize_message_handling.vader index f5e0f1da..e29f3358 100644 --- a/test/lsp/test_other_initialize_message_handling.vader +++ b/test/lsp/test_other_initialize_message_handling.vader @@ -1,15 +1,15 @@ Before: - let b:project = { + let b:conn = { + \ 'is_tsserver': 0, + \ 'data': '', + \ 'root': '/foo/bar', + \ 'open_documents': {}, \ 'initialized': 0, - \ 'init_request_id': 3, + \ 'init_request_id': 0, + \ 'init_options': {}, + \ 'callback_list': [], \ 'message_queue': [], \ 'capabilities_queue': [], - \} - - let b:conn = { - \ 'projects': { - \ '/foo/bar': b:project, - \ }, \ 'capabilities': { \ 'hover': 0, \ 'references': 0, @@ -20,64 +20,26 @@ Before: \} After: - unlet! b:project unlet! b:conn -Execute(publishDiagnostics messages with files inside project directories should initialize projects): - " This is for some other file, ignore this one. - call ale#lsp#HandleOtherInitializeResponses(b:conn, { - \ 'method': 'textDocument/publishDiagnostics', - \ 'params': {'uri': 'file:///xyz/bar/baz.txt'}, - \}) - - AssertEqual - \ { - \ 'initialized': 0, - \ 'init_request_id': 3, - \ 'message_queue': [], - \ 'capabilities_queue': [], - \ }, - \ b:project - - call ale#lsp#HandleOtherInitializeResponses(b:conn, { - \ 'method': 'textDocument/publishDiagnostics', - \ 'params': {'uri': 'file:///foo/bar/baz.txt'}, - \}) - - AssertEqual - \ { - \ 'initialized': 1, - \ 'init_request_id': 3, - \ 'message_queue': [], - \ 'capabilities_queue': [], - \ }, - \ b:project - Execute(Messages with no method and capabilities should initialize projects): - call ale#lsp#HandleOtherInitializeResponses(b:conn, { + call ale#lsp#HandleInitResponse(b:conn, { \ 'result': {'capabilities': {}}, \}) - AssertEqual - \ { - \ 'initialized': 1, - \ 'init_request_id': 3, - \ 'message_queue': [], - \ 'capabilities_queue': [], - \ }, - \ b:project + AssertEqual 1, b:conn.initialized Execute(Other messages should not initialize projects): - call ale#lsp#HandleOtherInitializeResponses(b:conn, {'method': 'lolwat'}) + call ale#lsp#HandleInitResponse(b:conn, {'method': 'lolwat'}) - AssertEqual 0, b:project.initialized + AssertEqual 0, b:conn.initialized - call ale#lsp#HandleOtherInitializeResponses(b:conn, {'result': {'x': {}}}) + call ale#lsp#HandleInitResponse(b:conn, {'result': {'x': {}}}) - AssertEqual 0, b:project.initialized + AssertEqual 0, b:conn.initialized Execute(Capabilities should bet set up correctly): - call ale#lsp#HandleOtherInitializeResponses(b:conn, { + call ale#lsp#HandleInitResponse(b:conn, { \ 'jsonrpc': '2.0', \ 'id': 1, \ 'result': { @@ -110,29 +72,19 @@ Execute(Capabilities should bet set up correctly): \ }, \}) + AssertEqual 1, b:conn.initialized AssertEqual \ { - \ 'capabilities': { - \ 'completion_trigger_characters': ['.'], - \ 'completion': 1, - \ 'references': 1, - \ 'hover': 1, - \ 'definition': 1, - \ }, - \ 'message_queue': [], - \ 'projects': { - \ '/foo/bar': { - \ 'initialized': 1, - \ 'message_queue': [], - \ 'capabilities_queue': [], - \ 'init_request_id': 3, - \ }, - \ }, + \ 'completion_trigger_characters': ['.'], + \ 'completion': 1, + \ 'references': 1, + \ 'hover': 1, + \ 'definition': 1, \ }, - \ b:conn + \ b:conn.capabilities Execute(Disabled capabilities should be recognised correctly): - call ale#lsp#HandleOtherInitializeResponses(b:conn, { + call ale#lsp#HandleInitResponse(b:conn, { \ 'jsonrpc': '2.0', \ 'id': 1, \ 'result': { @@ -161,29 +113,19 @@ Execute(Disabled capabilities should be recognised correctly): \ }, \}) + AssertEqual 1, b:conn.initialized AssertEqual \ { - \ 'capabilities': { - \ 'completion_trigger_characters': [], - \ 'completion': 0, - \ 'references': 0, - \ 'hover': 0, - \ 'definition': 0, - \ }, - \ 'message_queue': [], - \ 'projects': { - \ '/foo/bar': { - \ 'initialized': 1, - \ 'message_queue': [], - \ 'capabilities_queue': [], - \ 'init_request_id': 3, - \ }, - \ }, + \ 'completion_trigger_characters': [], + \ 'completion': 0, + \ 'references': 0, + \ 'hover': 0, + \ 'definition': 0, \ }, - \ b:conn + \ b:conn.capabilities Execute(Results that are not dictionaries should be handled correctly): - call ale#lsp#HandleOtherInitializeResponses(b:conn, { + call ale#lsp#HandleInitResponse(b:conn, { \ 'jsonrpc': '2.0', \ 'id': 1, \ 'result': v:null, -- cgit v1.2.3 From 2000436dfd7a25a8e9f66788c94bfb4512adda98 Mon Sep 17 00:00:00 2001 From: Daniel Welch Date: Mon, 22 Oct 2018 07:24:46 -0500 Subject: LSP configuration via didChangeConfiguration (#1852) * adding LSP configuration via workspace/didChangeConfiguration --- test/lsp/test_lsp_client_messages.vader | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test/lsp') diff --git a/test/lsp/test_lsp_client_messages.vader b/test/lsp/test_lsp_client_messages.vader index dc28c2e9..d4abaad9 100644 --- a/test/lsp/test_lsp_client_messages.vader +++ b/test/lsp/test_lsp_client_messages.vader @@ -175,6 +175,22 @@ Execute(ale#lsp#message#Hover() should return correct messages): \ ], \ ale#lsp#message#Hover(bufnr(''), 12, 34) +Execute(ale#lsp#message#DidChangeConfiguration() should return correct messages): + let g:ale_lsp_configuration = { + \ 'foo': 'bar' + \ } + AssertEqual + \ [ + \ 0, + \ 'workspace/didChangeConfiguration', + \ { + \ 'settings': { + \ 'foo': 'bar', + \ } + \ } + \ ], + \ ale#lsp#message#DidChangeConfiguration(bufnr(''), g:ale_lsp_configuration) + Execute(ale#lsp#tsserver_message#Open() should return correct messages): AssertEqual \ [ -- cgit v1.2.3 From 2ac9e2a29e3c570e8aac5d8f5404921e8d816006 Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Tue, 30 Oct 2018 15:47:19 -0700 Subject: Only send LSP config updates when the dict changes Each LSP connection now stores its configuration dictionary. It is initially empty (`{}`) and is updated each time the LSP connection is started. When a change is detected, the workspace/didChangeConfiguration message is sent to the LSP servers with the updated configuration. --- test/lsp/test_other_initialize_message_handling.vader | 1 + test/lsp/test_update_config.vader | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 test/lsp/test_update_config.vader (limited to 'test/lsp') diff --git a/test/lsp/test_other_initialize_message_handling.vader b/test/lsp/test_other_initialize_message_handling.vader index e29f3358..98509f82 100644 --- a/test/lsp/test_other_initialize_message_handling.vader +++ b/test/lsp/test_other_initialize_message_handling.vader @@ -7,6 +7,7 @@ Before: \ 'initialized': 0, \ 'init_request_id': 0, \ 'init_options': {}, + \ 'config': {}, \ 'callback_list': [], \ 'message_queue': [], \ 'capabilities_queue': [], diff --git a/test/lsp/test_update_config.vader b/test/lsp/test_update_config.vader new file mode 100644 index 00000000..07068bc8 --- /dev/null +++ b/test/lsp/test_update_config.vader @@ -0,0 +1,17 @@ +Before: + runtime autoload/ale/lsp.vim + + let g:conn_id = ale#lsp#Register('executable', '/foo/bar', {}) + +After: + Restore + + unlet! g:conn_id + + runtime autoload/ale/lsp.vim + +Execute(Only send updates when the configuration dictionary changes): + AssertEqual 0, ale#lsp#UpdateConfig(g:conn_id, bufnr(''), {}) + AssertEqual 1, ale#lsp#UpdateConfig(g:conn_id, bufnr(''), {'a': 1}) + AssertEqual 0, ale#lsp#UpdateConfig(g:conn_id, bufnr(''), {'a': 1}) + AssertEqual 1, ale#lsp#UpdateConfig(g:conn_id, bufnr(''), {}) -- cgit v1.2.3 From 4ef2c81e95529d4175ba8149fbe42e856a36ab10 Mon Sep 17 00:00:00 2001 From: w0rp Date: Wed, 31 Oct 2018 16:13:22 +0000 Subject: Implement LSP symbol search --- test/lsp/test_lsp_client_messages.vader | 11 +++++++++++ test/lsp/test_other_initialize_message_handling.vader | 6 +++++- 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'test/lsp') diff --git a/test/lsp/test_lsp_client_messages.vader b/test/lsp/test_lsp_client_messages.vader index d4abaad9..71768ce5 100644 --- a/test/lsp/test_lsp_client_messages.vader +++ b/test/lsp/test_lsp_client_messages.vader @@ -161,6 +161,17 @@ Execute(ale#lsp#message#References() should return correct messages): \ ], \ ale#lsp#message#References(bufnr(''), 12, 34) +Execute(ale#lsp#message#Symbol() should return correct messages): + AssertEqual + \ [ + \ 0, + \ 'workspace/symbol', + \ { + \ 'query': 'foobar', + \ } + \ ], + \ ale#lsp#message#Symbol('foobar') + Execute(ale#lsp#message#Hover() should return correct messages): AssertEqual \ [ diff --git a/test/lsp/test_other_initialize_message_handling.vader b/test/lsp/test_other_initialize_message_handling.vader index e29f3358..072f8c4b 100644 --- a/test/lsp/test_other_initialize_message_handling.vader +++ b/test/lsp/test_other_initialize_message_handling.vader @@ -16,6 +16,7 @@ Before: \ 'completion': 0, \ 'completion_trigger_characters': [], \ 'definition': 0, + \ 'symbol_search': 0, \ }, \} @@ -67,7 +68,8 @@ Execute(Capabilities should bet set up correctly): \ }, \ 'definitionProvider': v:true, \ 'experimental': {}, - \ 'documentHighlightProvider': v:true + \ 'documentHighlightProvider': v:true, + \ 'workspaceSymbolProvider': v:true \ }, \ }, \}) @@ -80,6 +82,7 @@ Execute(Capabilities should bet set up correctly): \ 'references': 1, \ 'hover': 1, \ 'definition': 1, + \ 'symbol_search': 1, \ }, \ b:conn.capabilities @@ -121,6 +124,7 @@ Execute(Disabled capabilities should be recognised correctly): \ 'references': 0, \ 'hover': 0, \ 'definition': 0, + \ 'symbol_search': 0, \ }, \ b:conn.capabilities -- cgit v1.2.3