Open zyxw59 opened 3 years ago
This isn’t a rust.vim bug but a rustfmt one. I suggest filing a bug against rustfmt to the effect that --edition 2018
should override any value from rustfmt.toml, rather than conflicting with it.
I was then intending to close this WONTFIX since there’s nothing that rust.vim can reasonably do about this, but then I got to wondering why it’s g:rustfmt_options
with no b:rustfmt_options
. Seems reasonable to add that, I think?
The conflict isn't between --edition 2018
and rustfmt.toml
, it's between the --edition 2018
specified in g:rustfmt_options
and the --edition 2018
added here when rustfmt.toml
isn't present.
I have the same issue. Everything works fine when I run rustfmt
from the command line, but when I run it in vim, I get the error mentioned above.
I have the following line in my vimrc, and it fails when a run :RustFmt
in vim in a rust project that doesn't have a rustfmt.toml
file.
let g:rustfmt_options = '--edition=2018'
My fix was to add a global .rustfmt.toml
file in my home directory, as described here: https://rust-lang.github.io/rustfmt/
rust.vim version
vim-plug, current rust.vim commit
87c745d8d506fc1eecc1d81df15d5bde1658a2fc
Steps to reproduce:
Option (A): Specify
--edition 2018
ing:rustfmt_options
in.vimrc
(or equivalent) Option (B): Do not specify--edition 2018
ing:rustfmt_options
in.vimrc
(or equivalent):RustFmt
rustfmt.toml
file which does not specifyedition
:RustFmt
Expected behavior:
At least one of option (A) or (B) works (correctly formats the file at steps 3 and 5)
Actual behavior
Option (A) fails at step 3, with "Option 'edition' given more than once" Option (B) fails at step 5, with "
async fn
is not permitted in the 2015 edition"