local function opts() local util = require("formatter.util") local prettier = { exe = "prettier", args = { "--stdin-filepath", util.escape_path(util.get_current_buffer_file_path()), }, stdin = true, try_node_modules = true, } return { filetype = { lua = { require("formatter.filetypes.lua").stylua, }, rust = { exe = "rustfmt", args = { "--edition 2021" }, stdin = true, }, qml = { exe = "qmlformat", args = { "--inplace" }, }, nix = { require("formatter.filetypes.nix").nixfmt, }, c = { require("formatter.filetypes.c").clangformat, }, cpp = { require("formatter.filetypes.cpp").clangformat, }, r = { require("formatter.filetypes.r").styler, }, python = { require("formatter.filetypes.python").ruff, require("formatter.filetypes.python").isort, }, json = { prettier, }, typescript = { prettier, }, javascript = { prettier, }, yaml = { prettier, }, css = { prettier, }, html = { prettier, }, scss = { prettier, }, fish = { require("formatter.filetypes.fish").fishindent, }, markdown = { require("formatter.filetypes.markdown").prettier, }, toml = { require("formatter.filetypes.toml").taplo, }, sh = { require("formatter.filetypes.sh").shfmt, }, typst = { exe = "typstyle", args = { "--inplace" }, }, ["*"] = { require("formatter.filetypes.any").remove_trailing_whitespace, }, }, } end return { "mhartington/formatter.nvim", config = function() require("formatter").setup(opts()) end, }