summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-02-16 23:18:57 +0000
committerw0rp <devw0rp@gmail.com>2017-02-16 23:18:57 +0000
commiteac0a41ae1aba77e1d017833425fa8132130df13 (patch)
tree1bd9b6f30a43b3066236937df5e88341559fae33 /autoload
parent843370b96f9a92a2298ed7985a8f620784fc9421 (diff)
downloadale-eac0a41ae1aba77e1d017833425fa8132130df13.zip
#254 Add an option for logging the output of commands
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/debugging.vim18
-rw-r--r--autoload/ale/engine.vim5
-rw-r--r--autoload/ale/history.vim31
3 files changed, 47 insertions, 7 deletions
diff --git a/autoload/ale/debugging.vim b/autoload/ale/debugging.vim
index 1ca7736b..60c1b37c 100644
--- a/autoload/ale/debugging.vim
+++ b/autoload/ale/debugging.vim
@@ -76,6 +76,24 @@ function! s:EchoCommandHistory() abort
endif
echom '(' . l:status_message . ') ' . string(l:item.command)
+
+ if g:ale_history_log_output && has_key(l:item, 'output')
+ if empty(l:item.output)
+ echom ''
+ echom '<<<NO OUTPUT RETURNED>>>'
+ echom ''
+ else
+ echom ''
+ echom '<<<OUTPUT STARTS>>>'
+
+ for l:line in l:item.output
+ echom l:line
+ endfor
+
+ echom '<<<OUTPUT ENDS>>>'
+ echom ''
+ endif
+ endif
endfor
endfunction
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim
index a6b9df38..ac8028a9 100644
--- a/autoload/ale/engine.vim
+++ b/autoload/ale/engine.vim
@@ -214,6 +214,11 @@ function! s:HandleExit(job) abort
return
endif
+ " Log the output of the command for ALEInfo if we should.
+ if g:ale_history_enabled && g:ale_history_log_output
+ call ale#history#RememberOutput(l:buffer, l:job_id, l:output[:])
+ endif
+
let l:linter_loclist = ale#util#GetFunction(l:linter.callback)(l:buffer, l:output)
" Make some adjustments to the loclists to fix common problems.
diff --git a/autoload/ale/history.vim b/autoload/ale/history.vim
index f52c1d75..78703be1 100644
--- a/autoload/ale/history.vim
+++ b/autoload/ale/history.vim
@@ -25,17 +25,34 @@ function! ale#history#Add(buffer, status, job_id, command) abort
let g:ale_buffer_info[a:buffer].history = l:history
endfunction
-" Set an exit code for a command which finished.
-function! ale#history#SetExitCode(buffer, job_id, exit_code) abort
+function! s:FindHistoryItem(buffer, job_id) abort
" Search backwards to find a matching job ID. IDs might be recycled,
" so finding the last one should be good enough.
for l:obj in reverse(g:ale_buffer_info[a:buffer].history[:])
if l:obj.job_id == a:job_id
- " If we find a match, then set the code and status, and stop here.
- let l:obj.exit_code = a:exit_code
- let l:obj.status = 'finished'
-
- return
+ return l:obj
endif
endfor
+
+ return {}
+endfunction
+
+" Set an exit code for a command which finished.
+function! ale#history#SetExitCode(buffer, job_id, exit_code) abort
+ let l:obj = s:FindHistoryItem(a:buffer, a:job_id)
+
+ if !empty(l:obj)
+ " If we find a match, then set the code and status.
+ let l:obj.exit_code = a:exit_code
+ let l:obj.status = 'finished'
+ endif
+endfunction
+
+" Set the output for a command which finished.
+function! ale#history#RememberOutput(buffer, job_id, output) abort
+ let l:obj = s:FindHistoryItem(a:buffer, a:job_id)
+
+ if !empty(l:obj)
+ let l:obj.output = a:output
+ endif
endfunction