From 1814f90393b411356fdff530a88bf440d43fd1da Mon Sep 17 00:00:00 2001 From: Mat Date: Fri, 8 Mar 2024 14:32:29 +0000 Subject: [PATCH] fix: #12 Get prompt from vim.ui.input() if no args provided to :CodeCompanion --- plugin/codecompanion.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugin/codecompanion.lua b/plugin/codecompanion.lua index caac4c46..56a84811 100644 --- a/plugin/codecompanion.lua +++ b/plugin/codecompanion.lua @@ -9,7 +9,17 @@ end local codecompanion = require("codecompanion") vim.api.nvim_create_user_command("CodeCompanion", function(opts) - codecompanion.inline(opts) + if #vim.trim(opts.args or "") == 0 then + vim.ui.input({ prompt = "Prompt" }, function(input) + if #vim.trim(input or "") == 0 then + return + end + opts.args = input + codecompanion.inline(opts) + end) + else + codecompanion.inline(opts) + end end, { desc = "Trigger CodeCompanion inline", range = true, nargs = "*" }) vim.api.nvim_create_user_command("CodeCompanionChat", function(opts)