Skip to content

Commit f401d9b

Browse files
committed
fix(avante-nvim): use Avante to manage bidnings and lazy load on file open
1 parent 427c63d commit f401d9b

File tree

1 file changed

+16
-41
lines changed
  • lua/astrocommunity/completion/avante-nvim

1 file changed

+16
-41
lines changed

lua/astrocommunity/completion/avante-nvim/init.lua

Lines changed: 16 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
local prefix = "<Leader>A"
12
return {
23
"yetone/avante.nvim",
34
build = vim.fn.has "win32" == 1 and "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false"
45
or "make",
6+
event = "User AstroFile", -- load on file open because Avante manages it's own bindings
57
cmd = {
68
"AvanteAsk",
79
"AvanteBuild",
@@ -16,54 +18,27 @@ return {
1618
"stevearc/dressing.nvim",
1719
"nvim-lua/plenary.nvim",
1820
"MunifTanjim/nui.nvim",
19-
{
20-
"AstroNvim/astrocore",
21-
opts = function(_, opts)
22-
local maps = assert(opts.mappings)
23-
local prefix = "<Leader>A"
24-
25-
maps.n[prefix] = { desc = require("astroui").get_icon("Avante", 1, true) .. "Avante" }
26-
27-
maps.n[prefix .. "<CR>"] = { function() require("avante.api").ask() end, desc = "Avante ask" }
28-
maps.v[prefix .. "<CR>"] = { function() require("avante.api").ask() end, desc = "Avante ask" }
29-
30-
maps.v[prefix .. "r"] = { function() require("avante.api").refresh() end, desc = "Avante refresh" }
31-
32-
maps.n[prefix .. "e"] = { function() require("avante.api").edit() end, desc = "Avante edit" }
33-
maps.v[prefix .. "e"] = { function() require("avante.api").edit() end, desc = "Avante edit" }
34-
end,
35-
},
21+
{ "AstroNvim/astrocore", opts = function(_, opts) opts.mappings.n[prefix] = { desc = " Avante" } end },
3622
},
3723
opts = {
3824
mappings = {
25+
ask = prefix .. "<CR>",
26+
edit = prefix .. "e",
27+
refresh = prefix .. "r",
28+
focus = prefix .. "f",
29+
toggle = {
30+
default = prefix .. "t",
31+
debug = prefix .. "d",
32+
hint = prefix .. "h",
33+
suggestion = prefix .. "s",
34+
repomap = prefix .. "R",
35+
},
3936
diff = {
40-
ours = "co",
41-
theirs = "ct",
42-
all_theirs = "ca",
43-
both = "cb",
44-
cursor = "cc",
4537
next = "]c",
4638
prev = "[c",
4739
},
48-
suggestion = {
49-
accept = "<M-l>",
50-
next = "<M-]>",
51-
prev = "<M-[>",
52-
dismiss = "<C-]>",
53-
},
54-
jump = {
55-
next = "]]",
56-
prev = "[[",
57-
},
58-
submit = {
59-
normal = "<CR>",
60-
insert = "<C-s>",
61-
},
62-
sidebar = {
63-
apply_all = "A",
64-
apply_cursor = "a",
65-
switch_windows = "<Tab>",
66-
reverse_switch_windows = "<S-Tab>",
40+
files = {
41+
add_current = prefix .. ".",
6742
},
6843
},
6944
},

0 commit comments

Comments
 (0)