Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rust): add global flag g:rustfmt_edition_opt #405

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this require an endif?

Copy link
Author

@cppcoffee cppcoffee Mar 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right, the endif has been added.

return {
\ 'exe': 'rustfmt',
\ 'args': [opts],
\ 'stdin': 1,
\ }
endfunction