summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-08-23 21:41:29 +0100
committerw0rp <devw0rp@gmail.com>2017-08-23 21:41:29 +0100
commit623fdf212cd70131df4d3c52de26d9d1faa5d90e (patch)
treec2e98dbffcc9abf65d4a656ddc3e867dee74e55c
parent0507503aa755587892e8841a749dc0ca8641a6f8 (diff)
downloadale-623fdf212cd70131df4d3c52de26d9d1faa5d90e.zip
Include executable checks in ALEInfo
-rw-r--r--autoload/ale/debugging.vim66
-rw-r--r--autoload/ale/engine.vim22
-rw-r--r--test/test_ale_info.vader20
3 files changed, 79 insertions, 29 deletions
diff --git a/autoload/ale/debugging.vim b/autoload/ale/debugging.vim
index 80d253e1..0042bd3c 100644
--- a/autoload/ale/debugging.vim
+++ b/autoload/ale/debugging.vim
@@ -70,39 +70,57 @@ function! s:EchoGlobalVariables() abort
endfor
endfunction
-function! s:EchoCommandHistory() abort
- let l:buffer = bufnr('%')
+" Echo a command that was run.
+function! s:EchoCommand(item) abort
+ let l:status_message = a:item.status
- if !has_key(g:ale_buffer_info, l:buffer)
- return
+ " Include the exit code in output if we have it.
+ if a:item.status is# 'finished'
+ let l:status_message .= ' - exit code ' . a:item.exit_code
endif
- for l:item in g:ale_buffer_info[l:buffer].history
- let l:status_message = l:item.status
+ echom '(' . l:status_message . ') ' . string(a:item.command)
- " Include the exit code in output if we have it.
- if l:item.status is# 'finished'
- let l:status_message .= ' - exit code ' . l:item.exit_code
+ if g:ale_history_log_output && has_key(a:item, 'output')
+ if empty(a:item.output)
+ echom ''
+ echom '<<<NO OUTPUT RETURNED>>>'
+ echom ''
+ else
+ echom ''
+ echom '<<<OUTPUT STARTS>>>'
+
+ for l:line in a:item.output
+ echom l:line
+ endfor
+
+ echom '<<<OUTPUT ENDS>>>'
+ echom ''
endif
+ endif
+endfunction
- echom '(' . l:status_message . ') ' . string(l:item.command)
+" Echo the results of an executable check.
+function! s:EchoExecutable(item) abort
+ echom printf(
+ \ '(executable check - %s) %s',
+ \ a:item.status ? 'success' : 'failure',
+ \ a:item.command,
+ \)
+endfunction
- 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>>>'
+function! s:EchoCommandHistory() abort
+ let l:buffer = bufnr('%')
- for l:line in l:item.output
- echom l:line
- endfor
+ if !has_key(g:ale_buffer_info, l:buffer)
+ return
+ endif
- echom '<<<OUTPUT ENDS>>>'
- echom ''
- endif
+ for l:item in g:ale_buffer_info[l:buffer].history
+ if l:item.job_id is# 'executable'
+ call s:EchoExecutable(l:item)
+ else
+ call s:EchoCommand(l:item)
endif
endfor
endfunction
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim
index ca8a00f3..b66a9fb6 100644
--- a/autoload/ale/engine.vim
+++ b/autoload/ale/engine.vim
@@ -16,22 +16,34 @@ if !has_key(s:, 'lsp_linter_map')
let s:lsp_linter_map = {}
endif
-let s:executable_cache_map = {}
+if !has_key(s:, 'executable_cache_map')
+ let s:executable_cache_map = {}
+endif
+
+function! ale#engine#ResetExecutableCache() abort
+ let s:executable_cache_map = {}
+endfunction
" Check if files are executable, and if they are, remember that they are
" for subsequent calls. We'll keep checking until programs can be executed.
-function! s:IsExecutable(executable) abort
+function! ale#engine#IsExecutable(buffer, executable) abort
if has_key(s:executable_cache_map, a:executable)
return 1
endif
+ let l:result = 0
+
if executable(a:executable)
let s:executable_cache_map[a:executable] = 1
- return 1
+ let l:result = 1
+ endif
+
+ if g:ale_history_enabled
+ call ale#history#Add(a:buffer, l:result, 'executable', a:executable)
endif
- return 0
+ return l:result
endfunction
function! ale#engine#InitBufferInfo(buffer) abort
@@ -755,7 +767,7 @@ function! s:RunLinter(buffer, linter) abort
else
let l:executable = ale#linter#GetExecutable(a:buffer, a:linter)
- if s:IsExecutable(l:executable)
+ if ale#engine#IsExecutable(a:buffer, l:executable)
return s:InvokeChain(a:buffer, a:linter, 0, [])
endif
endif
diff --git a/test/test_ale_info.vader b/test/test_ale_info.vader
index a8913df4..9cb768a2 100644
--- a/test/test_ale_info.vader
+++ b/test/test_ale_info.vader
@@ -7,6 +7,7 @@ Before:
let g:testlinter1 = {'name': 'testlinter1', 'executable': 'testlinter1', 'command': 'testlinter1', 'callback': 'testCB1', 'output_stream': 'stdout'}
let g:testlinter2 = {'name': 'testlinter2', 'executable': 'testlinter2', 'command': 'testlinter2', 'callback': 'testCB2', 'output_stream': 'stdout'}
+ call ale#engine#ResetExecutableCache()
call ale#linter#Reset()
let g:ale_linters = {}
let g:ale_linter_aliases = {}
@@ -351,3 +352,22 @@ Execute (ALEInfo command history should print command output if logging is on):
\ '',
\ '<<<NO OUTPUT RETURNED>>>',
\])
+
+Execute (ALEInfo should include executable checks in the history):
+ let g:ale_buffer_info[bufnr('')] = {'history': []}
+
+ call ale#linter#Define('testft', g:testlinter1)
+ call ale#engine#IsExecutable(bufnr(''), 'echo')
+ call ale#engine#IsExecutable(bufnr(''), 'TheresNoWayThisIsExecutable')
+
+ call CheckInfo([
+ \ ' Current Filetype: testft.testft2',
+ \ 'Available Linters: [''testlinter1'']',
+ \ ' Enabled Linters: [''testlinter1'']',
+ \ ' Linter Variables:',
+ \ '',
+ \] + g:globals_lines + g:command_header + [
+ \ '',
+ \ '(executable check - success) echo',
+ \ '(executable check - failure) TheresNoWayThisIsExecutable',
+ \])