From d97e25a2601d58a1d7e8ae72fb787210f2588a69 Mon Sep 17 00:00:00 2001 From: w0rp Date: Fri, 7 Oct 2016 17:08:11 +0100 Subject: [PATCH] Support reading from both output streams, and fix PHP error parsing, which sometimes logs to stderr, sometimes stdout. --- ale_linters/php/php.vim | 2 +- doc/ale.txt | 10 ++++++---- plugin/ale/zmain.vim | 10 ++++++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ale_linters/php/php.vim b/ale_linters/php/php.vim index 4b4b172..cc875e9 100644 --- a/ale_linters/php/php.vim +++ b/ale_linters/php/php.vim @@ -39,7 +39,7 @@ endfunction call ALEAddLinter('php', { \ 'name': 'php', \ 'executable': 'php', -\ 'output_stream': 'stderr', +\ 'output_stream': 'both', \ 'command': 'php -l --', \ 'callback': 'ale_linters#php#php#Handle', \}) diff --git a/doc/ale.txt b/doc/ale.txt index ecb39f3..3788c2a 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -324,10 +324,12 @@ ALEAddLinter(filetype, linter) *ALEAddLinter()* `output_stream` A |String| for the output stream the lines of output should be read from for the command which is run. The - accepted values are `'stdout'` and `'stderr'`. This - argument defaults to `'stdout'`. This argument can be - set for linter programs which output their errors and - warnings to the stderr stream instead of stdout. + accepted values are `'stdout'`, `'stderr'`, and + `'both'`. This argument defaults to `'stdout'`. This + argument can be set for linter programs which output + their errors and warnings to the stderr stream + instead of stdout. The option `'both'` will read + from both stder and stdout at the same time. Some programs for checking for errors are not capable of receiving input from stdin, as is required by ALE. To remedy this, a wrapper script is diff --git a/plugin/ale/zmain.vim b/plugin/ale/zmain.vim index 83bb810..8db9d8f 100644 --- a/plugin/ale/zmain.vim +++ b/plugin/ale/zmain.vim @@ -184,6 +184,12 @@ function! s:ApplyLinter(buffer, linter) \ 'on_stderr': 's:GatherOutputNeoVim', \ 'on_exit': 's:HandleExitNeoVim', \}) + elseif a:linter.output_stream ==# 'both' + let a:linter.job = jobstart(command, { + \ 'on_stdout': 's:GatherOutputNeoVim', + \ 'on_stderr': 's:GatherOutputNeoVim', + \ 'on_exit': 's:HandleExitNeoVim', + \}) else let a:linter.job = jobstart(command, { \ 'on_stdout': 's:GatherOutputNeoVim', @@ -202,6 +208,10 @@ function! s:ApplyLinter(buffer, linter) if a:linter.output_stream ==# 'stderr' " Read from stderr instead of stdout. let job_options.err_cb = function('s:GatherOutputVim') + elseif a:linter.output_stream ==# 'both' + " Read from both streams. + let job_options.out_cb = function('s:GatherOutputVim') + let job_options.err_cb = function('s:GatherOutputVim') else let job_options.out_cb = function('s:GatherOutputVim') endif