@@ -15,7 +15,7 @@ local parser = lazy.require("flutter-tools.utils.yaml_parser")
15
15
16
16
local M = {}
17
17
18
- --- @alias RunOpts { cli_args : string[] ?, args : string[] ?, device : Device ?}
18
+ --- @alias RunOpts { cli_args : string[] ?, args : string[] ?, device : Device ?, force_debug : boolean ? }
19
19
20
20
--- @type table ?
21
21
local current_device = nil
@@ -29,11 +29,13 @@ local current_device = nil
29
29
--- @type flutter.Runner ?
30
30
local runner = nil
31
31
32
- local function use_debugger_runner ()
33
- if not config .debugger .enabled then return false end
34
- local dap_ok , _ = pcall (require , " dap" )
35
- if dap_ok then return true end
36
- ui .notify (" debugger runner was request but nvim-dap is not installed!" , ui .ERROR )
32
+ local function use_debugger_runner (force_debug )
33
+ if force_debug or config .debugger .enabled then
34
+ local dap_ok , _ = pcall (require , " dap" )
35
+ if dap_ok then return true end
36
+ ui .notify (" debugger runner was request but nvim-dap is not installed!" , ui .ERROR )
37
+ return false
38
+ end
37
39
return false
38
40
end
39
41
95
97
--- Take arguments from the commandline and pass
96
98
--- them to the run command
97
99
--- @param args string
98
- function M .run_command (args )
100
+ --- @param force_debug boolean true if the command is a debug command
101
+ function M .run_command (args , force_debug )
99
102
args = args and args ~= " " and vim .split (args , " " ) or nil
100
- M .run ({ args = args })
103
+ M .run ({ args = args , force_debug = force_debug })
101
104
end
102
105
103
106
--- @param callback fun ( project_config : flutter.ProjectConfig ?)
@@ -137,7 +140,7 @@ local function get_run_args(opts, conf)
137
140
local dev_url = dev_tools .get_url ()
138
141
local additional_args = conf and conf .additional_args
139
142
140
- if not use_debugger_runner () then vim .list_extend (args , { " run" }) end
143
+ if not use_debugger_runner (opts . force_debug ) then vim .list_extend (args , { " run" }) end
141
144
if not cmd_args and device then vim .list_extend (args , { " -d" , device }) end
142
145
if web_port then vim .list_extend (args , { " --web-port" , web_port }) end
143
146
if cmd_args then vim .list_extend (args , cmd_args ) end
@@ -266,7 +269,7 @@ local function run(opts, project_conf)
266
269
else
267
270
ui .notify (" Starting dart project..." )
268
271
end
269
- runner = use_debugger_runner () and debugger_runner or job_runner
272
+ runner = use_debugger_runner (opts . force_debug ) and debugger_runner or job_runner
270
273
runner :run (paths , args , cwd , on_run_data , on_run_exit , is_flutter_project , project_conf )
271
274
end )
272
275
end
0 commit comments