Skip to content

Commit cd755e1

Browse files
committed
Add agent descriptions to autocomplete
Signed-off-by: Tomas Slusny <[email protected]>
1 parent f83f045 commit cd755e1

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

lua/CopilotChat/copilot.lua

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,12 @@ function Copilot:list_models()
851851

852852
local result = vim.tbl_values(version_map)
853853
table.sort(result)
854-
return result
854+
855+
local out = {}
856+
for _, id in ipairs(result) do
857+
out[id] = models[id].name
858+
end
859+
return out
855860
end
856861

857862
--- List available agents
@@ -861,7 +866,12 @@ function Copilot:list_agents()
861866

862867
local result = vim.tbl_keys(agents)
863868
table.sort(result)
864-
return result
869+
870+
local out = {}
871+
for _, id in ipairs(result) do
872+
out[id] = agents[id].description
873+
end
874+
return out
865875
end
866876

867877
--- Generate embeddings for the given inputs

lua/CopilotChat/init.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,11 @@ function M.complete_items(callback)
262262
}
263263
end
264264

265-
for _, agent in ipairs(agents) do
265+
for agent, description in pairs(agents) do
266266
items[#items + 1] = {
267267
word = '@' .. agent,
268268
kind = 'agent',
269-
menu = 'Use the specified agent',
269+
menu = description,
270270
icase = 1,
271271
dup = 0,
272272
empty = 0,
@@ -402,7 +402,7 @@ end
402402
--- Select a Copilot GPT model.
403403
function M.select_model()
404404
async.run(function()
405-
local models = state.copilot:list_models()
405+
local models = vim.tbl_keys(state.copilot:list_models())
406406
models = vim.tbl_map(function(model)
407407
if model == M.config.model then
408408
return model .. ' (selected)'
@@ -426,7 +426,7 @@ end
426426
--- Select a Copilot agent.
427427
function M.select_agent()
428428
async.run(function()
429-
local agents = state.copilot:list_agents()
429+
local agents = vim.tbl_keys(state.copilot:list_agents())
430430
agents = vim.tbl_map(function(agent)
431431
if agent == M.config.agent then
432432
return agent .. ' (selected)'
@@ -507,7 +507,7 @@ function M.ask(prompt, config, source)
507507
updated_prompt = string.gsub(updated_prompt, '#buffers?%s*', '')
508508

509509
async.run(function()
510-
local agents = state.copilot:list_agents()
510+
local agents = vim.tbl_keys(state.copilot:list_agents())
511511
local current_agent = config.agent
512512

513513
for agent in updated_prompt:gmatch('@([%w_-]+)') do

0 commit comments

Comments
 (0)