Skip to content

Commit

Permalink
feat(rust): add global flag g:rustfmt_edition_opt
Browse files Browse the repository at this point in the history
  • Loading branch information
cppcoffee committed Mar 13, 2022
1 parent 0d665b0 commit ea82962
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,9 @@ that caused Neoformat to be invoked.
[`rubocop`](https://github.com/bbatsov/rubocop)
- Rust
- [`rustfmt`](https://github.com/rust-lang-nursery/rustfmt)
```vim
let g:rustfmt_edition_opt="2021"
```
- Sass
- [`sass-convert`](http://sass-lang.com/documentation/#executables),
[`stylelint`](https://stylelint.io/),
Expand Down
4 changes: 4 additions & 0 deletions autoload/neoformat/formatters/rust.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ function! neoformat#formatters#rust#enabled() abort
endfunction

function! neoformat#formatters#rust#rustfmt() abort
let opts = get(g:, 'rustfmt_edition_opt', '')
if opts != ''
let opts = '--edition ' . opts
return {
\ 'exe': 'rustfmt',
\ 'args': [opts],
\ 'stdin': 1,
\ }
endfunction

0 comments on commit ea82962

Please sign in to comment.