From e9621c3cd172940c32ea29f5a9b0932071440bf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tautvydas=20S=CC=8Cidlauskas?= Date: Sun, 16 Mar 2025 18:59:47 +0200 Subject: [PATCH] feat: support passing args to FlutterAttach command --- lua/flutter-tools.lua | 2 +- lua/flutter-tools/commands.lua | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lua/flutter-tools.lua b/lua/flutter-tools.lua index 99af475..65a54b0 100644 --- a/lua/flutter-tools.lua +++ b/lua/flutter-tools.lua @@ -25,7 +25,7 @@ local function setup_commands() command("FlutterRun", function(data) commands.run_command(data.args) end, { nargs = "*" }) command("FlutterDebug", function(data) commands.run_command(data.args, true) end, { nargs = "*" }) command("FlutterLspRestart", lsp.restart) - command("FlutterAttach", commands.attach) + command("FlutterAttach", function(data) commands.attach(data.args) end, { nargs = "*" }) command("FlutterDetach", commands.detach) command("FlutterReload", commands.reload) command("FlutterRestart", commands.restart) diff --git a/lua/flutter-tools/commands.lua b/lua/flutter-tools/commands.lua index 82d2105..b3a027c 100644 --- a/lua/flutter-tools/commands.lua +++ b/lua/flutter-tools/commands.lua @@ -317,8 +317,8 @@ end local function attach(opts) opts = opts or {} executable.get(function(paths) - local args = opts.cli_args or {} - if not use_debugger_runner() then vim.list_extend(args, { "attach" }) end + local args = opts.cli_args or opts.args or {} + if not use_debugger_runner() then table.insert(args, 1, "attach") end local cwd = get_cwd() ui.notify("Attaching flutter project...") @@ -330,6 +330,8 @@ end --- Attach to a running app ---@param opts AttachOpts function M.attach(opts) + if type(opts) == "string" then opts = { args = opts ~= "" and vim.split(opts, " ") or {} } end + opts = opts or {} if M.is_running() then return ui.notify("Flutter is already running!") end attach(opts) end