format RON files
This commit is contained in:
@ -29,6 +29,18 @@ vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
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 {
|
||||
{
|
||||
"stevearc/conform.nvim",
|
||||
@ -56,6 +68,7 @@ return {
|
||||
-- Use a sub-list to run only the first available formatter
|
||||
javascript = { { "prettierd", "prettier" } },
|
||||
gdscript = { "gdformat" },
|
||||
ron = { "ronfmt" },
|
||||
dashboard = {},
|
||||
-- Use the "*" filetype to run formatters on all filetypes.
|
||||
-- ["*"] = { "codespell" },
|
||||
@ -64,6 +77,11 @@ return {
|
||||
["_"] = { "trim_whitespace" },
|
||||
},
|
||||
formatters = {
|
||||
ronfmt = {
|
||||
command = "ronfmt",
|
||||
args = { "$FILENAME" },
|
||||
stdin = false,
|
||||
},
|
||||
gdformat = {
|
||||
prepend_args = { "-l", "100" },
|
||||
},
|
||||
|
Reference in New Issue
Block a user