mirror of https://github.com/dense-analysis/ale
Fix #1176 - Add an option for caching failing executable checks
This commit is contained in:
parent
fd261264d7
commit
a990188e27
|
@ -32,16 +32,20 @@ function! ale#engine#IsExecutable(buffer, executable) abort
|
|||
return 0
|
||||
endif
|
||||
|
||||
if has_key(s:executable_cache_map, a:executable)
|
||||
return 1
|
||||
" Check for a cached executable() check.
|
||||
let l:result = get(s:executable_cache_map, a:executable, v:null)
|
||||
|
||||
if l:result isnot v:null
|
||||
return l:result
|
||||
endif
|
||||
|
||||
let l:result = 0
|
||||
" Check if the file is executable, and convert -1 to 1.
|
||||
let l:result = executable(a:executable) isnot 0
|
||||
|
||||
if executable(a:executable)
|
||||
let s:executable_cache_map[a:executable] = 1
|
||||
|
||||
let l:result = 1
|
||||
" Cache the executable check if we found it, or if the option to cache
|
||||
" failing checks is on.
|
||||
if l:result || g:ale_cache_executable_check_failures
|
||||
let s:executable_cache_map[a:executable] = l:result
|
||||
endif
|
||||
|
||||
if g:ale_history_enabled
|
||||
|
|
13
doc/ale.txt
13
doc/ale.txt
|
@ -605,6 +605,19 @@ g:airline#extensions#ale#enabled *g:airline#extensions#ale#enabled*
|
|||
|airline#extensions#ale#warning_symbol|.
|
||||
|
||||
|
||||
g:ale_cache_executable_check_failures *g:ale_cache_executable_check_failures*
|
||||
|
||||
Type: |Number|
|
||||
Default: `0`
|
||||
|
||||
When set to `1`, ALE will cache failing executable checks for linters. By
|
||||
default, only executable checks which succeed will be cached.
|
||||
|
||||
When this option is set to `1`, Vim will have to be restarted after new
|
||||
executables are installed for ALE to be able to run linters for those
|
||||
executables.
|
||||
|
||||
|
||||
g:ale_change_sign_column_color *g:ale_change_sign_column_color*
|
||||
|
||||
Type: |Number|
|
||||
|
|
|
@ -188,6 +188,10 @@ 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 caching failed executable checks.
|
||||
" This is off by default, because it will cause problems.
|
||||
call ale#Set('cache_executable_check_failures', 0)
|
||||
|
||||
" A dictionary mapping regular expression patterns to arbitrary buffer
|
||||
" variables to be set. Useful for configuration ALE based on filename
|
||||
" patterns.
|
||||
|
|
|
@ -2,9 +2,13 @@ Before:
|
|||
Save g:ale_warn_about_trailing_whitespace
|
||||
Save g:ale_linters
|
||||
Save g:ale_fixers
|
||||
Save g:ale_lint_on_text_changed
|
||||
Save g:ale_cache_executable_check_failures
|
||||
|
||||
unlet! b:ale_history
|
||||
|
||||
let g:ale_lint_on_text_changed = 'always'
|
||||
let g:ale_cache_executable_check_failures = 0
|
||||
let g:ale_warn_about_trailing_whitespace = 1
|
||||
|
||||
let g:testlinter1 = {'name': 'testlinter1', 'executable': 'testlinter1', 'command': 'testlinter1', 'callback': 'testCB1', 'output_stream': 'stdout'}
|
||||
|
@ -355,6 +359,31 @@ Execute (ALEInfo command history should print command output if logging is on):
|
|||
Execute (ALEInfo should include executable checks in the history):
|
||||
call ale#linter#Define('testft', g:testlinter1)
|
||||
call ale#engine#IsExecutable(bufnr(''), has('win32') ? 'cmd' : 'echo')
|
||||
call ale#engine#IsExecutable(bufnr(''), has('win32') ? 'cmd' : 'echo')
|
||||
call ale#engine#IsExecutable(bufnr(''), 'TheresNoWayThisIsExecutable')
|
||||
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) ' . (has('win32') ? 'cmd' : 'echo'),
|
||||
\ '(executable check - failure) TheresNoWayThisIsExecutable',
|
||||
\ '(executable check - failure) TheresNoWayThisIsExecutable',
|
||||
\])
|
||||
|
||||
Execute (The option for caching failing executable checks should work):
|
||||
let g:ale_cache_executable_check_failures = 1
|
||||
|
||||
call ale#linter#Define('testft', g:testlinter1)
|
||||
|
||||
call ale#engine#IsExecutable(bufnr(''), has('win32') ? 'cmd' : 'echo')
|
||||
call ale#engine#IsExecutable(bufnr(''), has('win32') ? 'cmd' : 'echo')
|
||||
call ale#engine#IsExecutable(bufnr(''), 'TheresNoWayThisIsExecutable')
|
||||
call ale#engine#IsExecutable(bufnr(''), 'TheresNoWayThisIsExecutable')
|
||||
|
||||
call CheckInfo([
|
||||
|
|
Loading…
Reference in New Issue