summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/engine.vim2
-rw-r--r--autoload/ale/fix.vim2
-rw-r--r--autoload/ale/job.vim43
-rw-r--r--autoload/ale/linter.vim2
4 files changed, 41 insertions, 8 deletions
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim
index 8441ad16..70b5a3ba 100644
--- a/autoload/ale/engine.vim
+++ b/autoload/ale/engine.vim
@@ -512,7 +512,7 @@ function! s:RunJob(options) abort
endif
endif
- let l:command = ale#job#PrepareCommand(l:command)
+ let l:command = ale#job#PrepareCommand(l:buffer, l:command)
let l:job_options = {
\ 'mode': 'nl',
\ 'exit_cb': function('s:HandleExit'),
diff --git a/autoload/ale/fix.vim b/autoload/ale/fix.vim
index 0a270ecc..62a4f9b1 100644
--- a/autoload/ale/fix.vim
+++ b/autoload/ale/fix.vim
@@ -222,7 +222,7 @@ function! s:RunJob(options) abort
\)
call s:CreateTemporaryFileForJob(l:buffer, l:temporary_file, l:input)
- let l:command = ale#job#PrepareCommand(l:command)
+ let l:command = ale#job#PrepareCommand(l:buffer, l:command)
let l:job_options = {
\ 'mode': 'nl',
\ 'exit_cb': function('s:HandleExit'),
diff --git a/autoload/ale/job.vim b/autoload/ale/job.vim
index e6a75c88..2e0b8ca2 100644
--- a/autoload/ale/job.vim
+++ b/autoload/ale/job.vim
@@ -165,23 +165,54 @@ function! ale#job#ValidateArguments(command, options) abort
endif
endfunction
-function! ale#job#PrepareCommand(command) abort
+function! s:PrepareWrappedCommand(original_wrapper, command) abort
+ let l:match = matchlist(a:command, '\v^(.*(\&\&|;)) *(.*)$')
+ let l:prefix = ''
+ let l:command = a:command
+
+ if !empty(l:match)
+ let l:prefix = l:match[1] . ' '
+ let l:command = l:match[3]
+ endif
+
+ let l:format = a:original_wrapper
+
+ if l:format =~# '%@'
+ let l:wrapped = substitute(l:format, '%@', ale#Escape(l:command), '')
+ else
+ if l:format !~# '%\*'
+ let l:format .= ' %*'
+ endif
+
+ let l:wrapped = substitute(l:format, '%\*', l:command, '')
+ endif
+
+ return l:prefix . l:wrapped
+endfunction
+
+function! ale#job#PrepareCommand(buffer, command) abort
+ let l:wrapper = ale#Var(a:buffer, 'command_wrapper')
+
+ let l:command = !empty(l:wrapper)
+ \ ? s:PrepareWrappedCommand(l:wrapper, a:command)
+ \ : a:command
+
" The command will be executed in a subshell. This fixes a number of
" issues, including reading the PATH variables correctly, %PATHEXT%
" expansion on Windows, etc.
"
" NeoVim handles this issue automatically if the command is a String,
- " but we'll do this explicitly, so we use thes same exact command for both
+ " but we'll do this explicitly, so we use the same exact command for both
" versions.
- if ale#Has('win32')
- return 'cmd /c ' . a:command
+ if has('win32')
+ return 'cmd /c ' . l:command
endif
if &shell =~? 'fish$'
- return ['/bin/sh', '-c', a:command]
+ return ['/bin/sh', '-c', l:command]
endif
- return split(&shell) + split(&shellcmdflag) + [a:command]
+ return split(&shell) + split(&shellcmdflag) + [l:command]
endfunction
" Start a job with options which are agnostic to Vim and NeoVim.
diff --git a/autoload/ale/linter.vim b/autoload/ale/linter.vim
index f4fa0c44..d059a12d 100644
--- a/autoload/ale/linter.vim
+++ b/autoload/ale/linter.vim
@@ -1,3 +1,4 @@
+call ale#Set('wrap_command_as_one_argument', 0)
" Author: w0rp <devw0rp@gmail.com>
" Description: Linter registration and lazy-loading
" Retrieves linters as requested by the engine, loading them if needed.
@@ -432,6 +433,7 @@ function! ale#linter#StartLSP(buffer, linter, callback) abort
endif
let l:command = ale#job#PrepareCommand(
+ \ a:buffer,
\ ale#linter#GetCommand(a:buffer, a:linter),
\)
let l:conn_id = ale#lsp#StartProgram(