Can't autoformat rust code using rustfmt on neovim

I can't get rustfmt working in neovim on autosave.
I use this line in my init.vim file to autosave content - autocmd TextChanged,TextChangedI * silent write
And I use this line to enable autosave on rustfmt - let g:rustfmt_autosave = 1
What am i missing? Or is there any other way to enable autosave in neovim and getting autoformat on autosave?

Are you using RLS with rust.vim or rust-analyzer?

I am using rust analyzer. Does rust analyzer includes rustfmt?

The setting you found only works with rust.vim in combination with RLS. Rust analyzer has builtin support for formatting. I can't find how to tell neovim to invoke it on save. I did find a vim plugin that can directly run rustfmt on save: https://github.com/Chiel92/vim-autoformat

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.