@@ -13,6 +13,7 @@ local lsp = lazy.require("flutter-tools.lsp") ---@module "flutter-tools.lsp"
13
13
local outline = lazy .require (" flutter-tools.outline" ) --- @module " flutter-tools.outline"
14
14
local devices = lazy .require (" flutter-tools.devices" ) --- @module " flutter-tools.devices"
15
15
local utils = lazy .require (" flutter-tools.utils" ) --- @module " flutter-tools.utils"
16
+ local ui = lazy .require (" flutter-tools.ui" ) --- @module " flutter-tools.ui"
16
17
17
18
local api = vim .api
18
19
@@ -55,17 +56,26 @@ local function setup_commands()
55
56
command (" FlutterRename" , function () require (" flutter-tools.lsp.rename" ).rename () end )
56
57
end
57
58
58
- local _setup_started = false
59
+ local _has_started = false
60
+ local _has_setup = false
59
61
60
62
--- Initialise various plugin modules
61
- local function start ()
62
- if not _setup_started then
63
- _setup_started = true
64
- setup_commands ()
65
- if config .debugger .enabled then dap .setup (config ) end
66
- if config .widget_guides .enabled then guides .setup () end
67
- if config .decorations then decorations .apply (config .decorations ) end
63
+ function M .start ()
64
+ if _has_started then return end
65
+
66
+ if not _has_setup then
67
+ ui .notify (
68
+ " Cannot start because the plugin has not been setup yet." ,
69
+ ui .ERROR
70
+ )
71
+ return
68
72
end
73
+
74
+ _has_started = true
75
+ setup_commands ()
76
+ if config .debugger .enabled then dap .setup (config ) end
77
+ if config .widget_guides .enabled then guides .setup () end
78
+ if config .decorations then decorations .apply (config .decorations ) end
69
79
end
70
80
71
81
local AUGROUP = api .nvim_create_augroup (" FlutterToolsGroup" , { clear = true })
@@ -78,7 +88,7 @@ local function setup_autocommands()
78
88
group = AUGROUP ,
79
89
pattern = { " *.dart" , " pubspec.yaml" },
80
90
once = true ,
81
- callback = start ,
91
+ callback = M . start ,
82
92
})
83
93
84
94
if config .lsp .color .enabled then
@@ -120,13 +130,15 @@ end
120
130
121
131
--- @param opts flutter.ProjectConfig
122
132
function M .setup_project (opts )
133
+ _has_setup = true
123
134
config .setup_project (opts )
124
- start ()
135
+ M . start ()
125
136
end
126
137
127
138
--- Entry point for this plugin
128
139
--- @param user_config table
129
140
function M .setup (user_config )
141
+ _has_setup = true
130
142
config .set (user_config )
131
143
setup_autocommands ()
132
144
end
0 commit comments