diff options
author | Kelly Fox <kelly@bumfuddled.com> | 2017-10-21 12:31:49 -0500 |
---|---|---|
committer | Kelly Fox <kelly@bumfuddled.com> | 2017-10-21 12:31:49 -0500 |
commit | 35031a0b8a384766277a8b38f84c28ae89a17430 (patch) | |
tree | 59c467e4ded6afd88076c474ae139ee9d5ef4a62 /autoload | |
parent | 3878be99771d81571789f5595bf082c63ed61755 (diff) | |
download | ale-35031a0b8a384766277a8b38f84c28ae89a17430.zip |
add rustfmt fixer
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/fix/registry.vim | 5 | ||||
-rw-r--r-- | autoload/ale/fixers/rustfmt.vim | 17 |
2 files changed, 22 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index d26c71ab..07daa402 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -107,6 +107,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['typescript'], \ 'description': 'Fix typescript files with tslint --fix.', \ }, +\ 'rustfmt': { +\ 'function': 'ale#fixers#rustfmt#Fix', +\ 'suggested_filetypes': ['rust'], +\ 'description': 'Fix Rust files with Rustfmt.', +\ }, \} " Reset the function registry to the default entries. diff --git a/autoload/ale/fixers/rustfmt.vim b/autoload/ale/fixers/rustfmt.vim new file mode 100644 index 00000000..fb5ac61c --- /dev/null +++ b/autoload/ale/fixers/rustfmt.vim @@ -0,0 +1,17 @@ +" Author: Kelly Fox <kelly@bumfuddled.com> +" Description: Integration of rustfmt with ALE. + +call ale#Set('rust_rustfmt_executable', 'rustfmt') +call ale#Set('rust_rustfmt_options', '') + +function! ale#fixers#rustfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'rust_rustfmt_executable') + let l:options = ale#Var(a:buffer, 'rust_rustfmt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction |