summaryrefslogtreecommitdiff
path: root/dot_config/nvim/lua/ibrahim/plugins/conform.lua
diff options
context:
space:
mode:
authorIbrahim Muftee <ibrahim@muftee.net>2025-06-24 11:26:15 -0500
committerIbrahim Muftee <ibrahim@muftee.net>2026-07-01 00:23:31 -0400
commit7d759edf68303c7681a6521fbc3675661204cd4f (patch)
treee8466125f1698855375a8db3b5bedaff2a3c5d3f /dot_config/nvim/lua/ibrahim/plugins/conform.lua
parentc5b4ef95882e57fffe50c85442f6086de24e9c83 (diff)
feat(nvim): replace old config with new one
Diffstat (limited to 'dot_config/nvim/lua/ibrahim/plugins/conform.lua')
-rw-r--r--dot_config/nvim/lua/ibrahim/plugins/conform.lua48
1 files changed, 48 insertions, 0 deletions
diff --git a/dot_config/nvim/lua/ibrahim/plugins/conform.lua b/dot_config/nvim/lua/ibrahim/plugins/conform.lua
new file mode 100644
index 0000000..c1b38ab
--- /dev/null
+++ b/dot_config/nvim/lua/ibrahim/plugins/conform.lua
@@ -0,0 +1,48 @@
+-- Use prettierd if it's available or prettier otherwise, but don't
+-- try to run them both.
+local prettier = { { "prettierd", "prettier" } }
+
+return {
+ "stevearc/conform.nvim",
+ event = { "BufReadPre", "BufNewFile" },
+ cmd = { "ConformInfo", "Format" },
+ opts = {
+ formatters = {
+ sqlfluff = {
+ -- By default, SQLFluff uses "ansi" formatting. My projects
+ -- right now use MySQL formatting instead.
+ -- Still looking for a better way to manage this.
+ args = { "fix", "--force", "--dialect=mysql", "-" },
+ },
+ },
+ formatters_by_ft = {
+ lua = { "stylua" },
+
+ -- Ruff LSP handles formatting for Python code
+ -- -- Multiple items in one table will be run sequentially
+ python = { "ruff_format" },
+
+ c = { "clang-format" },
+ css = prettier,
+ html = prettier,
+ javascript = prettier,
+ json = prettier,
+ markdown = prettier,
+ typescript = prettier,
+ yaml = prettier,
+
+ sql = { "sqlfluff" },
+ },
+ },
+ config = function(_, opts)
+ local conform = require("conform")
+ require("conform").setup(opts)
+
+ local function format()
+ conform.format({ async = true, lsp_fallback = true })
+ end
+
+ vim.keymap.set({ "n", "v" }, "<leader>rf", format, { desc = "Reformat" })
+ vim.api.nvim_create_user_command("Format", format, {})
+ end,
+}