Merge pull request #1025 from kfox/add-rustfmt-fixer

add rustfmt fixer
This commit is contained in:
w0rp
2017-10-24 22:20:03 +01:00
committed by GitHub
7 changed files with 76 additions and 2 deletions

View File

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

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