From 0afa74301871904b0f99f57c63d35336beaa2e0a Mon Sep 17 00:00:00 2001 From: mathijs-bakker Date: Mon, 8 Sep 2025 09:06:30 +0200 Subject: [PATCH] Update formatting --- lua/godotdev/{force_spaces.lua => formatting.lua} | 11 +++++++++++ lua/godotdev/setup.lua | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) rename lua/godotdev/{force_spaces.lua => formatting.lua} (60%) diff --git a/lua/godotdev/force_spaces.lua b/lua/godotdev/formatting.lua similarity index 60% rename from lua/godotdev/force_spaces.lua rename to lua/godotdev/formatting.lua index 09d168b..8ea9a80 100644 --- a/lua/godotdev/force_spaces.lua +++ b/lua/godotdev/formatting.lua @@ -10,3 +10,14 @@ vim.api.nvim_create_autocmd("FileType", { vim.bo.smartindent = true end, }) + +-- Autoformat .gd files on save using gdformat +vim.api.nvim_create_autocmd("BufWritePost", { + pattern = "*.gd", + callback = function() + -- Run gdformat on the file + vim.cmd("silent !gdformat %") + -- Reload the buffer to reflect changes + vim.cmd("edit") + end, +}) diff --git a/lua/godotdev/setup.lua b/lua/godotdev/setup.lua index f4e57e7..4d1f3e1 100644 --- a/lua/godotdev/setup.lua +++ b/lua/godotdev/setup.lua @@ -16,7 +16,7 @@ function M.setup(opts) require("godotdev.start_editor_server") require("godotdev.reconnect_lsp") - require("godotdev.force_spaces") + require("godotdev.formatting") require("godotdev.dap").setup({ type = "server",