Include executable checks in ALEInfo
This commit is contained in:
parent
0507503aa7
commit
623fdf212c
3 changed files with 80 additions and 30 deletions
|
@ -70,6 +70,45 @@ function! s:EchoGlobalVariables() abort
|
|||
endfor
|
||||
endfunction
|
||||
|
||||
" Echo a command that was run.
|
||||
function! s:EchoCommand(item) abort
|
||||
let l:status_message = a:item.status
|
||||
|
||||
" 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
|
||||
|
||||
echom '(' . l:status_message . ') ' . string(a:item.command)
|
||||
|
||||
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
|
||||
|
||||
" 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
|
||||
|
||||
function! s:EchoCommandHistory() abort
|
||||
let l:buffer = bufnr('%')
|
||||
|
||||
|
@ -78,31 +117,10 @@ function! s:EchoCommandHistory() abort
|
|||
endif
|
||||
|
||||
for l:item in g:ale_buffer_info[l:buffer].history
|
||||
let l:status_message = l:item.status
|
||||
|
||||
" 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
|
||||
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
|
||||
if l:item.job_id is# 'executable'
|
||||
call s:EchoExecutable(l:item)
|
||||
else
|
||||
call s:EchoCommand(l:item)
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
|
|
@ -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
|
||||
|
||||
return 0
|
||||
if g:ale_history_enabled
|
||||
call ale#history#Add(a:buffer, l:result, 'executable', a:executable)
|
||||
endif
|
||||
|
||||
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
|
||||
|
|
|
@ -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',
|
||||
\])
|
||||
|
|
Reference in a new issue