diff options
author | Benjamin Chausse <benjamin@chausse.xyz> | 2023-10-30 15:48:49 -0400 |
---|---|---|
committer | Benjamin Chausse <benjamin@chausse.xyz> | 2023-10-30 15:48:49 -0400 |
commit | 6707e9c579b0321e833e2841fa5d5e049674bfb0 (patch) | |
tree | 18f1c733dc561813f2e166e55b42faa092335f4d /lua/ben/plugins/formatting.lua | |
parent | cf473c39984ff94b574d9ebf25ad5ff6e63868e0 (diff) |
Moving away from null-ls
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, +} |