2025-09-15 11:55:20 +02:00
|
|
|
local config = require("godotdev").opts
|
2025-09-08 09:06:30 +02:00
|
|
|
|
|
|
|
|
vim.api.nvim_create_autocmd("BufWritePost", {
|
|
|
|
|
pattern = "*.gd",
|
|
|
|
|
callback = function()
|
2025-09-15 11:55:20 +02:00
|
|
|
local exe = config.formatter_cmd or config.formatter
|
|
|
|
|
if vim.fn.executable(exe) ~= 1 then
|
|
|
|
|
vim.notify(exe .. " not found in PATH. Run `:checkhealth godotdev` for more info.", vim.log.levels.WARN)
|
|
|
|
|
return
|
2025-09-08 09:08:48 +02:00
|
|
|
end
|
2025-09-15 11:55:20 +02:00
|
|
|
|
|
|
|
|
if config.formatter == "gdformat" then
|
|
|
|
|
vim.cmd("silent !" .. exe .. " %")
|
|
|
|
|
elseif config.formatter == "gdscript-format" then
|
|
|
|
|
vim.cmd("silent !" .. exe .. " %")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
vim.cmd("checktime")
|
2025-09-08 09:06:30 +02:00
|
|
|
end,
|
|
|
|
|
})
|