Skip to content

Commit

Permalink
fix: #12 Get prompt from vim.ui.input() if no args provided to :CodeC…
Browse files Browse the repository at this point in the history
…ompanion
  • Loading branch information
mrjones2014 committed Mar 8, 2024
1 parent fb2d33b commit 1814f90
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion plugin/codecompanion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1814f90

Please sign in to comment.