diff --git a/lua/fastvim/configs/conform.lua b/lua/fastvim/configs/conform.lua new file mode 100644 index 0000000..f83d7b4 --- /dev/null +++ b/lua/fastvim/configs/conform.lua @@ -0,0 +1,36 @@ +return { + "stevearc/conform.nvim", + event = { "BufWritePre" }, + cmd = { "ConformInfo" }, + keys = { + { + "f", + function() + require("conform").format { async = true, lsp_format = "fallback" } + end, + mode = "", + desc = "[F]ormat buffer", + }, + }, + opts = { + notify_on_error = false, + format_on_save = function(bufnr) + local disable_filetypes = { c = true, cpp = true } + local lsp_format_opt + if disable_filetypes[vim.bo[bufnr].filetype] then + lsp_format_opt = "never" + else + lsp_format_opt = "fallback" + end + return { + timeout_ms = 500, + lsp_format = lsp_format_opt, + } + end, + formatters_by_ft = { + lua = { "stylua" }, + python = { "isort", "black" }, + javascript = { "prettierd", "prettier", stop_after_first = true }, + }, + }, +} diff --git a/lua/fastvim/plugins/init.lua b/lua/fastvim/plugins/init.lua index e13a892..fba5ad2 100644 --- a/lua/fastvim/plugins/init.lua +++ b/lua/fastvim/plugins/init.lua @@ -10,42 +10,6 @@ return { require "fastvim.configs.neokinds", require "fastvim.configs.treesitter", - { - "stevearc/conform.nvim", - event = { "BufWritePre" }, - cmd = { "ConformInfo" }, - keys = { - { - "f", - function() - require("conform").format({ async = true, lsp_format = "fallback" }) - end, - mode = "", - desc = "[F]ormat buffer", - }, - }, - opts = { - notify_on_error = false, - format_on_save = function(bufnr) - local disable_filetypes = { c = true, cpp = true } - local lsp_format_opt - if disable_filetypes[vim.bo[bufnr].filetype] then - lsp_format_opt = "never" - else - lsp_format_opt = "fallback" - end - return { - timeout_ms = 500, - lsp_format = lsp_format_opt, - } - end, - formatters_by_ft = { - lua = { "stylua" }, - python = { "isort", "black" }, - javascript = { "prettierd", "prettier", stop_after_first = true }, - }, - }, - }, { "folke/todo-comments.nvim", event = "VimEnter",