add rustfmt fixer

This commit is contained in:
Kelly Fox
2017-10-21 12:31:49 -05:00
parent 3878be9977
commit 35031a0b8a
7 changed files with 76 additions and 2 deletions

View File

@@ -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.

View File

@@ -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