Skip to content

Commit 61ac567

Browse files
committed
feat: fix command completion
now command candidates match current command query: `:Chat do' --> would autocomplete doc,document,sudo commands Signed-off-by: blob42 <contact@blob42.xyz>
1 parent 8e6a1fa commit 61ac567

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

plugin/codegpt.lua

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ local config = require("codegpt.config")
55
vim.api.nvim_create_user_command("Chat", function(opts)
66
return codegpt.run_cmd(opts)
77
end, {
8+
desc = "Start codegpt chat",
89
range = true,
910
bang = true,
1011
nargs = "*",
11-
complete = function()
12+
complete = function(arglead)
1213
local cmd = {}
1314
for k in pairs(config.opts.commands) do
14-
table.insert(cmd, k)
15+
if k:match(arglead) then
16+
table.insert(cmd, k)
17+
end
1518
end
1619
return cmd
1720
end,
@@ -20,14 +23,16 @@ end, {
2023
vim.api.nvim_create_user_command("VChat", function(opts)
2124
return codegpt.run_cmd(opts)
2225
end, {
23-
desc = "Use vertical popup in popup callbacks",
26+
desc = "Codegpt chat: force use vertical popup",
2427
bang = true,
2528
range = true,
2629
nargs = "*",
27-
complete = function()
30+
complete = function(arglead)
2831
local cmd = {}
2932
for k in pairs(config.opts.commands) do
30-
table.insert(cmd, k)
33+
if k:match(arglead) then
34+
table.insert(cmd, k)
35+
end
3136
end
3237
return cmd
3338
end,

0 commit comments

Comments
 (0)