diff options
| author | Ibrahim Muftee <ibrahim@muftee.net> | 2024-04-11 23:20:57 -0500 |
|---|---|---|
| committer | Ibrahim Muftee <ibrahim@muftee.net> | 2026-07-01 00:23:31 -0400 |
| commit | a99b211b3bec43ebe3cdfa1899cba227d1d569a4 (patch) | |
| tree | a648712a5fa523f04670c32dd8eff6c2138b6669 /dot_config/nvim/lua/plugins/conform.lua | |
Initial commit
Diffstat (limited to 'dot_config/nvim/lua/plugins/conform.lua')
| -rw-r--r-- | dot_config/nvim/lua/plugins/conform.lua | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/dot_config/nvim/lua/plugins/conform.lua b/dot_config/nvim/lua/plugins/conform.lua new file mode 100644 index 0000000..25512bd --- /dev/null +++ b/dot_config/nvim/lua/plugins/conform.lua @@ -0,0 +1,47 @@ +-- 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", "black" }, + + 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, +} |
