From 79e42fed14b35767d53d7d443a644a037e012b89 Mon Sep 17 00:00:00 2001 From: w0rp Date: Fri, 10 May 2019 13:42:41 +0100 Subject: #2403 - Make ale_disable_lsp apply consistently, and document it better --- test/lsp/test_did_save_event.vader | 3 + test/test_ignoring_linters.vader | 95 ++++++++++++++++++++++ ...test_redundant_tsserver_rendering_avoided.vader | 4 + 3 files changed, 102 insertions(+) (limited to 'test') diff --git a/test/lsp/test_did_save_event.vader b/test/lsp/test_did_save_event.vader index 423138af..1a60bc9f 100644 --- a/test/lsp/test_did_save_event.vader +++ b/test/lsp/test_did_save_event.vader @@ -3,12 +3,15 @@ Before: Save g:ale_enabled Save g:ale_linters Save g:ale_run_synchronously + Save g:ale_disable_lsp call ale#test#SetDirectory('/testplugin/test/completion') call ale#test#SetFilename('dummy.txt') runtime autoload/ale/lsp.vim + let g:ale_disable_lsp = 0 + unlet! b:ale_disable_lsp let g:ale_lint_on_save = 1 let b:ale_enabled = 1 let g:ale_lsp_next_message_id = 1 diff --git a/test/test_ignoring_linters.vader b/test/test_ignoring_linters.vader index 2d9c67de..f2e9e5c9 100644 --- a/test/test_ignoring_linters.vader +++ b/test/test_ignoring_linters.vader @@ -300,3 +300,98 @@ Execute(Buffer ignore lists should be applied for LSP linters): call ale#lsp_linter#HandleLSPResponse(347, g:lsp_message) AssertEqual [], g:loclist + +Execute(ale_disable_lsp should be applied for tsserver): + call ale#test#SetFilename('filename.ts') + call ale#engine#InitBufferInfo(bufnr('')) + + let g:lsp_message = { + \ 'seq': 0, + \ 'type': 'event', + \ 'event': 'syntaxDiag', + \ 'body': { + \ 'file': g:dir . '/filename.ts', + \ 'diagnostics':[ + \ { + \ 'start': { + \ 'line':2, + \ 'offset':14, + \ }, + \ 'end': { + \ 'line':2, + \ 'offset':15, + \ }, + \ 'text': ''','' expected.', + \ "code":1005 + \ }, + \ ], + \ }, + \} + + call ale#lsp_linter#HandleLSPResponse(347, g:lsp_message) + + AssertEqual + \ [ + \ { + \ 'lnum': 2, + \ 'col': 14, + \ 'nr': 1005, + \ 'code': '1005', + \ 'type': 'E', + \ 'end_col': 15, + \ 'end_lnum': 2, + \ 'text': ''','' expected.', + \ }, + \ ], + \ g:loclist + + let g:loclist = [] + let b:ale_disable_lsp = 1 + call ale#lsp_linter#HandleLSPResponse(347, g:lsp_message) + + AssertEqual [], g:loclist + +Execute(ale_disable_lsp should be applied for LSP linters): + call ale#test#SetFilename('filename.py') + call ale#engine#InitBufferInfo(bufnr('')) + call ale#lsp_linter#SetLSPLinterMap({'347': 'lsplinter'}) + + let g:lsp_message = { + \ 'jsonrpc': '2.0', + \ 'method': 'textDocument/publishDiagnostics', + \ 'params': { + \ 'uri': ale#path#ToURI(expand('%:p')), + \ 'diagnostics': [ + \ { + \ 'severity': 1, + \ 'message': 'x', + \ 'range': { + \ 'start': {'line': 0, 'character': 9}, + \ 'end': {'line': 0, 'character': 9}, + \ }, + \ } + \ ], + \ }, + \} + + call ale#lsp_linter#HandleLSPResponse(347, g:lsp_message) + + AssertEqual + \ [ + \ { + \ 'lnum': 1, + \ 'col': 10, + \ 'type': 'E', + \ 'end_col': 9, + \ 'end_lnum': 1, + \ 'text': 'x', + \ } + \ ], + \ g:loclist + + let b:ale_disable_lsp = 1 + let g:loclist = [] + + call ale#lsp_linter#HandleLSPResponse(347, g:lsp_message) + + AssertEqual [], g:loclist diff --git a/test/test_redundant_tsserver_rendering_avoided.vader b/test/test_redundant_tsserver_rendering_avoided.vader index 6e0b2d30..6125ebc2 100644 --- a/test/test_redundant_tsserver_rendering_avoided.vader +++ b/test/test_redundant_tsserver_rendering_avoided.vader @@ -1,5 +1,9 @@ Before: Save g:ale_buffer_info + Save g:ale_disable_lsp + + let g:ale_disable_lsp = 0 + unlet! b:ale_disable_lsp function! CreateError(type, message) abort let l:diagnostics = [] -- cgit v1.2.3