From 2cf5fce51339507ba8e256dc7202defbf0f03473 Mon Sep 17 00:00:00 2001 From: Justice Nyaga Date: Sat, 3 May 2025 23:44:41 +0300 Subject: [PATCH] fix: add dependencies on windows --- lua/pubspec-assist.lua | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) 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)