summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-03-14 23:51:57 +0000
committerw0rp <devw0rp@gmail.com>2017-03-14 23:51:57 +0000
commite7d32fe37677636a0be087163c1efa7d0ba10d47 (patch)
treea605ebb4cf464fc6b797942ec9a1d452d4bd6918 /autoload
parent790c614b7a2360446aee6e003e3e834d21b2f04b (diff)
downloadale-e7d32fe37677636a0be087163c1efa7d0ba10d47.zip
#333 Pass in a flag indicating that linters should be run against files, and clear more jobs
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale.vim29
-rw-r--r--autoload/ale/engine.vim10
2 files changed, 25 insertions, 14 deletions
diff --git a/autoload/ale.vim b/autoload/ale.vim
index c81a57a6..2d29c8f7 100644
--- a/autoload/ale.vim
+++ b/autoload/ale.vim
@@ -3,6 +3,7 @@
" Manages execution of linters when requested by autocommands
let s:lint_timer = -1
+let s:should_lint_file = 0
" A function for checking various conditions whereby ALE just shouldn't
" attempt to do anything, say if particular buffer types are open in Vim.
@@ -13,11 +14,25 @@ function! ale#ShouldDoNothing() abort
\ || ale#util#InSandbox()
endfunction
-function! ale#Queue(delay) abort
+" (delay, [run_file_linters])
+function! ale#Queue(delay, ...) abort
+ if len(a:0) > 1
+ throw 'too many arguments!'
+ endif
+
+ let l:a1 = len(a:0) > 1 ? a:1 : 0
+
+ if type(l:a1) != type(1) || (l:a1 != 0 && l:a1 != 1)
+ throw 'The lint_file argument must be a Number which is either 0 or 1!'
+ endif
+
if ale#ShouldDoNothing()
return
endif
+ " Remember the event used for linting.
+ let s:should_lint_file = l:a1
+
if s:lint_timer != -1
call timer_stop(s:lint_timer)
let s:lint_timer = -1
@@ -51,18 +66,6 @@ function! ale#Lint(...) abort
let g:ale_buffer_info[l:buffer].new_loclist = []
for l:linter in l:linters
- " Check if a given linter has a program which can be executed.
- if has_key(l:linter, 'executable_callback')
- let l:executable = ale#util#GetFunction(l:linter.executable_callback)(l:buffer)
- else
- let l:executable = l:linter.executable
- endif
-
- if !executable(l:executable)
- " The linter's program cannot be executed, so skip it.
- continue
- endif
-
call ale#engine#Invoke(l:buffer, l:linter)
endfor
endfunction
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim
index 31591ded..8f5a06a0 100644
--- a/autoload/ale/engine.vim
+++ b/autoload/ale/engine.vim
@@ -626,7 +626,15 @@ endfunction
function! ale#engine#Invoke(buffer, linter) abort
" Stop previous jobs for the same linter.
call s:StopPreviousJobs(a:buffer, a:linter)
- call s:InvokeChain(a:buffer, a:linter, 0, [])
+
+ let l:executable = has_key(a:linter, 'executable_callback')
+ \ ? ale#util#GetFunction(a:linter.executable_callback)(a:buffer)
+ \ : a:linter.executable
+
+ " Run this program if it can be executed.
+ if executable(l:executable)
+ call s:InvokeChain(a:buffer, a:linter, 0, [])
+ endif
endfunction
" Given a buffer number, return the warnings and errors for a given buffer.