46
46
function M .startup ()
47
47
Util .track ({ start = " startup" })
48
48
49
- -- load plugins from rtp
49
+ local rtp = vim .opt .rtp :get ()
50
+
51
+ -- load plugins from rtp, excluding after
50
52
Util .track ({ start = " rtp plugins" })
51
- for _ , path in ipairs (vim . opt . rtp : get () ) do
53
+ for _ , path in ipairs (rtp ) do
52
54
if not path :find (" after/?$" ) then
53
55
M .source_runtime (path , " plugin" )
54
56
M .ftdetect (path )
55
57
end
56
58
end
57
59
Util .track ()
58
60
61
+ -- load start plugin
59
62
Util .track ({ start = " start" })
60
63
for _ , plugin in pairs (Config .plugins ) do
61
- -- load start plugin
62
64
if plugin .lazy == false then
63
65
M .load (plugin , { start = " start" })
64
66
end
65
67
end
66
68
Util .track ()
67
69
70
+ -- load after files
71
+ Util .track ({ start = " after" })
72
+ -- load after files from plugins
73
+ for _ , plugin in pairs (Config .plugins ) do
74
+ if plugin ._ .loaded then
75
+ M .source_runtime (plugin .dir , " after/plugin" )
76
+ end
77
+ end
78
+ -- load after files from rtp plugins
79
+ for _ , path in ipairs (rtp ) do
80
+ if path :find (" after/?$" ) then
81
+ M .source_runtime (path , " plugin" )
82
+ end
83
+ end
84
+ Util .track ()
85
+
86
+ -- run plugin init
68
87
Util .track ({ start = " init" })
69
88
for _ , plugin in pairs (Config .plugins ) do
70
- -- run plugin init
71
89
if plugin .init then
72
90
Util .track ({ plugin = plugin .name , init = " init" })
73
91
Util .try (plugin .init , " Failed to run `init` for **" .. plugin .name .. " **" )
@@ -76,17 +94,6 @@ function M.startup()
76
94
end
77
95
Util .track ()
78
96
79
- -- load after files
80
- Util .track ({ start = " after" })
81
- for _ , path in ipairs (vim .opt .rtp :get ()) do
82
- if path :find (" after/?$" ) then
83
- M .source_runtime (path , " plugin" )
84
- else
85
- M .source_runtime (path , " after/plugin" )
86
- end
87
- end
88
- Util .track ()
89
-
90
97
M .init_done = true
91
98
Util .track ()
92
99
end
0 commit comments