new fixer elixir mix format
(only available in elixir > 1.6)
This commit is contained in:
parent
c4579e1809
commit
43653ef548
5 changed files with 43 additions and 0 deletions
|
@ -27,6 +27,11 @@ let s:default_registry = {
|
||||||
\ 'suggested_filetypes': ['javascript', 'typescript'],
|
\ 'suggested_filetypes': ['javascript', 'typescript'],
|
||||||
\ 'description': 'Apply eslint --fix to a file.',
|
\ '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': {
|
\ 'format': {
|
||||||
\ 'function': 'ale#fixers#format#Fix',
|
\ 'function': 'ale#fixers#format#Fix',
|
||||||
\ 'suggested_filetypes': ['elm'],
|
\ 'suggested_filetypes': ['elm'],
|
||||||
|
|
17
autoload/ale/fixers/mix_format.vim
Normal file
17
autoload/ale/fixers/mix_format.vim
Normal 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
|
5
autoload/ale/handlers/elixir.vim
Normal file
5
autoload/ale/handlers/elixir.vim
Normal 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
|
0
test/elixir-test-files/testfile.ex
Normal file
0
test/elixir-test-files/testfile.ex
Normal file
16
test/fixers/test_elixir_fixer_callback.vader
Normal file
16
test/fixers/test_elixir_fixer_callback.vader
Normal 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(''))
|
Reference in a new issue