mirror of
https://github.com/dense-analysis/ale
synced 2024-12-24 15:13:02 +00:00
commit
c248885e57
@ -128,7 +128,7 @@ formatting.
|
||||
| reStructuredText | [proselint](http://proselint.com/) |
|
||||
| RPM spec | [rpmlint](https://github.com/rpm-software-management/rpmlint) (disabled by default; see `:help ale-integration-spec`) |
|
||||
| Ruby | [brakeman](http://brakemanscanner.org/) !!, [rails_best_practices](https://github.com/flyerhzm/rails_best_practices) !!, [reek](https://github.com/troessner/reek), [rubocop](https://github.com/bbatsov/rubocop), [ruby](https://www.ruby-lang.org) |
|
||||
| Rust | cargo !! (see `:help ale-integration-rust` for configuration instructions), [rls](https://github.com/rust-lang-nursery/rls), [rustc](https://www.rust-lang.org/) |
|
||||
| Rust | cargo !! (see `:help ale-integration-rust` for configuration instructions), [rls](https://github.com/rust-lang-nursery/rls), [rustc](https://www.rust-lang.org/), [rustfmt](https://github.com/rust-lang-nursery/rustfmt) |
|
||||
| SASS | [sass-lint](https://www.npmjs.com/package/sass-lint), [stylelint](https://github.com/stylelint/stylelint) |
|
||||
| SCSS | [sass-lint](https://www.npmjs.com/package/sass-lint), [scss-lint](https://github.com/brigade/scss-lint), [stylelint](https://github.com/stylelint/stylelint), [prettier](https://github.com/prettier/prettier) |
|
||||
| Scala | [scalac](http://scala-lang.org), [scalastyle](http://www.scalastyle.org) |
|
||||
|
@ -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.
|
||||
|
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
|
@ -22,6 +22,8 @@ Integration Information
|
||||
over cargo. rls implements the Language Server Protocol for incremental
|
||||
compilation of Rust code, and can check Rust files while you type. `rls`
|
||||
requires Rust files to contained in Cargo projects.
|
||||
4. rustfmt -- If you have `rustfmt` installed, you can use it as a fixer to
|
||||
consistently reformat your Rust code.
|
||||
|
||||
Only cargo is enabled by default. To switch to using rustc instead of cargo,
|
||||
configure |g:ale_linters| appropriately: >
|
||||
@ -70,5 +72,16 @@ g:ale_rust_ignore_error_codes *g:ale_rust_ignore_error_codes*
|
||||
let g:ale_rust_ignore_error_codes = ['E0432', 'E0433']
|
||||
|
||||
|
||||
===============================================================================
|
||||
rustfmt *ale-rust-rustfmt*
|
||||
|
||||
g:ale_rust_rustfmt_options *g:ale_rust_rustfmt_options*
|
||||
*b:ale_rust_rustfmt_options*
|
||||
Type: |String|
|
||||
Default: `''`
|
||||
|
||||
This variable can be set to pass additional options to the rustfmt fixer.
|
||||
|
||||
|
||||
===============================================================================
|
||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||
|
@ -144,6 +144,7 @@ CONTENTS *ale-contents*
|
||||
cargo...............................|ale-rust-cargo|
|
||||
rls.................................|ale-rust-rls|
|
||||
rustc...............................|ale-rust-rustc|
|
||||
rustfmt.............................|ale-rust-rustfmt|
|
||||
sass..................................|ale-sass-options|
|
||||
stylelint...........................|ale-sass-stylelint|
|
||||
scala.................................|ale-scala-options|
|
||||
@ -282,7 +283,7 @@ Notes:
|
||||
* reStructuredText: `proselint`
|
||||
* RPM spec: `rpmlint`
|
||||
* Ruby: `brakeman`, `rails_best_practices`!!, `reek`, `rubocop`, `ruby`
|
||||
* Rust: `cargo`!!, `rls`, `rustc` (see |ale-integration-rust|)
|
||||
* Rust: `cargo`!!, `rls`, `rustc` (see |ale-integration-rust|), `rustfmt`
|
||||
* SASS: `sass-lint`, `stylelint`
|
||||
* SCSS: `sass-lint`, `scss-lint`, `stylelint`, `prettier`
|
||||
* Scala: `scalac`, `scalastyle`
|
||||
|
38
test/fixers/test_rustfmt_fixer_callback.vader
Normal file
38
test/fixers/test_rustfmt_fixer_callback.vader
Normal file
@ -0,0 +1,38 @@
|
||||
Before:
|
||||
Save g:ale_rust_rustfmt_executable
|
||||
Save g:ale_rust_rustfmt_options
|
||||
|
||||
" Use an invalid global executable, so we don't match it.
|
||||
let g:ale_rust_rustfmt_executable = 'xxxinvalid'
|
||||
let g:ale_rust_rustfmt_options = ''
|
||||
|
||||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
call ale#test#RestoreDirectory()
|
||||
|
||||
Execute(The rustfmt callback should return the correct default values):
|
||||
call ale#test#SetFilename('../rust_files/testfile.rs')
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': ale#Escape('xxxinvalid')
|
||||
\ . ' %t',
|
||||
\ },
|
||||
\ ale#fixers#rustfmt#Fix(bufnr(''))
|
||||
|
||||
Execute(The rustfmt callback should include custom rustfmt options):
|
||||
let g:ale_rust_rustfmt_options = "--skip-children"
|
||||
call ale#test#SetFilename('../rust_files/testfile.rs')
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': ale#Escape('xxxinvalid')
|
||||
\ . ' ' . g:ale_rust_rustfmt_options
|
||||
\ . ' %t',
|
||||
\ },
|
||||
\ ale#fixers#rustfmt#Fix(bufnr(''))
|
0
test/rust_files/testfile.rs
Normal file
0
test/rust_files/testfile.rs
Normal file
Loading…
Reference in New Issue
Block a user