diff --git a/vim/lua/formatter_config.lua b/vim/lua/formatter_config.lua index 2a39c97..66f4cbc 100644 --- a/vim/lua/formatter_config.lua +++ b/vim/lua/formatter_config.lua @@ -22,6 +22,14 @@ local goimports = function() } end +local rustfmt = function() + return { + exe = "rustfmt", + args = { "--edition", "2021" }, + stdin = true, + } +end + require("formatter").setup({ log_level = vim.log.levels.INFO, filetype = { @@ -29,6 +37,7 @@ require("formatter").setup({ typescript = { prettier }, typescriptreact = { prettier }, go = { goimports }, + rust = { rustfmt }, -- https://github.com/JohnnyMorganz/StyLua -- cargo install stylua --features lua54 @@ -43,7 +52,7 @@ vim.api.nvim_exec2( [[ augroup FormatAutogroup autocmd! - autocmd BufWritePost *.js,*.ts,*.tsx,*.go,*.lua silent FormatWrite + autocmd BufWritePost *.js,*.ts,*.tsx,*.go,*.lua,*.rs silent FormatWrite augroup END ]], { output = true }