Switch to conform

This commit is contained in:
Jan Hamal Dvořák 2026-02-15 12:43:12 +01:00
parent 2a57c86a77
commit 5fe85e471d
4 changed files with 32 additions and 14 deletions

3
.gitmodules vendored
View file

@ -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

1
bundle/conform Submodule

@ -0,0 +1 @@
Subproject commit c2526f1cde528a66e086ab1668e996d162c75f4f

@ -1 +0,0 @@
Subproject commit 7cc2214a4a2f9772426a21b32bec9d87cd89dfa8

View file

@ -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,
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" },
},
{ pattern = { "*.sql" }, command = "pg_format --spaces=2 --wrap-limit=1000 --no-rcfile" },
{ pattern = { "*.py", "*.pyi" }, command = "ruff check --select I --fix --silent - | ruff format -" }
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")