local function format_options(bufnr) local oxfmt = vim.lsp.get_clients({ bufnr = bufnr, name = "oxfmt", method = "textDocument/formatting", })[1] return { lsp_format = "fallback", name = oxfmt and "oxfmt" or nil, } end require("lz.n").load({ { "conform.nvim", event = "BufWritePre", cmd = "ConformInfo", keys = { { "f", function() local options = format_options(vim.api.nvim_get_current_buf()) options.async = true require("conform").format(options) end, mode = "", desc = "[F]ormat buffer", }, }, after = function() require("conform").setup({ notify_on_error = true, format_on_save = function(bufnr) local disable_filetypes = { c = true, cpp = true } if disable_filetypes[vim.bo[bufnr].filetype] then return nil else local options = format_options(bufnr) options.timeout_ms = 500 return options end end, formatters_by_ft = { lua = { "stylua" }, python = { "ruff_fix", "ruff_format", "ruff_organize_imports" }, toml = { "taplo" }, yaml = { "yamlfmt" }, }, formatters = { stylua = { prepend_args = { "--indent-type", "Spaces", "--indent-width", "2" }, }, }, }) end, }, })