summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/rustfmt.vim17
2 files changed, 22 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 598be6d0..e17521f4 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -112,6 +112,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