mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-09 04:52:29 +08:00
add rustfmt fixer
This commit is contained in:
@@ -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.
|
||||
|
||||
17
autoload/ale/fixers/rustfmt.vim
Normal file
17
autoload/ale/fixers/rustfmt.vim
Normal 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
|
||||
Reference in New Issue
Block a user