diff --git a/lua/pubspec-assist.lua b/lua/pubspec-assist.lua index b959eaa..77bc95d 100644 --- a/lua/pubspec-assist.lua +++ b/lua/pubspec-assist.lua @@ -268,10 +268,16 @@ function M.add_package() return end vim.ui.input({ prompt = "Enter dependency name(s) " }, function(input) - add_package_job = job:new({ - command = "flutter", - args = { "pub", "add", input }, - }) + local command = vim.fn.has("win32") == 1 + and { + command = "cmd", + args = { "/C", "flutter", "pub", "add", input }, + } + or { + command = "flutter", + args = { "pub", "add", input }, + } + add_package_job = job:new(command) add_package_job:after_success(vim.schedule_wrap(function(j) vim.notify(join_lines(j:result()), vim.log.levels.INFO) -- reload buffer when add package success @@ -292,10 +298,16 @@ function M.add_dev_package() end vim.ui.input({ prompt = "Enter dependency name(s) " }, function(input) - add_package_job = job:new({ - command = "flutter", - args = { "pub", "add", input, "--dev" }, - }) + local command = vim.fn.has("win32") == 1 + and { + command = "cmd", + args = { "/C", "flutter", "pub", "add", input, "--dev" }, + } + or { + command = "flutter", + args = { "pub", "add", input, "--dev" }, + } + add_package_job = job:new(command) add_package_job:after_success(vim.schedule_wrap(function(j) local message = table.concat(j:result(), "\n") vim.notify(message, vim.log.levels.INFO)