diff options
author | cos <cos> | 2022-02-07 22:57:17 +0100 |
---|---|---|
committer | cos <cos> | 2023-03-08 08:35:53 +0100 |
commit | 029cb550395bf73b549f9ba916746ef305bad493 (patch) | |
tree | 99cda2206cde7c40f17be8b62ebd9411bddd7bd5 | |
parent | 16f5a1915b88ea50d809fc9d722f5b2b553f55b0 (diff) | |
download | ale-029cb550395bf73b549f9ba916746ef305bad493.zip |
wip: Add error on lint execution failure
Reports errors on failure to execute linters if `ale_error_on_lint_fail`
is set.
Bug: It appears the end_lnum is ignored. The scope for an error like
this one should likely be the entire file.
Please comment at https://github.com/dense-analysis/ale/issues/4060 if
having any thoughts at all about this suggested change.
-rw-r--r-- | autoload/ale/engine.vim | 16 | ||||
-rw-r--r-- | plugin/ale.vim | 3 |
2 files changed, 19 insertions, 0 deletions
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim index 185d54db..2720e901 100644 --- a/autoload/ale/engine.vim +++ b/autoload/ale/engine.vim @@ -553,6 +553,18 @@ function! s:AddProblemsFromOtherBuffers(buffer, linters) abort endif endfunction +function! s:AddLinterError(buffer, linter) abort + let l:output = [] + call add(l:output, { + \ 'lnum': 1, + \ 'end_lnum': ale#util#GetLineCount(a:buffer), + \ 'text': 'Linter failure (' . a:linter . ')', + \ 'detail': 'Failed to execute ' . a:linter, + \ 'type': 'E'} + \ ) + call ale#other_source#ShowResults(bufnr(''), 'ale-vim', l:output) +endfunction + function! s:RunIfExecutable(buffer, linter, lint_file, executable) abort if ale#command#IsDeferred(a:executable) let a:executable.result_callback = { @@ -597,6 +609,10 @@ function! s:RunIfExecutable(buffer, linter, lint_file, executable) abort \} return s:RunJob(l:command, l:options) + else + if ale#Var(a:buffer, 'error_on_lint_fail') + call s:AddLinterError(a:buffer, a:executable) + endif endif return 0 diff --git a/plugin/ale.vim b/plugin/ale.vim index f9b6cab8..ecf4f10a 100644 --- a/plugin/ale.vim +++ b/plugin/ale.vim @@ -169,6 +169,9 @@ let g:ale_history_enabled = get(g:, 'ale_history_enabled', 1) " A flag for storing the full output of commands in the history. let g:ale_history_log_output = get(g:, 'ale_history_log_output', 1) +" A flag for indicating error on linter failure. +let g:ale_error_on_lint_fail = get(g:, 'ale_error_on_lint_fail', 0) + " Enable automatic completion with LSP servers and tsserver let g:ale_completion_enabled = get(g:, 'ale_completion_enabled', 0) |