diff options
| author | brustybee <bee@4d2.org> | 2026-03-09 17:02:03 +0530 |
|---|---|---|
| committer | brustybee <bee@4d2.org> | 2026-03-09 17:02:03 +0530 |
| commit | 972e5f9c68cc433c5fc26adf92cd25b293a3776a (patch) | |
| tree | c5930854787316181d07854048d9627538017ceb /lua/plugins/formatter.lua | |
One shot upload
Diffstat (limited to 'lua/plugins/formatter.lua')
| -rw-r--r-- | lua/plugins/formatter.lua | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/lua/plugins/formatter.lua b/lua/plugins/formatter.lua new file mode 100644 index 0000000..cc600e5 --- /dev/null +++ b/lua/plugins/formatter.lua @@ -0,0 +1,46 @@ +return { + { + "conform.nvim", + event = { "BufReadPre", "BufNewFile" }, + for_cats = "core.general", + after = function() + local conform = require("conform") + + conform.setup({ + format_after_save = { + lsp_format = "fallback", + quiet = true, + }, + + formatters_by_ft = { + lua = { "stylua" }, + go = { "gofmt" }, + rust = { "rustfmt" }, + toml = { "tombi" }, + java = { "google-java-format" }, + cmake = { "cmake_format" }, + typescript = { "prettierd" }, + javascript = { "prettierd" }, + c = { "clang-format" }, + cpp = { "clang-format" }, + python = { "ruff_fix", "ruff_organize_imports", "ruff_format" }, + }, + + formatters = { + ["google-java-format"] = { + prepend_args = { "--aosp" }, + }, + ["clang-format"] = { + prepend_args = { "-style={BasedOnStyle: LLVM, IndentWidth: 4, TabWidth: 4, UseTab: Never}" }, + }, + }, + }) + + vim.keymap.set({ "n", "v" }, "<leader>lf", function() + conform.format({ async = true }) + end, { + desc = "Language format", + }) + end, + }, +} |
