Merge pull request #1017 from carakan/elixir_format
`mix format` new fixer for elixir lang
This commit is contained in:
commit
0e4dd95e5d
@ -27,6 +27,11 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['javascript', 'typescript'],
|
||||
\ 'description': 'Apply eslint --fix to a file.',
|
||||
\ },
|
||||
\ 'mix_format': {
|
||||
\ 'function': 'ale#fixers#mix_format#Fix',
|
||||
\ 'suggested_filetypes': ['elixir'],
|
||||
\ 'description': 'Apply mix format to a file.',
|
||||
\ },
|
||||
\ 'format': {
|
||||
\ 'function': 'ale#fixers#format#Fix',
|
||||
\ 'suggested_filetypes': ['elm'],
|
||||
|
16
autoload/ale/fixers/mix_format.vim
Normal file
16
autoload/ale/fixers/mix_format.vim
Normal file
@ -0,0 +1,16 @@
|
||||
" Author: carakan <carakan@gmail.com>
|
||||
" Description: Fixing files with elixir formatter 'mix format'.
|
||||
|
||||
call ale#Set('elixir_mix_executable', 'mix')
|
||||
|
||||
function! ale#fixers#mix_format#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'elixir_mix_executable')
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#mix_format#Fix(buffer) abort
|
||||
return {
|
||||
\ 'command': ale#Escape(ale#fixers#mix_format#GetExecutable(a:buffer))
|
||||
\ . ' format %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
17
doc/ale-elixir.txt
Normal file
17
doc/ale-elixir.txt
Normal file
@ -0,0 +1,17 @@
|
||||
===============================================================================
|
||||
ALE Elixir Integration *ale-elixir-options*
|
||||
|
||||
|
||||
===============================================================================
|
||||
mix *ale-elixir-mix*
|
||||
|
||||
g:ale_elixir_mix_options *g:ale_elixir_mix_options*
|
||||
*b:ale_elixir_mix_options*
|
||||
Type: |String|
|
||||
Default: `'mix'`
|
||||
|
||||
|
||||
This variable can be changed to specify the mix executable.
|
||||
|
||||
===============================================================================
|
||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
@ -48,6 +48,8 @@ CONTENTS *ale-contents*
|
||||
dartanalyzer........................|ale-dart-dartanalyzer|
|
||||
dockerfile............................|ale-dockerfile-options|
|
||||
hadolint............................|ale-dockerfile-hadolint|
|
||||
elixir................................|ale-elixir-options|
|
||||
mix.................................|ale-elixir-mix|
|
||||
elm...................................|ale-elm-options|
|
||||
elm-format..........................|ale-elm-elm-format|
|
||||
elm-make............................|ale-elm-elm-make|
|
||||
|
0
test/elixir-test-files/testfile.ex
Normal file
0
test/elixir-test-files/testfile.ex
Normal file
20
test/fixers/test_mix_format_fixer_callback.vader
Normal file
20
test/fixers/test_mix_format_fixer_callback.vader
Normal file
@ -0,0 +1,20 @@
|
||||
Before:
|
||||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||
Save g:ale_elixir_mix_executable
|
||||
|
||||
let g:ale_elixir_mix_executable = 'xxxinvalid'
|
||||
|
||||
After:
|
||||
call ale#test#RestoreDirectory()
|
||||
|
||||
Execute(The mix_format callback should return the correct default values):
|
||||
call ale#test#SetFilename('../elixir-test-files/testfile.ex')
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': ale#Escape('xxxinvalid')
|
||||
\ . ' format %t',
|
||||
\ },
|
||||
\ ale#fixers#mix_format#Fix(bufnr(''))
|
||||
|
Loading…
Reference in New Issue
Block a user