From ea82962b521a22776f084ffa335ade404ded8a3b Mon Sep 17 00:00:00 2001 From: cppcoffee Date: Sun, 13 Mar 2022 19:50:45 +0800 Subject: [PATCH] feat(rust): add global flag g:rustfmt_edition_opt --- README.md | 3 +++ autoload/neoformat/formatters/rust.vim | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index 3379bea8..8cda9a0e 100644 --- a/README.md +++ b/README.md @@ -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/), diff --git a/autoload/neoformat/formatters/rust.vim b/autoload/neoformat/formatters/rust.vim index 76254231..7377b5cb 100644 --- a/autoload/neoformat/formatters/rust.vim +++ b/autoload/neoformat/formatters/rust.vim @@ -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