Skip to content

Commit e9621c3

Browse files
committed
feat: support passing args to FlutterAttach command
1 parent 70430c3 commit e9621c3

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lua/flutter-tools.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ local function setup_commands()
2525
command("FlutterRun", function(data) commands.run_command(data.args) end, { nargs = "*" })
2626
command("FlutterDebug", function(data) commands.run_command(data.args, true) end, { nargs = "*" })
2727
command("FlutterLspRestart", lsp.restart)
28-
command("FlutterAttach", commands.attach)
28+
command("FlutterAttach", function(data) commands.attach(data.args) end, { nargs = "*" })
2929
command("FlutterDetach", commands.detach)
3030
command("FlutterReload", commands.reload)
3131
command("FlutterRestart", commands.restart)

lua/flutter-tools/commands.lua

+4-2
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,8 @@ end
317317
local function attach(opts)
318318
opts = opts or {}
319319
executable.get(function(paths)
320-
local args = opts.cli_args or {}
321-
if not use_debugger_runner() then vim.list_extend(args, { "attach" }) end
320+
local args = opts.cli_args or opts.args or {}
321+
if not use_debugger_runner() then table.insert(args, 1, "attach") end
322322

323323
local cwd = get_cwd()
324324
ui.notify("Attaching flutter project...")
@@ -330,6 +330,8 @@ end
330330
--- Attach to a running app
331331
---@param opts AttachOpts
332332
function M.attach(opts)
333+
if type(opts) == "string" then opts = { args = opts ~= "" and vim.split(opts, " ") or {} } end
334+
opts = opts or {}
333335
if M.is_running() then return ui.notify("Flutter is already running!") end
334336
attach(opts)
335337
end

0 commit comments

Comments
 (0)