summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2021-03-01 20:11:10 +0000
committerw0rp <devw0rp@gmail.com>2021-03-01 20:11:10 +0000
commit9fe7b1fe6a23fb55e6d782293585d58193123f59 (patch)
tree0403deb70011aee7be08e586b10b5828cf69499e /ale_linters
parent48fab99a0ab793e1b9607795c21659f12bd6947f (diff)
downloadale-9fe7b1fe6a23fb55e6d782293585d58193123f59.zip
Close #2281 - Separate cwd commands from commands
Working directories are now set seperately from the commands so they can later be swapped out when running linters over projects is supported, and also better support filename mapping for running linters on other machines in future.
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/c/cppcheck.vim5
-rw-r--r--ale_linters/cpp/cppcheck.vim5
-rw-r--r--ale_linters/cs/csc.vim17
-rw-r--r--ale_linters/cs/mcsc.vim16
-rw-r--r--ale_linters/d/dmd.vim30
-rw-r--r--ale_linters/elixir/credo.vim7
-rw-r--r--ale_linters/elixir/dialyxir.vim11
-rw-r--r--ale_linters/elixir/dogma.vim10
-rw-r--r--ale_linters/elixir/mix.vim11
-rw-r--r--ale_linters/elm/make.vim18
-rw-r--r--ale_linters/go/gobuild.vim4
-rw-r--r--ale_linters/go/golangci_lint.vim7
-rw-r--r--ale_linters/go/gometalinter.vim7
-rw-r--r--ale_linters/go/gosimple.vim8
-rw-r--r--ale_linters/go/gotype.vim12
-rw-r--r--ale_linters/go/govet.vim4
-rw-r--r--ale_linters/go/staticcheck.vim12
-rw-r--r--ale_linters/graphql/eslint.vim1
-rw-r--r--ale_linters/graphql/gqlint.vim9
-rw-r--r--ale_linters/haskell/cabal_ghc.vim4
-rw-r--r--ale_linters/haskell/stack_ghc.vim4
-rw-r--r--ale_linters/java/javac.vim13
-rw-r--r--ale_linters/javascript/eslint.vim1
-rw-r--r--ale_linters/kotlin/kotlinc.vim14
-rw-r--r--ale_linters/mercury/mmc.vim8
-rw-r--r--ale_linters/php/phpcs.vim4
-rw-r--r--ale_linters/python/flake8.vim18
-rw-r--r--ale_linters/python/mypy.vim16
-rw-r--r--ale_linters/python/pydocstyle.vim4
-rw-r--r--ale_linters/python/pylama.vim17
-rw-r--r--ale_linters/python/pylint.vim18
-rw-r--r--ale_linters/python/vulture.vim19
-rw-r--r--ale_linters/r/lintr.vim5
-rw-r--r--ale_linters/rst/rstcheck.vim11
-rw-r--r--ale_linters/ruby/ruby.vim2
-rw-r--r--ale_linters/rust/cargo.vim28
-rw-r--r--ale_linters/typescript/eslint.vim1
-rw-r--r--ale_linters/typescript/tslint.vim4
-rw-r--r--ale_linters/vim/ale_custom_linting_rules.vim11
39 files changed, 172 insertions, 224 deletions
diff --git a/ale_linters/c/cppcheck.vim b/ale_linters/c/cppcheck.vim
index 975ef047..28c2861f 100644
--- a/ale_linters/c/cppcheck.vim
+++ b/ale_linters/c/cppcheck.vim
@@ -5,15 +5,13 @@ call ale#Set('c_cppcheck_executable', 'cppcheck')
call ale#Set('c_cppcheck_options', '--enable=style')
function! ale_linters#c#cppcheck#GetCommand(buffer) abort
- let l:cd_command = ale#handlers#cppcheck#GetCdCommand(a:buffer)
let l:compile_commands_option = ale#handlers#cppcheck#GetCompileCommandsOptions(a:buffer)
let l:buffer_path_include = empty(l:compile_commands_option)
\ ? ale#handlers#cppcheck#GetBufferPathIncludeOptions(a:buffer)
\ : ''
let l:template = ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}')
- return l:cd_command
- \ . '%e -q --language=c'
+ return '%e -q --language=c'
\ . l:template
\ . ale#Pad(l:compile_commands_option)
\ . ale#Pad(ale#Var(a:buffer, 'c_cppcheck_options'))
@@ -25,6 +23,7 @@ call ale#linter#Define('c', {
\ 'name': 'cppcheck',
\ 'output_stream': 'both',
\ 'executable': {b -> ale#Var(b, 'c_cppcheck_executable')},
+\ 'cwd': function('ale#handlers#cppcheck#GetCwd'),
\ 'command': function('ale_linters#c#cppcheck#GetCommand'),
\ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat',
\})
diff --git a/ale_linters/cpp/cppcheck.vim b/ale_linters/cpp/cppcheck.vim
index 2578861d..eb86adf4 100644
--- a/ale_linters/cpp/cppcheck.vim
+++ b/ale_linters/cpp/cppcheck.vim
@@ -5,15 +5,13 @@ call ale#Set('cpp_cppcheck_executable', 'cppcheck')
call ale#Set('cpp_cppcheck_options', '--enable=style')
function! ale_linters#cpp#cppcheck#GetCommand(buffer) abort
- let l:cd_command = ale#handlers#cppcheck#GetCdCommand(a:buffer)
let l:compile_commands_option = ale#handlers#cppcheck#GetCompileCommandsOptions(a:buffer)
let l:buffer_path_include = empty(l:compile_commands_option)
\ ? ale#handlers#cppcheck#GetBufferPathIncludeOptions(a:buffer)
\ : ''
let l:template = ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}')
- return l:cd_command
- \ . '%e -q --language=c++'
+ return '%e -q --language=c++'
\ . l:template
\ . ale#Pad(l:compile_commands_option)
\ . ale#Pad(ale#Var(a:buffer, 'cpp_cppcheck_options'))
@@ -25,6 +23,7 @@ call ale#linter#Define('cpp', {
\ 'name': 'cppcheck',
\ 'output_stream': 'both',
\ 'executable': {b -> ale#Var(b, 'cpp_cppcheck_executable')},
+\ 'cwd': function('ale#handlers#cppcheck#GetCwd'),
\ 'command': function('ale_linters#cpp#cppcheck#GetCommand'),
\ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat',
\})
diff --git a/ale_linters/cs/csc.vim b/ale_linters/cs/csc.vim
index 308abc77..5ee3de29 100644
--- a/ale_linters/cs/csc.vim
+++ b/ale_linters/cs/csc.vim
@@ -3,14 +3,10 @@ call ale#Set('cs_csc_source', '')
call ale#Set('cs_csc_assembly_path', [])
call ale#Set('cs_csc_assemblies', [])
-function! s:GetWorkingDirectory(buffer) abort
- let l:working_directory = ale#Var(a:buffer, 'cs_csc_source')
+function! ale_linters#cs#csc#GetCwd(buffer) abort
+ let l:cwd = ale#Var(a:buffer, 'cs_csc_source')
- if !empty(l:working_directory)
- return l:working_directory
- endif
-
- return expand('#' . a:buffer . ':p:h')
+ return !empty(l:cwd) ? l:cwd : expand('#' . a:buffer . ':p:h')
endfunction
function! ale_linters#cs#csc#GetCommand(buffer) abort
@@ -34,8 +30,7 @@ function! ale_linters#cs#csc#GetCommand(buffer) abort
" The code is compiled as a module and the output is redirected to a
" temporary file.
- return ale#path#CdString(s:GetWorkingDirectory(a:buffer))
- \ . 'csc /unsafe'
+ return 'csc /unsafe'
\ . ale#Pad(ale#Var(a:buffer, 'cs_csc_options'))
\ . ale#Pad(l:lib_option)
\ . ale#Pad(l:r_option)
@@ -57,8 +52,7 @@ function! ale_linters#cs#csc#Handle(buffer, lines) abort
\ '^\v([^ ]+)\s+([Cc][sS][^ ]+):\s+(.+)$',
\]
let l:output = []
-
- let l:dir = s:GetWorkingDirectory(a:buffer)
+ let l:dir = ale_linters#cs#csc#GetCwd(a:buffer)
for l:match in ale#util#GetMatches(a:lines, l:patterns)
if len(l:match) > 6 && strlen(l:match[5]) > 2 && l:match[5][:1] is? 'CS'
@@ -89,6 +83,7 @@ call ale#linter#Define('cs',{
\ 'name': 'csc',
\ 'output_stream': 'stdout',
\ 'executable': 'csc',
+\ 'cwd': function('ale_linters#cs#csc#GetCwd'),
\ 'command': function('ale_linters#cs#csc#GetCommand'),
\ 'callback': 'ale_linters#cs#csc#Handle',
\ 'lint_file': 1
diff --git a/ale_linters/cs/mcsc.vim b/ale_linters/cs/mcsc.vim
index 0e4e5667..2dd46661 100644
--- a/ale_linters/cs/mcsc.vim
+++ b/ale_linters/cs/mcsc.vim
@@ -3,14 +3,10 @@ call ale#Set('cs_mcsc_source', '')
call ale#Set('cs_mcsc_assembly_path', [])
call ale#Set('cs_mcsc_assemblies', [])
-function! s:GetWorkingDirectory(buffer) abort
- let l:working_directory = ale#Var(a:buffer, 'cs_mcsc_source')
+function! ale_linters#cs#mcsc#GetCwd(buffer) abort
+ let l:cwd = ale#Var(a:buffer, 'cs_mcsc_source')
- if !empty(l:working_directory)
- return l:working_directory
- endif
-
- return expand('#' . a:buffer . ':p:h')
+ return !empty(l:cwd) ? l:cwd : expand('#' . a:buffer . ':p:h')
endfunction
function! ale_linters#cs#mcsc#GetCommand(buffer) abort
@@ -34,8 +30,7 @@ function! ale_linters#cs#mcsc#GetCommand(buffer) abort
" The code is compiled as a module and the output is redirected to a
" temporary file.
- return ale#path#CdString(s:GetWorkingDirectory(a:buffer))
- \ . 'mcs -unsafe'
+ return 'mcs -unsafe'
\ . ale#Pad(ale#Var(a:buffer, 'cs_mcsc_options'))
\ . ale#Pad(l:lib_option)
\ . ale#Pad(l:r_option)
@@ -58,7 +53,7 @@ function! ale_linters#cs#mcsc#Handle(buffer, lines) abort
\]
let l:output = []
- let l:dir = s:GetWorkingDirectory(a:buffer)
+ let l:dir = ale_linters#cs#mcsc#GetCwd(a:buffer)
for l:match in ale#util#GetMatches(a:lines, l:patterns)
if len(l:match) > 6 && strlen(l:match[5]) > 2 && l:match[5][:1] is? 'CS'
@@ -89,6 +84,7 @@ call ale#linter#Define('cs',{
\ 'name': 'mcsc',
\ 'output_stream': 'stderr',
\ 'executable': 'mcs',
+\ 'cwd': function('ale_linters#cs#mcsc#GetCwd'),
\ 'command': function('ale_linters#cs#mcsc#GetCommand'),
\ 'callback': 'ale_linters#cs#mcsc#Handle',
\ 'lint_file': 1
diff --git a/ale_linters/d/dmd.vim b/ale_linters/d/dmd.vim
index 14461ae6..cc5d8bc6 100644
--- a/ale_linters/d/dmd.vim
+++ b/ale_linters/d/dmd.vim
@@ -1,35 +1,37 @@
" Author: w0rp <devw0rp@gmail.com>
" Description: "dmd for D files"
-function! ale_linters#d#dmd#GetDUBCommand(buffer) abort
+function! s:GetDUBCommand(buffer) abort
" If we can't run dub, then skip this command.
if !executable('dub')
" Returning an empty string skips to the DMD command.
- return ''
- endif
-
- let l:dub_file = ale#d#FindDUBConfig(a:buffer)
+ let l:config = ale#d#FindDUBConfig(a:buffer)
- if empty(l:dub_file)
- return ''
+ " To support older dub versions, we just change the directory to the
+ " directory where we found the dub config, and then run `dub describe`
+ " from that directory.
+ if !empty(l:config)
+ return [fnamemodify(l:config, ':h'), 'dub describe --import-paths']
+ endif
endif
- " To support older dub versions, we just change the directory to
- " the directory where we found the dub config, and then run `dub describe`
- " from that directory.
- return 'cd ' . ale#Escape(fnamemodify(l:dub_file, ':h'))
- \ . ' && dub describe --import-paths'
+ return ['', '']
endfunction
function! ale_linters#d#dmd#RunDUBCommand(buffer) abort
- let l:command = ale_linters#d#dmd#GetDUBCommand(a:buffer)
+ let [l:cwd, l:command] = s:GetDUBCommand(a:buffer)
if empty(l:command)
" If we can't run DUB, just run DMD.
return ale_linters#d#dmd#DMDCommand(a:buffer, [], {})
endif
- return ale#command#Run(a:buffer, l:command, function('ale_linters#d#dmd#DMDCommand'))
+ return ale#command#Run(
+ \ a:buffer,
+ \ l:command,
+ \ function('ale_linters#d#dmd#DMDCommand'),
+ \ {'cwd': l:cwd},
+ \)
endfunction
function! ale_linters#d#dmd#DMDCommand(buffer, dub_output, meta) abort
diff --git a/ale_linters/elixir/credo.vim b/ale_linters/elixir/credo.vim
index 892d47b9..d6a861f4 100644
--- a/ale_linters/elixir/credo.vim
+++ b/ale_linters/elixir/credo.vim
@@ -56,11 +56,7 @@ function! ale_linters#elixir#credo#GetConfigFile() abort
endfunction
function! ale_linters#elixir#credo#GetCommand(buffer) abort
- let l:project_root = ale#handlers#elixir#FindMixUmbrellaRoot(a:buffer)
- let l:mode = ale_linters#elixir#credo#GetMode()
-
- return ale#path#CdString(l:project_root)
- \ . 'mix help credo && '
+ return 'mix help credo && '
\ . 'mix credo ' . ale_linters#elixir#credo#GetMode()
\ . ale_linters#elixir#credo#GetConfigFile()
\ . ' --format=flycheck --read-from-stdin %s'
@@ -69,6 +65,7 @@ endfunction
call ale#linter#Define('elixir', {
\ 'name': 'credo',
\ 'executable': 'mix',
+\ 'cwd': function('ale#handlers#elixir#FindMixUmbrellaRoot'),
\ 'command': function('ale_linters#elixir#credo#GetCommand'),
\ 'callback': 'ale_linters#elixir#credo#Handle',
\})
diff --git a/ale_linters/elixir/dialyxir.vim b/ale_linters/elixir/dialyxir.vim
index c7da7757..9b8a5cda 100644
--- a/ale_linters/elixir/dialyxir.vim
+++ b/ale_linters/elixir/dialyxir.vim
@@ -25,17 +25,10 @@ function! ale_linters#elixir#dialyxir#Handle(buffer, lines) abort
return l:output
endfunction
-function! ale_linters#elixir#dialyxir#GetCommand(buffer) abort
- let l:project_root = ale#handlers#elixir#FindMixProjectRoot(a:buffer)
-
- return ale#path#CdString(l:project_root)
- \ . ' mix help dialyzer && mix dialyzer'
-endfunction
-
call ale#linter#Define('elixir', {
\ 'name': 'dialyxir',
\ 'executable': 'mix',
-\ 'command': function('ale_linters#elixir#dialyxir#GetCommand'),
+\ 'cwd': function('ale#handlers#elixir#FindMixProjectRoot'),
+\ 'command': 'mix help dialyzer && mix dialyzer',
\ 'callback': 'ale_linters#elixir#dialyxir#Handle',
\})
-
diff --git a/ale_linters/elixir/dogma.vim b/ale_linters/elixir/dogma.vim
index 1c721158..28e7f420 100644
--- a/ale_linters/elixir/dogma.vim
+++ b/ale_linters/elixir/dogma.vim
@@ -29,17 +29,11 @@ function! ale_linters#elixir#dogma#Handle(buffer, lines) abort
return l:output
endfunction
-function! ale_linters#elixir#dogma#GetCommand(buffer) abort
- let l:project_root = ale#handlers#elixir#FindMixProjectRoot(a:buffer)
-
- return ale#path#CdString(l:project_root)
- \ . ' mix help dogma && mix dogma %s --format=flycheck'
-endfunction
-
call ale#linter#Define('elixir', {
\ 'name': 'dogma',
\ 'executable': 'mix',
-\ 'command': function('ale_linters#elixir#dogma#GetCommand'),
+\ 'cwd': function('ale#handlers#elixir#FindMixProjectRoot'),
+\ 'command': 'mix help dogma && mix dogma %s --format=flycheck',
\ 'lint_file': 1,
\ 'callback': 'ale_linters#elixir#dogma#Handle',
\})
diff --git a/ale_linters/elixir/mix.vim b/ale_linters/elixir/mix.vim
index abf5d0aa..948c6d36 100644
--- a/ale_linters/elixir/mix.vim
+++ b/ale_linters/elixir/mix.vim
@@ -30,22 +30,15 @@ function! ale_linters#elixir#mix#Handle(buffer, lines) abort
endfunction
function! ale_linters#elixir#mix#GetCommand(buffer) abort
- let l:project_root = ale#handlers#elixir#FindMixProjectRoot(a:buffer)
-
let l:temp_dir = ale#command#CreateDirectory(a:buffer)
- let l:mix_build_path = has('win32')
- \ ? 'set MIX_BUILD_PATH=' . ale#Escape(l:temp_dir) . ' &&'
- \ : 'MIX_BUILD_PATH=' . ale#Escape(l:temp_dir)
-
- return ale#path#CdString(l:project_root)
- \ . l:mix_build_path
- \ . ' mix compile %s'
+ return ale#Env('MIX_BUILD_PATH', l:temp_dir) . 'mix compile %s'
endfunction
call ale#linter#Define('elixir', {
\ 'name': 'mix',
\ 'executable': 'mix',
+\ 'cwd': function('ale#handlers#elixir#FindMixProjectRoot'),
\ 'command': function('ale_linters#elixir#mix#GetCommand'),
\ 'callback': 'ale_linters#elixir#mix#Handle',
\ 'lint_file': 1,
diff --git a/ale_linters/elm/make.vim b/ale_linters/elm/make.vim
index 6b93257f..48ed82f3 100644
--- a/ale_linters/elm/make.vim
+++ b/ale_linters/elm/make.vim
@@ -186,20 +186,19 @@ function! ale_linters#elm#make#IsTest(buffer) abort
endif
endfunction
+function! ale_linters#elm#make#GetCwd(buffer) abort
+ let l:root_dir = ale_linters#elm#make#GetRootDir(a:buffer)
+
+ return !empty(l:root_dir) ? l:root_dir : ''
+endfunction
+
" Return the command to execute the linter in the projects directory.
" If it doesn't, then this will fail when imports are needed.
function! ale_linters#elm#make#GetCommand(buffer) abort
let l:executable = ale_linters#elm#make#GetExecutable(a:buffer)
- let l:root_dir = ale_linters#elm#make#GetRootDir(a:buffer)
let l:is_v19 = ale_linters#elm#make#IsVersionGte19(a:buffer)
let l:is_using_elm_test = l:executable =~# 'elm-test$'
- if empty(l:root_dir)
- let l:dir_set_cmd = ''
- else
- let l:dir_set_cmd = 'cd ' . ale#Escape(l:root_dir) . ' && '
- endif
-
" elm-test needs to know the path of elm-make if elm isn't installed globally.
" https://github.com/rtfeldman/node-test-runner/blob/57728f10668f2d2ab3179e7e3208bcfa9a1f19aa/README.md#--compiler
if l:is_v19 && l:is_using_elm_test
@@ -213,7 +212,9 @@ function! ale_linters#elm#make#GetCommand(buffer) abort
" a sort of flag to tell the compiler not to generate an output file,
" which is why this is hard coded here.
" Source: https://github.com/elm-lang/elm-compiler/blob/19d5a769b30ec0b2fc4475985abb4cd94cd1d6c3/builder/src/Generate/Output.hs#L253
- return l:dir_set_cmd . '%e make --report=json --output=/dev/null' . l:elm_test_compiler_flag . '%t'
+ return '%e make --report=json --output=/dev/null'
+ \ . l:elm_test_compiler_flag
+ \ . '%t'
endfunction
function! ale_linters#elm#make#GetExecutable(buffer) abort
@@ -235,6 +236,7 @@ call ale#linter#Define('elm', {
\ 'name': 'make',
\ 'executable': function('ale_linters#elm#make#GetExecutable'),
\ 'output_stream': 'both',
+\ 'cwd': function('ale_linters#elm#make#GetCwd'),
\ 'command': function('ale_linters#elm#make#GetCommand'),
\ 'callback': 'ale_linters#elm#make#Handle'
\})
diff --git a/ale_linters/go/gobuild.vim b/ale_linters/go/gobuild.vim
index 1dfb6daa..5210c5a8 100644
--- a/ale_linters/go/gobuild.vim
+++ b/ale_linters/go/gobuild.vim
@@ -10,8 +10,7 @@ function! ale_linters#go#gobuild#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'go_gobuild_options')
" Run go test in local directory with relative path
- return ale#path#BufferCdString(a:buffer)
- \ . ale#go#EnvString(a:buffer)
+ return ale#go#EnvString(a:buffer)
\ . ale#Var(a:buffer, 'go_go_executable') . ' test'
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' -c -o /dev/null ./'
@@ -50,6 +49,7 @@ call ale#linter#Define('go', {
\ 'name': 'gobuild',
\ 'aliases': ['go build'],
\ 'executable': {b -> ale#Var(b, 'go_go_executable')},
+\ 'cwd': '%s:h',
\ 'command': function('ale_linters#go#gobuild#GetCommand'),
\ 'output_stream': 'stderr',
\ 'callback': 'ale_linters#go#gobuild#Handler',
diff --git a/ale_linters/go/golangci_lint.vim b/ale_linters/go/golangci_lint.vim
index dd0e975a..2c4b1a4f 100644
--- a/ale_linters/go/golangci_lint.vim
+++ b/ale_linters/go/golangci_lint.vim
@@ -12,14 +12,12 @@ function! ale_linters#go#golangci_lint#GetCommand(buffer) abort
if l:lint_package
- return ale#path#BufferCdString(a:buffer)
- \ . ale#go#EnvString(a:buffer)
+ return ale#go#EnvString(a:buffer)
\ . '%e run '
\ . l:options
endif
- return ale#path#BufferCdString(a:buffer)
- \ . ale#go#EnvString(a:buffer)
+ return ale#go#EnvString(a:buffer)
\ . '%e run '
\ . ale#Escape(l:filename)
\ . ' ' . l:options
@@ -53,6 +51,7 @@ endfunction
call ale#linter#Define('go', {
\ 'name': 'golangci-lint',
\ 'executable': {b -> ale#Var(b, 'go_golangci_lint_executable')},
+\ 'cwd': '%s:h',
\ 'command': function('ale_linters#go#golangci_lint#GetCommand'),
\ 'callback': 'ale_linters#go#golangci_lint#Handler',
\ 'lint_file': 1,
diff --git a/ale_linters/go/gometalinter.vim b/ale_linters/go/gometalinter.vim
index eed9550a..ac33a9f3 100644
--- a/ale_linters/go/gometalinter.vim
+++ b/ale_linters/go/gometalinter.vim
@@ -13,14 +13,12 @@ function! ale_linters#go#gometalinter#GetCommand(buffer) abort
" BufferCdString is used so that we can be sure the paths output from gometalinter can
" be calculated to absolute paths in the Handler
if l:lint_package
- return ale#path#BufferCdString(a:buffer)
- \ . ale#go#EnvString(a:buffer)
+ return ale#go#EnvString(a:buffer)
\ . '%e'
\ . (!empty(l:options) ? ' ' . l:options : '') . ' .'
endif
- return ale#path#BufferCdString(a:buffer)
- \ . ale#go#EnvString(a:buffer)
+ return ale#go#EnvString(a:buffer)
\ . '%e'
\ . ' --include=' . ale#Escape(ale#util#EscapePCRE(l:filename))
\ . (!empty(l:options) ? ' ' . l:options : '') . ' .'
@@ -53,6 +51,7 @@ endfunction
call ale#linter#Define('go', {
\ 'name': 'gometalinter',
\ 'executable': {b -> ale#Var(b, 'go_gometalinter_executable')},
+\ 'cwd': '%s:h',
\ 'command': function('ale_linters#go#gometalinter#GetCommand'),
\ 'callback': 'ale_linters#go#gometalinter#Handler',
\ 'lint_file': 1,
diff --git a/ale_linters/go/gosimple.vim b/ale_linters/go/gosimple.vim
index ad52c621..490d15a9 100644
--- a/ale_linters/go/gosimple.vim
+++ b/ale_linters/go/gosimple.vim
@@ -1,15 +1,11 @@
" Author: Ben Reedy <https://github.com/breed808>
" Description: gosimple for Go files
-function! ale_linters#go#gosimple#GetCommand(buffer) abort
- return ale#path#BufferCdString(a:buffer) . ' '
- \ . ale#go#EnvString(a:buffer) . 'gosimple .'
-endfunction
-
call ale#linter#Define('go', {
\ 'name': 'gosimple',
\ 'executable': 'gosimple',
-\ 'command': function('ale_linters#go#gosimple#GetCommand'),
+\ 'cwd': '%s:h',
+\ 'command': {b -> ale#go#EnvString(b) . 'gosimple .'},
\ 'callback': 'ale#handlers#go#Handler',
\ 'output_stream': 'both',
\ 'lint_file': 1,
diff --git a/ale_linters/go/gotype.vim b/ale_linters/go/gotype.vim
index 6a5149ca..8fd6df27 100644
--- a/ale_linters/go/gotype.vim
+++ b/ale_linters/go/gotype.vim
@@ -1,19 +1,23 @@
" Author: Jelte Fennema <github-public@jeltef.nl>
" Description: gotype for Go files
-function! ale_linters#go#gotype#GetCommand(buffer) abort
+function! ale_linters#go#gotype#GetExecutable(buffer) abort
if expand('#' . a:buffer . ':p') =~# '_test\.go$'
return ''
endif
- return ale#path#BufferCdString(a:buffer) . ' '
- \ . ale#go#EnvString(a:buffer) . 'gotype -e .'
+ return 'gotype'
+endfunction
+
+function! ale_linters#go#gotype#GetCommand(buffer) abort
+ return ale#go#EnvString(a:buffer) . 'gotype -e .'
endfunction
call ale#linter#Define('go', {
\ 'name': 'gotype',
\ 'output_stream': 'stderr',
-\ 'executable': 'gotype',
+\ 'executable': function('ale_linters#go#gotype#GetExecutable'),
+\ 'cwd': '%s:h',
\ 'command': function('ale_linters#go#gotype#GetCommand'),
\ 'callback': 'ale#handlers#go#Handler',
\ 'lint_file': 1,
diff --git a/ale_linters/go/govet.vim b/ale_linters/go/govet.vim
index dddafe17..5da8261c 100644
--- a/ale_linters/go/govet.vim
+++ b/ale_linters/go/govet.vim
@@ -10,8 +10,7 @@ call ale#Set('go_govet_options', '')
function! ale_linters#go#govet#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'go_govet_options')
- return ale#path#BufferCdString(a:buffer) . ' '
- \ . ale#go#EnvString(a:buffer)
+ return ale#go#EnvString(a:buffer)
\ . ale#Var(a:buffer, 'go_go_executable') . ' vet '
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' .'
@@ -22,6 +21,7 @@ call ale#linter#Define('go', {
\ 'aliases': ['go vet'],
\ 'output_stream': 'stderr',
\ 'executable': {b -> ale#Var(b, 'go_go_executable')},
+\ 'cwd': '%s:h',
\ 'command': function('ale_linters#go#govet#GetCommand'),
\ 'callback': 'ale#handlers#go#Handler',
\ 'lint_file': 1,
diff --git a/ale_linters/go/staticcheck.vim b/ale_linters/go/staticcheck.vim
index ed40c6c2..84e70d58 100644
--- a/ale_linters/go/staticcheck.vim
+++ b/ale_linters/go/staticcheck.vim
@@ -5,28 +5,24 @@ call ale#Set('go_staticcheck_options', '')
call ale#Set('go_staticcheck_lint_package', 0)
function! ale_linters#go#staticcheck#GetCommand(buffer) abort
- let l:filename = expand('#' . a:buffer . ':t')
let l:options = ale#Var(a:buffer, 'go_staticcheck_options')
let l:lint_package = ale#Var(a:buffer, 'go_staticcheck_lint_package')
let l:env = ale#go#EnvString(a:buffer)
- " BufferCdString is used so that we can be sure the paths output from
- " staticcheck can be calculated to absolute paths in the Handler
if l:lint_package
- return ale#path#BufferCdString(a:buffer)
- \ . l:env . 'staticcheck'
+ return l:env . 'staticcheck'
\ . (!empty(l:options) ? ' ' . l:options : '') . ' .'
endif
- return ale#path#BufferCdString(a:buffer)
- \ . l:env . 'staticcheck'
+ return l:env . 'staticcheck'
\ . (!empty(l:options) ? ' ' . l:options : '')
- \ . ' ' . ale#Escape(l:filename)
+ \ . ' %s:t'
endfunction
call ale#linter#Define('go', {
\ 'name': 'staticcheck',
\ 'executable': 'staticcheck',
+\ 'cwd': '%s:h',
\ 'command': function('ale_linters#go#staticcheck#GetCommand'),
\ 'callback': 'ale#handlers#go#Handler',
\ 'output_stream': 'both',
diff --git a/ale_linters/graphql/eslint.vim b/ale_linters/graphql/eslint.vim
index aed1a371..a98233e9 100644
--- a/ale_linters/graphql/eslint.vim
+++ b/ale_linters/graphql/eslint.vim
@@ -4,6 +4,7 @@
call ale#linter#Define('graphql', {
\ 'name': 'eslint',
\ 'executable': function('ale#handlers#eslint#GetExecutable'),
+\ 'cwd': function('ale#handlers#eslint#GetCwd'),
\ 'command': function('ale#handlers#eslint#GetCommand'),
\ 'callback': 'ale#handlers#eslint#HandleJSON',
\})
diff --git a/ale_linters/graphql/gqlint.vim b/ale_linters/graphql/gqlint.vim
index d5029de1..6f1ca54a 100644
--- a/ale_linters/graphql/gqlint.vim
+++ b/ale_linters/graphql/gqlint.vim
@@ -1,15 +1,10 @@
" Author: Michiel Westerbeek <happylinks@gmail.com>
" Description: Linter for GraphQL Schemas
-function! ale_linters#graphql#gqlint#GetCommand(buffer) abort
- return ale#path#BufferCdString(a:buffer)
- \ . 'gqlint'
- \ . ' --reporter=simple %t'
-endfunction
-
call ale#linter#Define('graphql', {
\ 'name': 'gqlint',
\ 'executable': 'gqlint',
-\ 'command': function('ale_linters#graphql#gqlint#GetCommand'),
+\ 'cwd': '%s:h',
+\ 'command': 'gqlint --reporter=simple %t',
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
\})
diff --git a/ale_linters/haskell/cabal_ghc.vim b/ale_linters/haskell/cabal_ghc.vim
index f3f248f5..1bb31ebb 100644
--- a/ale_linters/haskell/cabal_ghc.vim
+++ b/ale_linters/haskell/cabal_ghc.vim
@@ -4,8 +4,7 @@
call ale#Set('haskell_cabal_ghc_options', '-fno-code -v0')
function! ale_linters#haskell#cabal_ghc#GetCommand(buffer) abort
- return ale#path#BufferCdString(a:buffer)
- \ . 'cabal exec -- ghc '
+ return 'cabal exec -- ghc '
\ . ale#Var(a:buffer, 'haskell_cabal_ghc_options')
\ . ' %t'
endfunction
@@ -15,6 +14,7 @@ call ale#linter#Define('haskell', {
\ 'aliases': ['cabal-ghc'],
\ 'output_stream': 'stderr',
\ 'executable': 'cabal',
+\ 'cwd': '%s:h',
\ 'command': function('ale_linters#haskell#cabal_ghc#GetCommand'),
\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
\})
diff --git a/ale_linters/haskell/stack_ghc.vim b/ale_linters/haskell/stack_ghc.vim
index c345fe43..51ecc744 100644
--- a/ale_linters/haskell/stack_ghc.vim
+++ b/ale_linters/haskell/stack_ghc.vim
@@ -4,8 +4,7 @@
call ale#Set('haskell_stack_ghc_options', '-fno-code -v0')
function! ale_linters#haskell#stack_ghc#GetCommand(buffer) abort
- return ale#path#BufferCdString(a:buffer)
- \ . ale#handlers#haskell#GetStackExecutable(a:buffer)
+ return ale#handlers#haskell#GetStackExecutable(a:buffer)
\ . ' ghc -- '
\ . ale#Var(a:buffer, 'haskell_stack_ghc_options')
\ . ' %t'
@@ -16,6 +15,7 @@ call ale#linter#Define('haskell', {
\ 'aliases': ['stack-ghc'],
\ 'output_stream': 'stderr',
\ 'executable': function('ale#handlers#haskell#GetStackExecutable'),
+\ 'cwd': '%s:h',
\ 'command': function('ale_linters#haskell#stack_ghc#GetCommand'),
\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
\})
diff --git a/ale_linters/java/javac.vim b/ale_linters/java/javac.vim
index a5e57e6c..760f234c 100644
--- a/ale_linters/java/javac.vim
+++ b/ale_linters/java/javac.vim
@@ -9,16 +9,16 @@ call ale#Set('java_javac_classpath', '')
call ale#Set('java_javac_sourcepath', '')
function! ale_linters#java#javac#RunWithImportPaths(buffer) abort
- let l:command = ale#maven#BuildClasspathCommand(a:buffer)
+ let [l:cwd, l:command] = ale#maven#BuildClasspathCommand(a:buffer)
" Try to use Gradle if Maven isn't available.
if empty(l:command)
- let l:command = ale#gradle#BuildClasspathCommand(a:buffer)
+ let [l:cwd, l:command] = ale#gradle#BuildClasspathCommand(a:buffer)
endif
" Try to use Ant if Gradle and Maven aren't available
if empty(l:command)
- let l:command = ale#ant#BuildClasspathCommand(a:buffer)
+ let [l:cwd, l:command] = ale#ant#BuildClasspathCommand(a:buffer)
endif
if empty(l:command)
@@ -28,7 +28,8 @@ function! ale_linters#java#javac#RunWithImportPaths(buffer) abort
return ale#command#Run(
\ a:buffer,
\ l:command,
- \ function('ale_linters#java#javac#GetCommand')
+ \ function('ale_linters#java#javac#GetCommand'),
+ \ {'cwd': l:cwd},
\)
endfunction
@@ -110,8 +111,7 @@ function! ale_linters#java#javac#GetCommand(buffer, import_paths, meta) abort
" Always run javac from the directory the file is in, so we can resolve
" relative paths correctly.
- return ale#path#BufferCdString(a:buffer)
- \ . '%e -Xlint'
+ return '%e -Xlint'
\ . ale#Pad(l:cp_option)
\ . ale#Pad(l:sp_option)
\ . ' -d ' . ale#Escape(l:class_file_directory)
@@ -154,6 +154,7 @@ endfunction
call ale#linter#Define('java', {
\ 'name': 'javac',
\ 'executable': {b -> ale#Var(b, 'java_javac_executable')},
+\ 'cwd': '%s:h',
\ 'command': function('ale_linters#java#javac#RunWithImportPaths'),
\ 'output_stream': 'stderr',
\ 'callback': 'ale_linters#java#javac#Handle',
diff --git a/ale_linters/javascript/eslint.vim b/ale_linters/javascript/eslint.vim
index 31fb413f..cf4de6ec 100644
--- a/ale_linters/javascript/eslint.vim
+++ b/ale_linters/javascript/eslint.vim
@@ -5,6 +5,7 @@ call ale#linter#Define('javascript', {
\ 'name': 'eslint',
\ 'output_stream': 'both',
\ 'executable': function('ale#handlers#eslint#GetExecutable'),
+\ 'cwd': function('ale#handlers#eslint#GetCwd'),
\ 'command': function('ale#handlers#eslint#GetCommand'),
\ 'callback': 'ale#handlers#eslint#HandleJSON',
\})
diff --git a/ale_linters/kotlin/kotlinc.vim b/ale_linters/kotlin/kotlinc.vim
index 66c075be..e8bc924d 100644
--- a/ale_linters/kotlin/kotlinc.vim
+++ b/ale_linters/kotlin/kotlinc.vim
@@ -15,20 +15,15 @@ function! ale_linters#kotlin#kotlinc#RunWithImportPaths(buffer) abort
let l:command = ''
" exec maven/gradle only if classpath is not set
- if ale#Var(a:buffer, 'kotlin_kotlinc_classpath') isnot# ''
+ if !empty(ale#Var(a:buffer, 'kotlin_kotlinc_classpath'))
return ale_linters#kotlin#kotlinc#GetCommand(a:buffer, [], {})
endif
- let l:pom_path = ale#path#FindNearestFile(a:buffer, 'pom.xml')
-
- if !empty(l:pom_path) && executable('mvn')
- let l:command = ale#path#CdString(fnamemodify(l:pom_path, ':h'))
- \ . 'mvn dependency:build-classpath'
- endif
+ let [l:cwd, l:command] = ale#maven#BuildClasspathCommand(a:buffer)
" Try to use Gradle if Maven isn't available.
if empty(l:command)
- let l:command = ale#gradle#BuildClasspathCommand(a:buffer)
+ let [l:cwd, l:command] = ale#gradle#BuildClasspathCommand(a:buffer)
endif
if empty(l:command)
@@ -38,7 +33,8 @@ function! ale_linters#kotlin#kotlinc#RunWithImportPaths(buffer) abort
return ale#command#Run(
\ a:buffer,
\ l:command,
- \ function('ale_linters#kotlin#kotlinc#GetCommand')
+ \ function('ale_linters#kotlin#kotlinc#GetCommand'),
+ \ {'cwd': l:cwd},
\)
endfunction
diff --git a/ale_linters/mercury/mmc.vim b/ale_linters/mercury/mmc.vim
index 8a9ccc0e..85969e10 100644
--- a/ale_linters/mercury/mmc.vim
+++ b/ale_linters/mercury/mmc.vim
@@ -5,12 +5,9 @@ call ale#Set('mercury_mmc_executable', 'mmc')
call ale#Set('mercury_mmc_options', '--make --output-compile-error-lines 100')
function! ale_linters#mercury#mmc#GetCommand(buffer) abort
- let l:module_name = expand('#' . a:buffer . ':t:r')
-
- return ale#path#BufferCdString(a:buffer)
- \ . '%e --errorcheck-only '
+ return '%e --errorcheck-only '
\ . ale#Var(a:buffer, 'mercury_mmc_options')
- \ . ' ' . l:module_name
+ \ . ' %s:t:r'
endfunction
function! ale_linters#mercury#mmc#Handle(buffer, lines) abort
@@ -34,6 +31,7 @@ call ale#linter#Define('mercury', {
\ 'name': 'mmc',
\ 'output_stream': 'stderr',
\ 'executable': {b -> ale#Var(b, 'mercury_mmc_executable')},
+\ 'cwd': '%s:h',
\ 'command': function('ale_linters#mercury#mmc#GetCommand'),
\ 'callback': 'ale_linters#mercury#mmc#Handle',
\ 'lint_file': 1,
diff --git a/ale_linters/php/phpcs.vim b/ale_linters/php/phpcs.vim
index c5a3faa9..3d88ad5d 100644
--- a/ale_linters/php/phpcs.vim
+++ b/ale_linters/php/phpcs.vim
@@ -13,8 +13,7 @@ function! ale_linters#php#phpcs#GetCommand(buffer) abort
\ ? '--standard=' . ale#Escape(l:standard)
\ : ''
- return ale#path#BufferCdString(a:buffer)
- \ . '%e -s --report=emacs --stdin-path=%s'
+ return '%e -s --report=emacs --stdin-path=%s'
\ . ale#Pad(l:standard_option)
\ . ale#Pad(ale#Var(a:buffer, 'php_phpcs_options'))
endfunction
@@ -49,6 +48,7 @@ call ale#linter#Define('php', {
\ 'vendor/bin/phpcs',
\ 'phpcs'
\ ])},
+\ 'cwd': '%s:h',
\ 'command': function('ale_linters#php#phpcs#GetCommand'),
\ 'callback': 'ale_linters#php#phpcs#Handle',
\})
diff --git a/ale_linters/python/flake8.vim b/ale_linters/python/flake8.vim
index fc4ab692..1d49d03f 100644
--- a/ale_linters/python/flake8.vim
+++ b/ale_linters/python/flake8.vim
@@ -38,30 +38,28 @@ function! ale_linters#python#flake8#RunWithVersionCheck(buffer) abort
\)
endfunction
-function! ale_linters#python#flake8#GetCdString(buffer) abort
+function! ale_linters#python#flake8#GetCwd(buffer) abort
let l:change_directory = ale#Var(a:buffer, 'python_flake8_change_directory')
- let l:cd_string = ''
+ let l:cwd = ''
if l:change_directory is# 'project'
let l:project_root = ale#python#FindProjectRootIni(a:buffer)
if !empty(l:project_root)
- let l:cd_string = ale#path#CdString(l:project_root)
+ let l:cwd = l:project_root
endif
endif
- if (l:change_directory is# 'project' && empty(l:cd_string))
+ if (l:change_directory is# 'project' && empty(l:cwd))
\|| l:change_directory is# 1
\|| l:change_directory is# 'file'
- let l:cd_string = ale#path#BufferCdString(a:buffer)
+ let l:cwd = '%s:h'
endif
- return l:cd_string
+ return l:cwd
endfunction
function! ale_linters#python#flake8#GetCommand(buffer, version) abort
- let l:cd_string = ale_linters#python#flake8#GetCdString(a:buffer)
-
let l:executable = ale_linters#python#flake8#GetExecutable(a:buffer)
let l:exec_args = l:executable =~? 'pipenv$'
@@ -76,8 +74,7 @@ function! ale_linters#python#flake8#GetCommand(buffer, version) abort
let l:options = ale#Var(a:buffer, 'python_flake8_options')
- return l:cd_string
- \ . ale#Escape(l:executable) . l:exec_args
+ return ale#Escape(l:executable) . l:exec_args
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' --format=default'
\ . l:display_name_args . ' -'
@@ -161,6 +158,7 @@ endfunction
call ale#linter#Define('python', {
\ 'name': 'flake8',
\ 'executable': function('ale_linters#python#flake8#GetExecutable'),
+\ 'cwd': function('ale_linters#python#flake8#GetCwd'),
\ 'command': function('ale_linters#python#flake8#RunWithVersionCheck'),
\ 'callback': 'ale_linters#python#flake8#Handle',
\})
diff --git a/ale_linters/python/mypy.vim b/ale_linters/python/mypy.vim
index 1e35d929..48697421 100644
--- a/ale_linters/python/mypy.vim
+++ b/ale_linters/python/mypy.vim
@@ -18,7 +18,7 @@ function! ale_linters#python#mypy#GetExecutable(buffer) abort
endfunction
" The directory to change to before running mypy
-function! s:GetDir(buffer) abort
+function! ale_linters#python#mypy#GetCwd(buffer) abort
" If we find a directory with "mypy.ini" in it use that,
" else try and find the "python project" root, or failing
" that, run from the same folder as the current file
@@ -36,26 +36,19 @@ function! s:GetDir(buffer) abort
endfunction
function! ale_linters#python#mypy#GetCommand(buffer) abort
- let l:dir = s:GetDir(a:buffer)
let l:executable = ale_linters#python#mypy#GetExecutable(a:buffer)
-
let l:exec_args = l:executable =~? 'pipenv$'
\ ? ' run mypy'
\ : ''
- let l:options = ale#Var(a:buffer, 'python_mypy_options')
-
- " We have to always switch to an explicit directory for a command so
- " we can know with certainty the base path for the 'filename' keys below.
- return ale#path#CdString(l:dir)
- \ . ale#Escape(l:executable) . l:exec_args
- \ . (len(l:options) ? (' ' . l:options) : '')
+ return '%e' . l:exec_args
+ \ . ale#Pad(ale#Var(a:buffer, 'python_mypy_options'))
\ . ' --show-column-numbers'
\ . ' --shadow-file %s %t %s'
endfunction
function! ale_linters#python#mypy#Handle(buffer, lines) abort
- let l:dir = s:GetDir(a:buffer)
+ let l:dir = ale_linters#python#mypy#GetCwd(a:buffer)
" Look for lines like the following:
"
" file.py:4: error: No library stub file for module 'django.db'
@@ -97,6 +90,7 @@ endfunction
call ale#linter#Define('python', {
\ 'name': 'mypy',
\ 'executable': function('ale_linters#python#mypy#GetExecutable'),
+\ 'cwd': function('ale_linters#python#mypy#GetCwd'),
\ 'command': function('ale_linters#python#mypy#GetCommand'),
\ 'callback': 'ale_linters#python#mypy#Handle',
\ 'output_stream': 'both'
diff --git a/ale_linters/python/pydocstyle.vim b/ale_linters/python/pydocstyle.vim
index 69ae3807..abf95fa1 100644
--- a/ale_linters/python/pydocstyle.vim
+++ b/ale_linters/python/pydocstyle.vim
@@ -21,8 +21,7 @@ function! ale_linters#python#pydocstyle#GetCommand(buffer) abort
\ ? ' run pydocstyle'
\ : ''
- return ale#path#BufferCdString(a:buffer)
- \ . ale#Escape(l:executable) . l:exec_args
+ return ale#Escape(l:executable) . l:exec_args
\ . ale#Pad(ale#Var(a:buffer, 'python_pydocstyle_options'))
\ . ' %s:t'
endfunction
@@ -66,6 +65,7 @@ endfunction
call ale#linter#Define('python', {
\ 'name': 'pydocstyle',
\ 'executable': function('ale_linters#python#pydocstyle#GetExecutable'),
+\ 'cwd': '%s:h',
\ 'command': function('ale_linters#python#pydocstyle#GetCommand'),
\ 'callback': 'ale_linters#python#pydocstyle#Handle',
\})
diff --git a/ale_linters/python/pylama.vim b/ale_linters/python/pylama.vim
index 38dd2836..bad69667 100644
--- a/ale_linters/python/pylama.vim
+++ b/ale_linters/python/pylama.vim
@@ -16,19 +16,20 @@ function! ale_linters#python#pylama#GetExecutable(buffer) abort
return ale#python#FindExecutable(a:buffer, 'python_pylama', ['pylama'])
endfunction
-function! ale_linters#python#pylama#GetCommand(buffer) abort
- let l:cd_string = ''
-
+function! ale_linters#python#pylama#GetCwd(buffer) abort
if ale#Var(a:buffer, 'python_pylama_change_directory')
" Pylama loads its configuration from the current directory only, and
" applies file masks using paths relative to the current directory.
" Run from project root, if found, otherwise buffer dir.
let l:project_root = ale#python#FindProjectRoot(a:buffer)
- let l:cd_string = l:project_root isnot# ''
- \ ? ale#path#CdString(l:project_root)
- \ : ale#path#BufferCdString(a:buffer)
+
+ return !empty(l:project_root) ? l:project_root : '%s:h'
endif
+ return ''
+endfunction
+
+function! ale_linters#python#pylama#GetCommand(buffer) abort
let l:executable = ale_linters#python#pylama#GetExecutable(a:buffer)
let l:exec_args = l:executable =~? 'pipenv$'
\ ? ' run pylama'
@@ -37,8 +38,7 @@ function! ale_linters#python#pylama#GetCommand(buffer) abort
" Note: Using %t to lint changes would be preferable, but many pylama
" checks use surrounding paths (e.g. C0103 module name, E0402 relative
" import beyond top, etc.). Neither is ideal.
- return l:cd_string
- \ . ale#Escape(l:executable) . l:exec_args
+ return ale#Escape(l:executable) . l:exec_args
\ . ale#Pad(ale#Var(a:buffer, 'python_pylama_options'))
\ . ' %s'
endfunction
@@ -86,6 +86,7 @@ endfunction
call ale#linter#Define('python', {
\ 'name': 'pylama',
\ 'executable': function('ale_linters#python#pylama#GetExecutable'),
+\ 'cwd': function('ale_linters#python#pylama#GetCwd'),
\ 'command': function('ale_linters#python#pylama#GetCommand'),
\ 'callback': 'ale_linters#python#pylama#Handle',
\ 'lint_file': 1,
diff --git a/ale_linters/python/pylint.vim b/ale_linters/python/pylint.vim
index 44eea246..f086a865 100644
--- a/ale_linters/python/pylint.vim
+++ b/ale_linters/python/pylint.vim
@@ -17,27 +17,26 @@ function! ale_linters#python#pylint#GetExecutable(buffer) abort
return ale#python#FindExecutable(a:buffer, 'python_pylint', ['pylint'])
endfunction
-function! ale_linters#python#pylint#GetCommand(buffer, version) abort
- let l:cd_string = ''
-
+function! ale_linters#python#pylint#GetCwd(buffer) abort
if ale#Var(a:buffer, 'python_pylint_change_directory')
" pylint only checks for pylintrc in the packages above its current
" directory before falling back to user and global pylintrc.
" Run from project root, if found, otherwise buffer dir.
let l:project_root = ale#python#FindProjectRoot(a:buffer)
- let l:cd_string = l:project_root isnot# ''
- \ ? ale#path#CdString(l:project_root)
- \ : ale#path#BufferCdString(a:buffer)
+
+ return !empty(l:project_root) ? l:project_root : '%s:h'
endif
- let l:executable = ale_linters#python#pylint#GetExecutable(a:buffer)
+ return ''
+endfunction
+function! ale_linters#python#pylint#GetCommand(buffer, version) abort
+ let l:executable = ale_linters#python#pylint#GetExecutable(a:buffer)
let l:exec_args = l:executable =~? 'pipenv$'
\ ? ' run pylint'
\ : ''
- return l:cd_string
- \ . ale#Escape(l:executable) . l:exec_args
+ return ale#Escape(l:executable) . l:exec_args
\ . ale#Pad(ale#Var(a:buffer, 'python_pylint_options'))
\ . ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n'
\ . (ale#semver#GTE(a:version, [2, 4, 0]) ? ' --from-stdin' : '')
@@ -104,6 +103,7 @@ call ale#linter#Define('python', {
\ '%e --version',
\ {buffer, version -> !ale#semver#GTE(version, [2, 4, 0])},
\ )},
+\ 'cwd': function('ale_linters#python#pylint#GetCwd'),
\ 'command': {buffer -> ale#semver#RunWithVersionCheck(
\ buffer,
\ ale#Var(buffer, 'python_pylint_executable'),
diff --git a/ale_linters/python/vulture.vim b/ale_linters/python/vulture.vim
index d328d262..84ffd49a 100644
--- a/ale_linters/python/vulture.vim
+++ b/ale_linters/python/vulture.vim
@@ -6,7 +6,6 @@ call ale#Set('python_vulture_options', '')
call ale#Set('python_vulture_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('python_vulture_change_directory', 1)
-
" The directory to change to before running vulture
function! s:GetDir(buffer) abort
let l:project_root = ale#python#FindProjectRoot(a:buffer)
@@ -16,29 +15,28 @@ function! s:GetDir(buffer) abort
\ : expand('#' . a:buffer . ':p:h')
endfunction
-
function! ale_linters#python#vulture#GetExecutable(buffer) abort
return ale#python#FindExecutable(a:buffer, 'python_vulture', ['vulture'])
endfunction
+function! ale_linters#python#vulture#GetCwd(buffer) abort
+ if !ale#Var(a:buffer, 'python_vulture_change_directory')
+ return ''
+ endif
-function! ale_linters#python#vulture#GetCommand(buffer) abort
- let l:change_dir = ale#Var(a:buffer, 'python_vulture_change_directory')
- \ ? ale#path#CdString(s:GetDir(a:buffer))
- \ : ''
+ return s:GetDir(a:buffer)
+endfunction
+function! ale_linters#python#vulture#GetCommand(buffer) abort
let l:executable = ale_linters#python#vulture#GetExecutable(a:buffer)
-
let l:exec_args = l:executable =~? 'pipenv$'
\ ? ' run vulture'
\ : ''
-
let l:lint_dest = ale#Var(a:buffer, 'python_vulture_change_directory')
\ ? ' .'
\ : ' %s'
- return l:change_dir
- \ . ale#Escape(l:executable) . l:exec_args
+ return ale#Escape(l:executable) . l:exec_args
\ . ' '
\ . ale#Var(a:buffer, 'python_vulture_options')
\ . l:lint_dest
@@ -74,6 +72,7 @@ endfunction
call ale#linter#Define('python', {
\ 'name': 'vulture',
\ 'executable': function('ale_linters#python#vulture#GetExecutable'),
+\ 'cwd': function('ale_linters#python#vulture#GetCwd'),
\ 'command': function('ale_linters#python#vulture#GetCommand'),
\ 'callback': 'ale_linters#python#vulture#Handle',
\ 'lint_file': 1,
diff --git a/ale_linters/r/lintr.vim b/ale_linters/r/lintr.vim
index 3164c06f..799458fb 100644
--- a/ale_linters/r/lintr.vim
+++ b/ale_linters/r/lintr.vim
@@ -21,14 +21,13 @@ function! ale_linters#r#lintr#GetCommand(buffer) abort
let l:cmd_string = 'suppressPackageStartupMessages(library(lintr));'
\ . l:lint_cmd
- return ale#path#BufferCdString(a:buffer)
- \ . 'Rscript --vanilla -e '
- \ . ale#Escape(l:cmd_string) . ' %t'
+ return 'Rscript --vanilla -e ' . ale#Escape(l:cmd_string) . ' %t'
endfunction
call ale#linter#Define('r', {
\ 'name': 'lintr',
\ 'executable': 'Rscript',
+\ 'cwd': '%s:h',
\ 'command': function('ale_linters#r#lintr#GetCommand'),
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
\ 'output_stream': 'both',
diff --git a/ale_linters/rst/rstcheck.vim b/ale_linters/rst/rstcheck.vim
index 39e11d6e..e0cf0798 100644
--- a/ale_linters/rst/rstcheck.vim
+++ b/ale_linters/rst/rstcheck.vim
@@ -1,6 +1,5 @@
" Author: John Nduli https://github.com/jnduli
" Description: Rstcheck for reStructuredText files
-"
function! ale_linters#rst#rstcheck#Handle(buffer, lines) abort
" matches: 'bad_rst.rst:1: (SEVERE/4) Title overline & underline
@@ -22,17 +21,11 @@ function! ale_linters#rst#rstcheck#Handle(buffer, lines) abort
return l:output
endfunction
-function! ale_linters#rst#rstcheck#GetCommand(buffer) abort
- return ale#path#BufferCdString(a:buffer)
- \ . 'rstcheck'
- \ . ' %t'
-endfunction
-
-
call ale#linter#Define('rst', {
\ 'name': 'rstcheck',
\ 'executable': 'rstcheck',
-\ 'command': function('ale_linters#rst#rstcheck#GetCommand'),
+\ 'cwd': '%s:h',
+\ 'command': 'rstcheck %t',
\ 'callback': 'ale_linters#rst#rstcheck#Handle',
\ 'output_stream': 'both',
\})
diff --git a/ale_linters/ruby/ruby.vim b/ale_linters/ruby/ruby.vim
index 621fcbc0..2dc55eb0 100644
--- a/ale_linters/ruby/ruby.vim
+++ b/ale_linters/ruby/ruby.vim
@@ -6,7 +6,7 @@ call ale#Set('ruby_ruby_executable', 'ruby')
call ale#linter#Define('ruby', {
\ 'name': 'ruby',
\ 'executable': {b -> ale#Var(b, 'ruby_ruby_executable')},
-\ 'command': '%e -w -c %t',
+\ 'command': '%e -w -c -T1 %t',
\ 'output_stream': 'stderr',
\ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors',
\})
diff --git a/ale_linters/rust/cargo.vim b/ale_linters/rust/cargo.vim
index 3407abed..37fd10a8 100644
--- a/ale_linters/rust/cargo.vim
+++ b/ale_linters/rust/cargo.vim
@@ -23,6 +23,19 @@ function! ale_linters#rust#cargo#GetCargoExecutable(bufnr) abort
endif
endfunction
+function! ale_linters#rust#cargo#GetCwd(buffer) abort
+ if ale#Var(a:buffer, 'rust_cargo_avoid_whole_workspace')
+ let l:nearest_cargo = ale#path#FindNearestFile(a:buffer, 'Cargo.toml')
+ let l:nearest_cargo_dir = fnamemodify(l:nearest_cargo, ':h')
+
+ if l:nearest_cargo_dir isnot# '.'
+ return l:nearest_cargo_dir
+ endif
+ endif
+
+ return ''
+endfunction
+
function! ale_linters#rust#cargo#GetCommand(buffer, version) abort
let l:use_check = ale#Var(a:buffer, 'rust_cargo_use_check')
\ && ale#semver#GTE(a:version, [0, 17, 0])
@@ -42,18 +55,6 @@ function! ale_linters#rust#cargo#GetCommand(buffer, version) abort
let l:include_features = ' --features ' . ale#Escape(l:include_features)
endif
- let l:avoid_whole_workspace = ale#Var(a:buffer, 'rust_cargo_avoid_whole_workspace')
- let l:nearest_cargo_prefix = ''
-
- if l:avoid_whole_workspace
- let l:nearest_cargo = ale#path#FindNearestFile(a:buffer, 'Cargo.toml')
- let l:nearest_cargo_dir = fnamemodify(l:nearest_cargo, ':h')
-
- if l:nearest_cargo_dir isnot# '.'
- let l:nearest_cargo_prefix = 'cd '. ale#Escape(l:nearest_cargo_dir) .' && '
- endif
- endif
-
let l:default_feature_behavior = ale#Var(a:buffer, 'rust_cargo_default_feature_behavior')
if l:default_feature_behavior is# 'all'
@@ -81,7 +82,7 @@ function! ale_linters#rust#cargo#GetCommand(buffer, version) abort
endif
endif
- return l:nearest_cargo_prefix . 'cargo '
+ return 'cargo '
\ . l:subcommand
\ . (l:use_all_targets ? ' --all-targets' : '')
\ . (l:use_examples ? ' --examples' : '')
@@ -96,6 +97,7 @@ endfunction
call ale#linter#Define('rust', {
\ 'name': 'cargo',
\ 'executable': function('ale_linters#rust#cargo#GetCargoExecutable'),
+\ 'cwd': function('ale_linters#rust#cargo#GetCwd'),
\ 'command': {buffer -> ale#semver#RunWithVersionCheck(
\ buffer,
\ ale_linters#rust#cargo#GetCargoExecutable(buffer),
diff --git a/ale_linters/typescript/eslint.vim b/ale_linters/typescript/eslint.vim
index 33a21440..eaeac307 100644
--- a/ale_linters/typescript/eslint.vim
+++ b/ale_linters/typescript/eslint.vim
@@ -4,6 +4,7 @@
call ale#linter#Define('typescript', {
\ 'name': 'eslint',
\ 'executable': function('ale#handlers#eslint#GetExecutable'),
+\ 'cwd': function('ale#handlers#eslint#GetCwd'),
\ 'command': function('ale#handlers#eslint#GetCommand'),
\ 'callback': 'ale#handlers#eslint#HandleJSON',
\})
diff --git a/ale_linters/typescript/tslint.vim b/ale_linters/typescript/tslint.vim
index f70c2e45..886a3cd4 100644
--- a/ale_linters/typescript/tslint.vim
+++ b/ale_linters/typescript/tslint.vim
@@ -59,8 +59,7 @@ function! ale_linters#typescript#tslint#GetCommand(buffer) abort
\ ? ' -r ' . ale#Escape(l:tslint_rules_dir)
\ : ''
- return ale#path#BufferCdString(a:buffer)
- \ . ale#Escape(ale#handlers#tslint#GetExecutable(a:buffer))
+ return ale#Escape(ale#handlers#tslint#GetExecutable(a:buffer))
\ . ' --format json'
\ . l:tslint_config_option
\ . l:tslint_rules_option
@@ -70,6 +69,7 @@ endfunction
call ale#linter#Define('typescript', {
\ 'name': 'tslint',
\ 'executable': function('ale#handlers#tslint#GetExecutable'),
+\ 'cwd': '%s:h',
\ 'command': function('ale_linters#typescript#tslint#GetCommand'),
\ 'callback': 'ale_linters#typescript#tslint#Handle',
\})
diff --git a/ale_linters/vim/ale_custom_linting_rules.vim b/ale_linters/vim/ale_custom_linting_rules.vim
index 822eb30a..5ca2f149 100644
--- a/ale_linters/vim/ale_custom_linting_rules.vim
+++ b/ale_linters/vim/ale_custom_linting_rules.vim
@@ -22,16 +22,20 @@ function! s:GetALEProjectDir(buffer) abort
return ale#path#Dirname(ale#path#Dirname(ale#path#Dirname(l:executable)))
endfunction
-function! ale_linters#vim#ale_custom_linting_rules#GetCommand(buffer) abort
- let l:dir = s:GetALEProjectDir(a:buffer)
+function! ale_linters#vim#ale_custom_linting_rules#GetCwd(buffer) abort
+ let l:executable = ale_linters#vim#ale_custom_linting_rules#GetExecutable(a:buffer)
+ return ale#path#Dirname(ale#path#Dirname(ale#path#Dirname(l:executable)))
+endfunction
+
+function! ale_linters#vim#ale_custom_linting_rules#GetCommand(buffer) abort
let l:temp_dir = ale#command#CreateDirectory(a:buffer)
let l:temp_file = l:temp_dir . '/example.vim'
let l:lines = getbufline(a:buffer, 1, '$')
call ale#util#Writefile(a:buffer, l:lines, l:temp_file)
- return ale#path#CdString(l:dir) . '%e ' . ale#Escape(l:temp_dir)
+ return '%e ' . ale#Escape(l:temp_dir)
endfunction
function! ale_linters#vim#ale_custom_linting_rules#Handle(buffer, lines) abort
@@ -59,6 +63,7 @@ endfunction
call ale#linter#Define('vim', {
\ 'name': 'ale_custom_linting_rules',
\ 'executable': function('ale_linters#vim#ale_custom_linting_rules#GetExecutable'),
+\ 'cwd': function('ale_linters#vim#ale_custom_linting_rules#GetCwd'),
\ 'command': function('ale_linters#vim#ale_custom_linting_rules#GetCommand'),
\ 'callback': 'ale_linters#vim#ale_custom_linting_rules#Handle',
\ 'read_buffer': 0,