@@ -30,6 +30,15 @@ local M = {
30
30
-- Module helper functions and variables
31
31
---- ----------------------------------------------------------------------------
32
32
33
+ local agent_completion = function ()
34
+ local buf = vim .api .nvim_get_current_buf ()
35
+ local file_name = vim .api .nvim_buf_get_name (buf )
36
+ if M .not_chat (buf , file_name ) == nil then
37
+ return M ._chat_agents
38
+ end
39
+ return M ._command_agents
40
+ end
41
+
33
42
-- setup function
34
43
M ._setup_called = false
35
44
--- @param opts table | nil # table with options
@@ -175,25 +184,14 @@ M.setup = function(opts)
175
184
ChatPaste = { " popup" , " split" , " vsplit" , " tabnew" },
176
185
ChatToggle = { " popup" , " split" , " vsplit" , " tabnew" },
177
186
Context = { " popup" , " split" , " vsplit" , " tabnew" },
187
+ Agent = agent_completion ,
178
188
}
179
189
180
190
-- register default commands
191
+ M .helpers .create_user_command (M .config .cmd_prefix .. " Do" , M .cmd .Do , do_completion )
181
192
for cmd , _ in pairs (M .cmd ) do
182
193
if M .hooks [cmd ] == nil then
183
- M .helpers .create_user_command (M .config .cmd_prefix .. cmd , M .cmd [cmd ], function ()
184
- if completions [cmd ] then
185
- return completions [cmd ]
186
- end
187
- if cmd == " Agent" then
188
- local buf = vim .api .nvim_get_current_buf ()
189
- local file_name = vim .api .nvim_buf_get_name (buf )
190
- if M .not_chat (buf , file_name ) == nil then
191
- return M ._chat_agents
192
- end
193
- return M ._command_agents
194
- end
195
- return {}
196
- end )
194
+ M .helpers .create_user_command (M .config .cmd_prefix .. cmd , M .cmd [cmd ], completions [cmd ])
197
195
end
198
196
end
199
197
0 commit comments