Files
2026-03-10 18:39:47 +01:00

36 lines
1021 B
Lua

require("funsi")
-- paths to check for project.godot file
local paths_to_check = { '/', '/../' }
local is_godot_project = false
local godot_project_path = ''
local cwd = vim.fn.getcwd()
-- iterate over paths and check
for value in pairs(paths_to_check) do
if vim.uv.fs_stat(cwd .. value .. 'project.godot') then
is_godot_project = true
godot_project_path = cwd .. value
break
end
end
-- check if server is already running in godot project path
local is_server_running = vim.uv.fs_stat(godot_project_path .. '/server.pipe')
-- start server, if not already running
if is_godot_project and not is_server_running then
vim.fn.serverstart(godot_project_path .. '/server.pipe')
end
-- autosave after 1 sec
vim.opt.updatetime = 1000
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
pattern = "*",
callback = function()
if vim.bo.modified and vim.bo.buftype == "" and vim.fn.expand("%") ~= "" then
vim.cmd("silent! write")
end
end,
})