diff options
-rw-r--r-- | autoload/ale/fixers/mix_format.vim | 13 | ||||
-rw-r--r-- | doc/ale-elixir.txt | 12 | ||||
-rw-r--r-- | doc/ale.txt | 1 | ||||
-rw-r--r-- | test/fixers/test_mix_format_fixer_callback.vader | 14 |
4 files changed, 36 insertions, 4 deletions
diff --git a/autoload/ale/fixers/mix_format.vim b/autoload/ale/fixers/mix_format.vim index 04866408..3847d1b6 100644 --- a/autoload/ale/fixers/mix_format.vim +++ b/autoload/ale/fixers/mix_format.vim @@ -1,16 +1,23 @@ -" Author: carakan <carakan@gmail.com> +" Author: carakan <carakan@gmail.com>, Fernando Mendes <fernando@mendes.codes> " Description: Fixing files with elixir formatter 'mix format'. call ale#Set('elixir_mix_executable', 'mix') +call ale#Set('elixir_mix_format_options', '') function! ale#fixers#mix_format#GetExecutable(buffer) abort return ale#Var(a:buffer, 'elixir_mix_executable') endfunction +function! ale#fixers#mix_format#GetCommand(buffer) abort + let l:executable = ale#Escape(ale#fixers#mix_format#GetExecutable(a:buffer)) + let l:options = ale#Var(a:buffer, 'elixir_mix_format_options') + + return l:executable . ' format ' . l:options . ' %t' +endfunction + function! ale#fixers#mix_format#Fix(buffer) abort return { - \ 'command': ale#Escape(ale#fixers#mix_format#GetExecutable(a:buffer)) - \ . ' format %t', + \ 'command': ale#fixers#mix_format#GetCommand(a:buffer), \ 'read_temporary_file': 1, \} endfunction diff --git a/doc/ale-elixir.txt b/doc/ale-elixir.txt index b7d4922e..ac0ec605 100644 --- a/doc/ale-elixir.txt +++ b/doc/ale-elixir.txt @@ -14,6 +14,18 @@ g:ale_elixir_mix_options *g:ale_elixir_mix_options* This variable can be changed to specify the mix executable. =============================================================================== +mix_format *ale-elixir-mix-format* + +g:ale_elixir_mix_format_options *g:ale_elixir_mix_format_options* + *b:ale_elixir_mix_format_options* + Type: |String| + Default: `''` + + + This variable can be changed to specify the mix options passed to the + mix_format fixer + +=============================================================================== dialyxir *ale-elixir-dialyxir* Dialyzer, a DIscrepancy AnaLYZer for ERlang programs. diff --git a/doc/ale.txt b/doc/ale.txt index 2e98cd71..aa644e63 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -59,6 +59,7 @@ CONTENTS *ale-contents* hadolint............................|ale-dockerfile-hadolint| elixir................................|ale-elixir-options| mix.................................|ale-elixir-mix| + mix_format..........................|ale-elixir-mix-format| dialyxir............................|ale-elixir-dialyxir| elm...................................|ale-elm-options| elm-format..........................|ale-elm-elm-format| diff --git a/test/fixers/test_mix_format_fixer_callback.vader b/test/fixers/test_mix_format_fixer_callback.vader index c6c97c57..7bd7c77b 100644 --- a/test/fixers/test_mix_format_fixer_callback.vader +++ b/test/fixers/test_mix_format_fixer_callback.vader @@ -1,6 +1,7 @@ Before: call ale#test#SetDirectory('/testplugin/test/fixers') Save g:ale_elixir_mix_executable + Save g:ale_elixir_mix_format_options let g:ale_elixir_mix_executable = 'xxxinvalid' @@ -14,7 +15,18 @@ Execute(The mix_format callback should return the correct default values): \ { \ 'read_temporary_file': 1, \ 'command': ale#Escape('xxxinvalid') - \ . ' format %t', + \ . ' format %t', \ }, \ ale#fixers#mix_format#Fix(bufnr('')) +Execute(The mix_format callback should include the correct format options): + let g:ale_elixir_mix_format_options = 'invalid_options' + call ale#test#SetFilename('../elixir-test-files/testfile.ex') + + AssertEqual + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#Escape('xxxinvalid') + \ . ' format invalid_options %t', + \ }, + \ ale#fixers#mix_format#Fix(bufnr('')) |