From 32c47943d312217fba0a3246ff150597e050454d Mon Sep 17 00:00:00 2001 From: dlond Date: Sat, 3 May 2025 01:54:16 +1200 Subject: [PATCH] custom formatting --- lua/custom/plugins/formatting.lua | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 lua/custom/plugins/formatting.lua diff --git a/lua/custom/plugins/formatting.lua b/lua/custom/plugins/formatting.lua new file mode 100644 index 00000000..a053bf9d --- /dev/null +++ b/lua/custom/plugins/formatting.lua @@ -0,0 +1,37 @@ +-- Formatter configuration + +return { + -- ======================================== + -- Formatter Configuration (conform.nvim) + -- ======================================== + { + 'stevearc/conform.nvim', + event = 'BufWritePre', -- Format on save + -- cmd = { 'ConformInfo' }, -- Optional: If you want the command available + -- keys = { ... } -- Optional: Define keys if needed + opts = { + formatters_by_ft = { + lua = { 'stylua' }, + c = { 'clang_format' }, + cpp = { 'clang_format' }, + python = { 'isort', 'black' }, + nix = { 'nixpkgs-fmt' }, -- Add nix formatter + -- Add other filetypes and formatters, e.g.: + -- javascript = { "prettier" }, + -- typescript = { "prettier" }, + -- css = { "prettier" }, + -- html = { "prettier" }, + -- json = { "prettier" }, + -- yaml = { "prettier" }, + -- markdown = { "prettier" }, + -- bash = { "shfmt" }, + }, + -- Configure format_on_save behavior + format_on_save = { + -- I recommend these options, but adjust to your liking + timeout_ms = 500, -- Stop formatting if it takes too long + lsp_fallback = true, -- Fallback to LSP formatting if conform fails + }, + }, + }, +}