-- nvim/.config/nvim/after/ftplugin/rust.lua
vim.bo.expandtab = true
vim.bo.tabstop = 4
vim.bo.shiftwidth = 4
vim.bo.softtabstop = 4
vim.bo.textwidth = 100
vim.opt_local.colorcolumn = "100"
-- Clippy on save via rustaceanvim's own command.
vim.api.nvim_buf_create_user_command(0, "Clippy", function()
vim.cmd("!cargo clippy --all-targets --no-deps -- -D warnings")
end, { desc = "cargo clippy" })
vim.api.nvim_buf_create_user_command(0, "CargoTest", function(args)
local cmd = { "cargo", "test" }
if args.args ~= "" then
table.insert(cmd, "--")
table.insert(cmd, args.args)
end
vim.cmd("!" .. table.concat(cmd, " "))
end, { nargs = "?", desc = "cargo test" })
vim.opt_local.formatoptions:remove("o")
vim.opt_local.formatoptions:append("c")