Skip to content

Commit

Permalink
feat: add :CodeCompanionChat sub-commands
Browse files Browse the repository at this point in the history
  • Loading branch information
olimorris committed Oct 8, 2024
1 parent 6bd8344 commit 98761d6
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lua/codecompanion/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ local prompt_library = vim
end)
:totable()

local chat_subcommands = vim
.iter(config.adapters)
:filter(function(k, _)
return k ~= "non_llms" and k ~= "opts"
end)
:map(function(k, _)
return k
end)
:totable()

table.insert(chat_subcommands, "Toggle")
table.insert(chat_subcommands, "Add")

---@class CodeCompanionCommandOpts:table
---@field desc string

Expand Down Expand Up @@ -101,6 +114,18 @@ return {
desc = "Open a CodeCompanion chat buffer",
range = true,
nargs = "*",
-- Reference:
-- https://github.com/nvim-neorocks/nvim-best-practices?tab=readme-ov-file#speaking_head-user-commands
complete = function(arg_lead, cmdline, _)
if cmdline:match("^['<,'>]*CodeCompanionChat[!]*%s+%w*$") then
return vim
.iter(chat_subcommands)
:filter(function(key)
return key:find(arg_lead) ~= nil
end)
:totable()
end
end,
},
},
{
Expand Down

1 comment on commit 98761d6

@olimorris
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example:

Image

Please sign in to comment.