summaryrefslogtreecommitdiff
path: root/lua/bee/format.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/bee/format.lua')
-rw-r--r--lua/bee/format.lua35
1 files changed, 35 insertions, 0 deletions
diff --git a/lua/bee/format.lua b/lua/bee/format.lua
new file mode 100644
index 0000000..c8d1214
--- /dev/null
+++ b/lua/bee/format.lua
@@ -0,0 +1,35 @@
+return {
+ "conform.nvim",
+ auto_enable = true,
+ event = "FileType",
+ keys = {
+ { "<leader>lf", desc = "[F]ormat [F]ile" },
+ },
+ after = function(_)
+ local conform = require("conform")
+ conform.setup({
+ format_on_save = {
+ timeout_ms = 1000,
+ lsp_format = "fallback",
+ quiet = true,
+ },
+ formatters_by_ft = {
+ lua = { "stylua" },
+ nix = { "nixfmt" },
+ c = { "clang_format" },
+ cpp = { "clang_format" },
+ cmake = { "cmake_format" },
+ -- Use a sub-list to run only the first available formatter
+ javascript = { { "prettierd", "prettier" } },
+ },
+ })
+
+ vim.keymap.set({ "n", "v" }, "<leader>lf", function()
+ conform.format({
+ lsp_fallback = true,
+ async = false,
+ timeout_ms = 1000,
+ })
+ end, { desc = "[L]anguage [F]ormat" })
+ end,
+}