mirror of https://github.com/dense-analysis/ale
#2403 - Make ale_disable_lsp apply consistently, and document it better
This commit is contained in:
parent
f444abdfe6
commit
79e42fed14
|
@ -97,7 +97,7 @@ function! s:Lint(buffer, should_lint_file, timer_id) abort
|
|||
" Apply ignore lists for linters only if needed.
|
||||
let l:ignore_config = ale#Var(a:buffer, 'linters_ignore')
|
||||
let l:disable_lsp = ale#Var(a:buffer, 'disable_lsp')
|
||||
let l:linters = !empty(l:ignore_config)
|
||||
let l:linters = !empty(l:ignore_config) || l:disable_lsp
|
||||
\ ? ale#engine#ignore#Exclude(l:filetype, l:linters, l:ignore_config, l:disable_lsp)
|
||||
\ : l:linters
|
||||
|
||||
|
|
|
@ -10,6 +10,11 @@ endif
|
|||
|
||||
" Check if diagnostics for a particular linter should be ignored.
|
||||
function! s:ShouldIgnore(buffer, linter_name) abort
|
||||
" Ignore all diagnostics if LSP integration is disabled.
|
||||
if ale#Var(a:buffer, 'disable_lsp')
|
||||
return 1
|
||||
endif
|
||||
|
||||
let l:config = ale#Var(a:buffer, 'linters_ignore')
|
||||
|
||||
" Don't load code for ignoring diagnostics if there's nothing to ignore.
|
||||
|
|
|
@ -142,6 +142,8 @@ ALE offers several options for controlling which linters are run.
|
|||
* Selecting linters to run. - |g:ale_linters|
|
||||
* Aliasing filetypes for linters - |g:ale_linter_aliases|
|
||||
* Only running linters you asked for. - |g:ale_linters_explicit|
|
||||
* Disabling only a subset of linters. - |g:ale_linters_ignore|
|
||||
* Disabling LSP linters and `tsserver`. - |g:ale_disable_lsp|
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
@ -321,6 +323,9 @@ servers. LSP linters can be used in combination with any other linter, and
|
|||
will automatically connect to LSP servers when needed. ALE also supports
|
||||
`tsserver` for TypeScript, which uses a different but very similar protocol.
|
||||
|
||||
If you want to use another plugin for LSP features and tsserver, you can use
|
||||
the |g:ale_disable_lsp| setting to disable ALE's own LSP integrations, or
|
||||
ignore particular linters with |g:ale_linters_ignore|.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
5.1 Completion *ale-completion*
|
||||
|
@ -627,7 +632,9 @@ g:ale_disable_lsp *g:ale_disable_lsp*
|
|||
Type: |Number|
|
||||
Default: `0`
|
||||
|
||||
When this option is set to `1`, ALE ignores all linters powered by LSP.
|
||||
When this option is set to `1`, ALE ignores all linters powered by LSP,
|
||||
and also `tsserver`.
|
||||
|
||||
Please see also |ale-lsp|.
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 = []
|
||||
|
|
Loading…
Reference in New Issue