diff --git a/.gitmodules b/.gitmodules index caba269..10f11ff 100644 --- a/.gitmodules +++ b/.gitmodules @@ -22,3 +22,6 @@ [submodule "bundle/nvim-lspconfig"] path = bundle/nvim-lspconfig url = https://github.com/neovim/nvim-lspconfig.git +[submodule "bundle/conform"] + path = bundle/conform + url = https://github.com/stevearc/conform.nvim.git diff --git a/bundle/conform b/bundle/conform new file mode 160000 index 0000000..c2526f1 --- /dev/null +++ b/bundle/conform @@ -0,0 +1 @@ +Subproject commit c2526f1cde528a66e086ab1668e996d162c75f4f diff --git a/bundle/nvim-format-buffer b/bundle/nvim-format-buffer deleted file mode 160000 index 7cc2214..0000000 --- a/bundle/nvim-format-buffer +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7cc2214a4a2f9772426a21b32bec9d87cd89dfa8 diff --git a/lua/init.lua b/lua/init.lua index d98a729..a416518 100644 --- a/lua/init.lua +++ b/lua/init.lua @@ -59,22 +59,37 @@ require("nvim-treesitter.configs").setup { } } -require("nvim-format-buffer").setup({ - verbose = false, - format_rules = { - { pattern = { "*.c", "*.h", "*.cpp", "*.hpp" }, command = "clang-format" }, - { pattern = { "*.rs" }, command = "rustfmt" }, - { - pattern = { "*.js", "*.mjs", "*.ts", "*.mts", "*.cjs", "*.tsx", "*.vue", "*.css" }, - command = function() - return "prettier --stdin-filepath " .. vim.api.nvim_buf_get_name(0) - end, - }, - { pattern = { "*.sql" }, command = "pg_format --spaces=2 --wrap-limit=1000 --no-rcfile" }, - { pattern = { "*.py", "*.pyi" }, command = "ruff check --select I --fix --silent - | ruff format -" } +require("conform").setup({ + formatters_by_ft = { + c = { "clang-format" }, + cpp = { "clang-format" }, + rust = { "rustfmt" }, + python = { "ruff_fix", "ruff_format" }, + javascript = { "prettier" }, + typescript = { "prettier" }, + vue = { "prettier" }, + }, + format_on_save = { + timeout_ms = 1000, + lsp_format = "fallback", }, }) +-- require("nvim-format-buffer").setup({ +-- format_rules = { +-- { pattern = { "*.c", "*.h", "*.cpp", "*.hpp" }, command = "clang-format" }, +-- { pattern = { "*.rs" }, command = "rustfmt" }, +-- { +-- pattern = { "*.js", "*.mjs", "*.ts", "*.mts", "*.cjs", "*.tsx", "*.vue", "*.css" }, +-- command = function() +-- return "prettier --stdin-filepath " .. vim.api.nvim_buf_get_name(0) +-- end, +-- }, +-- { pattern = { "*.sql" }, command = "pg_format --spaces=2 --wrap-limit=1000 --no-rcfile" }, +-- { pattern = { "*.py", "*.pyi" }, command = "ruff check --select I --fix --silent - | ruff format -" } +-- }, +-- }) + require("vim.lsp.log").set_format_func(vim.inspect) vim.lsp.set_log_level("error")