neovim refactor

This commit is contained in:
kiri committed 2026-09-04 19:49:42 +02:00
1 parent b12c211a69
commit 883f9d26c2
25 files changed
+1154 -880

No files matched your search

@@ -1,15 +1,22 @@
local function format_options(bufnr)
local oxfmt = vim.lsp.get_clients({
bufnr = bufnr,
name = "oxfmt",
method = "textDocument/formatting",
})[1]
return {
lsp_format = "fallback",
name = oxfmt and "oxfmt" or nil,
}
end
local formatters_by_ft = {
lua = { "stylua" },
nix = { "nixfmt" },
javascript = { "oxfmt" },
javascriptreact = { "oxfmt" },
typescript = { "oxfmt" },
typescriptreact = { "oxfmt" },
json = { "oxfmt" },
jsonc = { "oxfmt" },
css = { "oxfmt" },
html = { "oxfmt" },
svelte = { "oxfmt" },
astro = { lsp_format = "fallback" },
python = { "ruff_fix", "ruff_format" },
rust = { "rustfmt" },
toml = { "taplo" },
yaml = { "yamlfmt" },
typst = { "typstyle" },
}
require("lz.n").load({
{
@@ -18,40 +25,23 @@ require("lz.n").load({
cmd = "ConformInfo",
keys = {
{
"<leader>f",
"<leader>cf",
function()
local options = format_options(vim.api.nvim_get_current_buf())
options.async = true
require("conform").format(options)
require("conform").format({ async = true })
end,
mode = "",
desc = "[F]ormat buffer",
mode = { "n", "x" },
desc = "Format selection or buffer",
},
},
after = function()
require("conform").setup({
notify_on_error = true,
local conform = require("conform")
conform.setup({
formatters_by_ft = formatters_by_ft,
format_on_save = function(bufnr)
local disable_filetypes = { c = true, cpp = true }
if disable_filetypes[vim.bo[bufnr].filetype] then
return nil
else
local options = format_options(bufnr)
options.timeout_ms = 500
return options
if formatters_by_ft[vim.bo[bufnr].filetype] then
return { timeout_ms = 500 }
end
end,
formatters_by_ft = {
lua = { "stylua" },
python = { "ruff_fix", "ruff_format", "ruff_organize_imports" },
toml = { "taplo" },
yaml = { "yamlfmt" },
},
formatters = {
stylua = {
prepend_args = { "--indent-type", "Spaces", "--indent-width", "2" },
},
},
})
end,
},