From 029cb550395bf73b549f9ba916746ef305bad493 Mon Sep 17 00:00:00 2001 From: cos Date: Mon, 7 Feb 2022 22:57:17 +0100 Subject: 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. --- autoload/ale/engine.vim | 16 ++++++++++++++++ plugin/ale.vim | 3 +++ 2 files changed, 19 insertions(+) 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) -- cgit v1.2.3