new fixer elixir mix format

(only available in elixir > 1.6)
This commit is contained in:
Carlos Ramos 2017-10-20 17:13:25 -04:00
parent c4579e1809
commit 43653ef548
5 changed files with 43 additions and 0 deletions

View File

@ -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'],

View File

@ -0,0 +1,17 @@
" 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#handlers#elixir#GetExecutable(a:buffer)
\ . ale#fixers#mix_format#GetExecutable(a:buffer)
\ . ' format %t',
\ 'read_temporary_file': 1,
\}
endfunction

View File

@ -0,0 +1,5 @@
call ale#Set('elixir_executable', '')
function! ale#handlers#elixir#GetExecutable(buffer) abort
return ale#Var(a:buffer, 'elixir_executable')
endfunction

View File

View File

@ -0,0 +1,16 @@
Before:
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
call ale#test#RestoreDirectory()
Execute(The executable path should be correct):
call ale#test#SetFilename('../elixir-test-files/testfile.ex')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': 'mix format'
\ . ' %t',
\ },
\ ale#fixers#elixir#Fix(bufnr(''))