summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoload/ale/engine.vim18
-rw-r--r--doc/ale.txt13
-rw-r--r--plugin/ale.vim4
-rw-r--r--test/test_ale_info.vader29
4 files changed, 57 insertions, 7 deletions
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim
index 811b2438..150b53c1 100644
--- a/autoload/ale/engine.vim
+++ b/autoload/ale/engine.vim
@@ -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
- endif
+ " Check for a cached executable() check.
+ let l:result = get(s:executable_cache_map, a:executable, v:null)
- let l:result = 0
+ if l:result isnot v:null
+ return l:result
+ endif
- if executable(a:executable)
- let s:executable_cache_map[a:executable] = 1
+ " Check if the file is executable, and convert -1 to 1.
+ let l:result = executable(a:executable) isnot 0
- 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
diff --git a/doc/ale.txt b/doc/ale.txt
index 184912ce..a4ec7272 100644
--- a/doc/ale.txt
+++ b/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|
diff --git a/plugin/ale.vim b/plugin/ale.vim
index 8c97e39f..a07915f7 100644
--- a/plugin/ale.vim
+++ b/plugin/ale.vim
@@ -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.
diff --git a/test/test_ale_info.vader b/test/test_ale_info.vader
index 30237a3c..2ca18341 100644
--- a/test/test_ale_info.vader
+++ b/test/test_ale_info.vader
@@ -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([