diff options
Diffstat (limited to 'lua/ben/plugins/formatting.lua')
-rw-r--r-- | lua/ben/plugins/formatting.lua | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lua/ben/plugins/formatting.lua b/lua/ben/plugins/formatting.lua new file mode 100644 index 0000000..22ddb17 --- /dev/null +++ b/lua/ben/plugins/formatting.lua @@ -0,0 +1,38 @@ +return { + "stevearc/conform.nvim", + event = { "BufReadPre", "BufNewFile" }, + config = function() + local conform = require("conform") + + conform.setup({ + formatters_by_ft = { + javascript = { "prettier" }, + html = { "prettier" }, + css = { "prettier" }, + json = { "prettier" }, + markdown = { "prettier" }, + bib = { "bibtex_tidy" }, + go = { "goimports", "gci", "golines" }, + sh = { "shfmt" }, + tex = { "latexindent" }, + sql = { "sql_formatter" }, + python = { "isort", "black" }, + yaml = { "yamlfix" }, + lua = { "stylua" }, + }, + + format_on_save = { + lsp_fallback = true, + async = false, + timeout_ms = 300, + }, + }) + vim.keymap.set({ "n", "v" }, "<leader>mp", function() + conform.format({ + lsp_fallback = true, + async = false, + timeout_ms = 300, + }) + end, { desc = "Format file or range" }) + end, +} |