Skip to content

Commit

Permalink
fix: use slash commands with :CodeCompanion cmd
Browse files Browse the repository at this point in the history
Users can now do `:CodeCompanion<cr>` and leverage slash commands in the input box
  • Loading branch information
JeanMertz authored Jan 8, 2025
1 parent 2167312 commit 8cbf696
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions lua/codecompanion/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,7 @@ return {
{
cmd = "CodeCompanion",
callback = function(opts)
if #vim.trim(opts.args or "") == 0 then
vim.ui.input({ prompt = config.display.action_palette.prompt }, function(input)
if #vim.trim(input or "") == 0 then
return
end
opts.args = input
codecompanion.inline(opts)
end)
else
local handler = function(opts)
if string.sub(opts.args, 1, 1) == "/" then
local user_prompt = nil
-- Remove the leading slash
Expand Down Expand Up @@ -86,6 +78,18 @@ return {

codecompanion.inline(opts)
end

if #vim.trim(opts.args or "") == 0 then
vim.ui.input({ prompt = config.display.action_palette.prompt }, function(input)
if #vim.trim(input or "") == 0 then
return
end
opts.args = input
handler(opts)
end)
else
handler(opts)
end
end,
opts = {
desc = "Use the CodeCompanion Inline Assistant",
Expand Down

0 comments on commit 8cbf696

Please sign in to comment.