Skip to content

How should I use RustFmt to format my file? #172

Answered by mrcjkb
Catizard asked this question in Q&A
Discussion options

You must be logged in to vote

Hey 👋

I think you've got the wrong plugin. This plugin doesn't define a RustFmt command.
rust.vim does.

To format your file with the LSP client started by this plugin, you can run

:lua vim.lsp.buf.format { async = true }

I'd recommend a keymap:

vim.keymap.set({ 'n', 'v' }, '<space>f', function()
    vim.lsp.buf.format { async = true }
end, desc('[lsp] format buffer'))

which will format the entire buffer in normal mode, or just the visual selection in visual mode.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Catizard
Comment options

@9mm
Comment options

Answer selected by Catizard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants