Closed reubenwong97 closed 2 years ago
RustFmt
is not provided by this plugin, but by https://github.com/rust-lang/rust.vim. To run the lsp style of formatting, see :lua vim.lsp.buf.formatting()
(this will also write to the buffer).
@simrat39 I didn't install rust-lang/rust.vim
, why does the command :RustFmt
available but not executable?
There is an example of using lsp to format the buffer, so you don't need to call RustFmt. See: https://sharksforarms.dev/posts/neovim-rust/#whats-next
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = "*.rs",
callback = function()
vim.lsp.buf.formatting_sync(nil, 200)
end,
group = format_sync_grp,
})
+1 to what @winkee01 said -- I've not downloaded rust.vim (it looks semi-abandoned). rust-tools.nvim is the only rust-specific neovim plugin that I have, but I also have both RustFmt
and RustFmtRange
as command options.
Both of which complain along the lines of:
Error detected while processing function rustfmt#Format[7]..<SNR>65_RunRustfmt:
line 48:
E776: No location list
Doing a quick search of this repo I found the following:
I'm not full conversant in how this plugin works (thank you for it btw!) -- but perhaps some unintended code slipped in?
(There's also specifically (above) mention that The rustfmt option is unstable and only available on a nightly build.
Sounds like a comment for different/unintended code, but I'll just add that I'm using stable neovim (v0.8.1).)
Did you find a solution to this @reubenwong97? i'm getting the same error trying to get format on save to work.
RustFmt
is not provided by this plugin, but by https://github.com/rust-lang/rust.vim. To run the lsp style of formatting, see:lua vim.lsp.buf.formatting()
(this will also write to the buffer).
Hey @Clish254 ,
I am no longer actively using nvim for rust development. But at the time, i followed the solution laid out by @simrat39 and all I had to do was install the rust-lang/rust.vim
plugin and formatting on save worked. Hope this works for you.
RustFmt
is not provided by this plugin, but by https://github.com/rust-lang/rust.vim. To run the lsp style of formatting, see:lua vim.lsp.buf.formatting()
(this will also write to the buffer).Hey @Clish254 ,
I am no longer actively using nvim for rust development. But at the time, i followed the solution laid out by @simrat39 and all I had to do was install the
rust-lang/rust.vim
plugin and formatting on save worked. Hope this works for you.
That worked, thanks!
Hello,
I am getting the following error when using
:RustFmt
.It just prints out my source code while not performing any formatting. Any assistance is greatly appreciated.
For added info, my
init.lua
looks like this, I am using Astronvim: