summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorw0rp <w0rp@users.noreply.github.com>2017-10-24 22:20:03 +0100
committerGitHub <noreply@github.com>2017-10-24 22:20:03 +0100
commitc248885e5790ce81018ddc8f8afbc3c173051059 (patch)
tree8fb8fcfc71ee025c2785f3fc86dad3b0d59ac43c /autoload
parent0e4dd95e5dac4ef5ac7877b1885f1c8300a53bd3 (diff)
parent35031a0b8a384766277a8b38f84c28ae89a17430 (diff)
downloadale-c248885e5790ce81018ddc8f8afbc3c173051059.zip
Merge pull request #1025 from kfox/add-rustfmt-fixer
add rustfmt fixer
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