summaryrefslogtreecommitdiff
path: root/autoload/ale/linter.vim
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2019-02-21 21:24:41 +0000
committerw0rp <devw0rp@gmail.com>2019-02-21 21:24:41 +0000
commitffa45fa3fb44ade28c64aa8f0a21acd71c903a2a (patch)
tree350f4b45b17a1862844a14856c4063c0d219f0bd /autoload/ale/linter.vim
parenta8b987a1c31f297622f0038230d23404e7c2ad50 (diff)
downloadale-ffa45fa3fb44ade28c64aa8f0a21acd71c903a2a.zip
#2132 - Implement deferred command handling for linters
Diffstat (limited to 'autoload/ale/linter.vim')
-rw-r--r--autoload/ale/linter.vim11
1 files changed, 8 insertions, 3 deletions
diff --git a/autoload/ale/linter.vim b/autoload/ale/linter.vim
index 86ee506c..8c9f83ad 100644
--- a/autoload/ale/linter.vim
+++ b/autoload/ale/linter.vim
@@ -177,7 +177,8 @@ function! ale#linter#PreProcess(filetype, linter) abort
let l:obj.command = a:linter.command
if type(l:obj.command) isnot v:t_string
- throw '`command` must be a string if defined'
+ \&& type(l:obj.command) isnot v:t_func
+ throw '`command` must be a String or Function if defined'
endif
else
throw 'Either `command`, `executable_callback`, `command_chain` '
@@ -489,9 +490,13 @@ endfunction
" Given a buffer and linter, get the command String for the linter.
" The command_chain key is not supported.
function! ale#linter#GetCommand(buffer, linter) abort
- return has_key(a:linter, 'command_callback')
- \ ? ale#util#GetFunction(a:linter.command_callback)(a:buffer)
+ let l:Command = has_key(a:linter, 'command_callback')
+ \ ? function(a:linter.command_callback)
\ : a:linter.command
+
+ return type(l:Command) is v:t_func
+ \ ? l:Command(a:buffer)
+ \ : l:Command
endfunction
" Given a buffer and linter, get the address for connecting to the server.