From 35031a0b8a384766277a8b38f84c28ae89a17430 Mon Sep 17 00:00:00 2001 From: Kelly Fox Date: Sat, 21 Oct 2017 12:31:49 -0500 Subject: add rustfmt fixer --- autoload/ale/fix/registry.vim | 5 +++++ autoload/ale/fixers/rustfmt.vim | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 autoload/ale/fixers/rustfmt.vim (limited to 'autoload') 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 +" 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 -- cgit v1.2.3