format RON files

This commit is contained in:
Christian Nieves
2025-02-11 12:53:27 -06:00
parent 53fdcbb4dc
commit 4d94c9cad7

View File

@ -29,6 +29,18 @@ vim.api.nvim_create_autocmd("BufWritePre", {
end, end,
}) })
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
require("conform").format({ async = true, lsp_format = "fallback", range = range })
end, { range = true })
return { return {
{ {
"stevearc/conform.nvim", "stevearc/conform.nvim",
@ -56,6 +68,7 @@ return {
-- Use a sub-list to run only the first available formatter -- Use a sub-list to run only the first available formatter
javascript = { { "prettierd", "prettier" } }, javascript = { { "prettierd", "prettier" } },
gdscript = { "gdformat" }, gdscript = { "gdformat" },
ron = { "ronfmt" },
dashboard = {}, dashboard = {},
-- Use the "*" filetype to run formatters on all filetypes. -- Use the "*" filetype to run formatters on all filetypes.
-- ["*"] = { "codespell" }, -- ["*"] = { "codespell" },
@ -64,6 +77,11 @@ return {
["_"] = { "trim_whitespace" }, ["_"] = { "trim_whitespace" },
}, },
formatters = { formatters = {
ronfmt = {
command = "ronfmt",
args = { "$FILENAME" },
stdin = false,
},
gdformat = { gdformat = {
prepend_args = { "-l", "100" }, prepend_args = { "-l", "100" },
}, },