|
1 | | --- paths to check for project.godot file |
2 | | -local paths_to_check = { "/", "/../" } |
3 | | -local is_godot_project = false |
4 | | -local godot_project_path = "" |
5 | | -local cwd = vim.fn.getcwd() |
| 1 | +require("mainframev") |
6 | 2 |
|
7 | | --- iterate over paths and check |
8 | | -for key, value in pairs(paths_to_check) do |
9 | | - if vim.uv.fs_stat(cwd .. value .. "project.godot") then |
10 | | - is_godot_project = true |
11 | | - godot_project_path = cwd .. value |
12 | | - break |
13 | | - end |
14 | | -end |
| 3 | +-- defer godot project detection until after startup |
| 4 | +vim.api.nvim_create_autocmd("VimEnter", { |
| 5 | + once = true, |
| 6 | + callback = function() |
| 7 | + local cwd = vim.fn.getcwd() |
| 8 | + local paths_to_check = { "/", "/../" } |
| 9 | + local is_godot_project = false |
| 10 | + local godot_project_path = "" |
15 | 11 |
|
16 | | --- check if server is already running in godot project path |
17 | | -local is_server_running = vim.uv.fs_stat(godot_project_path .. "/server.pipe") |
18 | | --- start server, if not already running |
19 | | -if is_godot_project and not is_server_running then |
20 | | - vim.fn.serverstart(godot_project_path .. "/server.pipe") |
21 | | -end |
| 12 | + for _, value in pairs(paths_to_check) do |
| 13 | + if vim.uv.fs_stat(cwd .. value .. "project.godot") then |
| 14 | + is_godot_project = true |
| 15 | + godot_project_path = cwd .. value |
| 16 | + break |
| 17 | + end |
| 18 | + end |
22 | 19 |
|
23 | | -require("mainframev") |
| 20 | + if is_godot_project and not vim.uv.fs_stat(godot_project_path .. "/server.pipe") then |
| 21 | + vim.fn.serverstart(godot_project_path .. "/server.pipe") |
| 22 | + end |
| 23 | + end, |
| 24 | +}) |
0 commit comments