Skip to content

Commit 2405abb

Browse files
committed
nvim: improve startup time
1 parent b02b3c7 commit 2405abb

4 files changed

Lines changed: 24 additions & 24 deletions

File tree

.config/nvim/init.lua

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
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")
62

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 = ""
1511

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
2219

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+
})

.config/nvim/lua/mainframev/plugins/git-conflict.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---@type LazySpec
22
return {
33
"akinsho/git-conflict.nvim",
4-
lazy = false,
4+
event = "BufReadPre",
55
version = "2.1.0",
66
config = function()
77
local present, conflict = pcall(require, "git-conflict")

.config/nvim/lua/mainframev/plugins/rustacean.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ return {
77
-- its a dependency from crates.nvim
88
"nvim-lua/plenary.nvim",
99
},
10-
-- the plugin is already lazy
11-
lazy = false,
10+
ft = "rust",
1211
init = function()
1312
vim.g.rustaceanvim = function()
1413
require("crates").setup({
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---@type LazySpec
22
return {
33
"wakatime/vim-wakatime",
4-
lazy = false,
4+
event = "VeryLazy",
55
}

0 commit comments

Comments
 (0)