summaryrefslogtreecommitdiff
path: root/ale_linters/elixir
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/elixir
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/elixir')
-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
4 files changed, 8 insertions, 31 deletions
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,