feat(api): support native chat mode (#541)
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
@@ -36,16 +36,25 @@ H.commands = function()
|
||||
---@type AskOptions
|
||||
local args = { question = nil, win = {} }
|
||||
local q_parts = {}
|
||||
local q_ask = nil
|
||||
for _, arg in ipairs(opts.fargs) do
|
||||
local value = arg:match("position=(%w+)")
|
||||
if value then
|
||||
local ask = arg:match("ask=(%w+)")
|
||||
if ask ~= nil then
|
||||
q_ask = ask == "true"
|
||||
elseif value then
|
||||
args.win.position = value
|
||||
else
|
||||
table.insert(q_parts, arg)
|
||||
end
|
||||
end
|
||||
args.question = #q_parts > 0 and table.concat(q_parts, " ") or nil
|
||||
require("avante.api").ask(args)
|
||||
require("avante.api").ask(
|
||||
vim.tbl_deep_extend(
|
||||
"force",
|
||||
args,
|
||||
{ ask = q_ask, question = #q_parts > 0 and table.concat(q_parts, " ") or nil }
|
||||
)
|
||||
)
|
||||
end, {
|
||||
desc = "avante: ask AI for code suggestions",
|
||||
nargs = "*",
|
||||
@@ -56,6 +65,7 @@ H.commands = function()
|
||||
---@param x string
|
||||
vim.tbl_map(function(x) return "position=" .. x end, { "left", "right", "top", "bottom" })
|
||||
)
|
||||
vim.list_extend(candidates, vim.tbl_map(function(x) return "ask=" .. x end, { "true", "false" }))
|
||||
return candidates
|
||||
end,
|
||||
})
|
||||
@@ -283,6 +293,8 @@ M.toggle = { api = true }
|
||||
---@param opts? AskOptions
|
||||
M.toggle_sidebar = function(opts)
|
||||
opts = opts or {}
|
||||
if opts.ask == nil then opts.ask = true end
|
||||
|
||||
local sidebar = M.get()
|
||||
if not sidebar then
|
||||
M._init(api.nvim_get_current_tabpage())
|
||||
|
||||
Reference in New Issue
Block a user