feat(conform): format command

This commit is contained in:
Guz
2026-02-14 13:05:04 -03:00
parent c60ec0fe4b
commit e00efd0922
2 changed files with 14 additions and 2 deletions

View File

@@ -11,7 +11,7 @@ local function javascript_formatters(bufnr)
if conform.get_formatter_info("prettierd", bufnr).available then
table.insert(formatters, "prettierd")
elseif require("conform").get_formatter_info("prettier", bufnr).available then
elseif conform.get_formatter_info("prettier", bufnr).available then
table.insert(formatters, "prettier")
end
@@ -81,3 +81,15 @@ conform.setup({
xmltidy = { inherit = false, command = "tidy", args = { "-xml", "-indent", "yes", "2", "-wrap", "100", "-" } }, -- INFO: Uses HTML Tidy
},
})
vim.api.nvim_create_user_command("Format", function(args)
local range = nil
if args.count ~= -1 then
local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1]
range = {
start = { args.line1, 0 },
["end"] = { args.line2, end_line:len() },
}
end
conform.format({ async = true, lsp_format = "fallback", range = range })
end, { range = true })

View File

@@ -40,8 +40,8 @@ lze.load({
after = function()
require("dot.formatting")
end,
cmd = { "ConformInfo", "Format" },
event = { "InsertLeave", "TextChanged" },
on_require = "conform",
},
{
"guess-indent.nvim",