summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHoracio Sanson <hsanson@gmail.com>2021-01-20 08:42:45 +0900
committerGitHub <noreply@github.com>2021-01-20 08:42:45 +0900
commitbfc412a77ba108b1529f48548def8b0ab56e95a1 (patch)
tree3bf23d5189a2abde328b02f84063c6845d43fd59
parent9387ccfbc57f34f9fdc6af85cd0dbddf5ee8c5ae (diff)
parent7e9d4fbfc820ae4198b07b204295fc3acd391209 (diff)
downloadale-bfc412a77ba108b1529f48548def8b0ab56e95a1.zip
Merge pull request #3455 from Thau/feat/credo_config_file
feat: Adds variable to use custom config file with Elixir Credo
-rw-r--r--ale_linters/elixir/credo.vim11
-rw-r--r--doc/ale-elixir.txt7
-rw-r--r--test/command_callback/test_elixir_credo.vader7
3 files changed, 25 insertions, 0 deletions
diff --git a/ale_linters/elixir/credo.vim b/ale_linters/elixir/credo.vim
index 7c298502..892d47b9 100644
--- a/ale_linters/elixir/credo.vim
+++ b/ale_linters/elixir/credo.vim
@@ -45,6 +45,16 @@ function! ale_linters#elixir#credo#GetMode() abort
endif
endfunction
+function! ale_linters#elixir#credo#GetConfigFile() abort
+ let l:config_file = get(g:, 'ale_elixir_credo_config_file', '')
+
+ if empty(l:config_file)
+ return ''
+ endif
+
+ return ' --config-file ' . l:config_file
+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()
@@ -52,6 +62,7 @@ function! ale_linters#elixir#credo#GetCommand(buffer) abort
return ale#path#CdString(l:project_root)
\ . 'mix help credo && '
\ . 'mix credo ' . ale_linters#elixir#credo#GetMode()
+ \ . ale_linters#elixir#credo#GetConfigFile()
\ . ' --format=flycheck --read-from-stdin %s'
endfunction
diff --git a/doc/ale-elixir.txt b/doc/ale-elixir.txt
index de9daacf..a4e5c2c6 100644
--- a/doc/ale-elixir.txt
+++ b/doc/ale-elixir.txt
@@ -85,5 +85,12 @@ g:ale_elixir_credo_strict *g:ale_elixir_credo_strict*
Tells credo to run in strict mode or suggest mode. Set variable to 1 to
enable --strict mode.
+g:ale_elixir_credo_config_file g:ale_elixir_credo_config_file
+
+ Type: String
+ Default: ''
+
+ Tells credo to use a custom configuration file.
+
===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
diff --git a/test/command_callback/test_elixir_credo.vader b/test/command_callback/test_elixir_credo.vader
index 3eb88846..b14444c6 100644
--- a/test/command_callback/test_elixir_credo.vader
+++ b/test/command_callback/test_elixir_credo.vader
@@ -38,3 +38,10 @@ Execute(Builds credo command with suggest mode when set to 0):
AssertLinter 'mix',
\ ale#path#CdString(ale#path#Simplify(g:dir . '/elixir_paths/mix_project'))
\ . 'mix help credo && mix credo suggest --format=flycheck --read-from-stdin %s'
+
+Execute(Builds credo command with a custom config file):
+ let g:ale_elixir_credo_config_file = '/home/user/custom_credo.exs'
+
+ AssertLinter 'mix',
+ \ ale#path#CdString(ale#path#Simplify(g:dir . '/elixir_paths/mix_project'))
+ \ . 'mix help credo && mix credo suggest --config-file /home/user/custom_credo.exs --format=flycheck --read-from-stdin %s'