From 932a3dabe2b43e7a5bd40c20aca666da4bd26ba6 Mon Sep 17 00:00:00 2001 From: Micah Halter Date: Fri, 13 Dec 2024 09:31:50 -0500 Subject: [PATCH] fix(avante-nvim)!: improve Avante keymaps to not conflict with with changing text (#1288) --- .../completion/avante-nvim/init.lua | 67 ++++++++++++------- 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/lua/astrocommunity/completion/avante-nvim/init.lua b/lua/astrocommunity/completion/avante-nvim/init.lua index e8e0cfa97..a1ee09a24 100644 --- a/lua/astrocommunity/completion/avante-nvim/init.lua +++ b/lua/astrocommunity/completion/avante-nvim/init.lua @@ -1,6 +1,7 @@ return { "yetone/avante.nvim", - build = ":AvanteBuild", + build = vim.fn.has "win32" == 1 and "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" + or "make", cmd = { "AvanteAsk", "AvanteBuild", @@ -19,42 +20,55 @@ return { "AstroNvim/astrocore", opts = function(_, opts) local maps = assert(opts.mappings) - local prefix = "a" + local prefix = "A" - maps.n[prefix] = { desc = "Avante functionalities" } + maps.n[prefix] = { desc = require("astroui").get_icon("Avante", 1, true) .. "Avante" } - maps.n[prefix .. "a"] = { function() require("avante.api").ask() end, desc = "Avante ask" } - maps.v[prefix .. "a"] = { function() require("avante.api").ask() end, desc = "Avante ask" } + maps.n[prefix .. ""] = { function() require("avante.api").ask() end, desc = "Avante ask" } + maps.v[prefix .. ""] = { function() require("avante.api").ask() end, desc = "Avante ask" } maps.v[prefix .. "r"] = { function() require("avante.api").refresh() end, desc = "Avante refresh" } maps.n[prefix .. "e"] = { function() require("avante.api").edit() end, desc = "Avante edit" } maps.v[prefix .. "e"] = { function() require("avante.api").edit() end, desc = "Avante edit" } - - -- the following key bindings do not have an official api implementation - maps.n.co = { "(AvanteConflictOurs)", desc = "Choose ours", expr = true } - maps.v.co = { "(AvanteConflictOurs)", desc = "Choose ours", expr = true } - - maps.n.ct = { "(AvanteConflictTheirs)", desc = "Choose theirs", expr = true } - maps.v.ct = { "(AvanteConflictTheirs)", desc = "Choose theirs", expr = true } - - maps.n.ca = { "(AvanteConflictAllTheirs)", desc = "Choose all theirs", expr = true } - maps.v.ca = { "(AvanteConflictAllTheirs)", desc = "Choose all theirs", expr = true } - - maps.n.cb = { "(AvanteConflictBoth)", desc = "Choose both", expr = true } - maps.v.cb = { "(AvanteConflictBoth)", desc = "Choose both", expr = true } - - maps.n.cc = { "(AvanteConflictCursor)", desc = "Choose cursor", expr = true } - maps.v.cc = { "(AvanteConflictCursor)", desc = "Choose cursor", expr = true } - - maps.n["]x"] = { "(AvanteConflictPrevConflict)", desc = "Move to previous conflict", expr = true } - - maps.n["[x"] = { "(AvanteConflictNextConflict)", desc = "Move to next conflict", expr = true } end, }, }, - opts = {}, + opts = { + mappings = { + diff = { + ours = "co", + theirs = "ct", + all_theirs = "ca", + both = "cb", + cursor = "cc", + next = "]c", + prev = "[c", + }, + suggestion = { + accept = "", + next = "", + prev = "", + dismiss = "", + }, + jump = { + next = "]]", + prev = "[[", + }, + submit = { + normal = "", + insert = "", + }, + sidebar = { + apply_all = "A", + apply_cursor = "a", + switch_windows = "", + reverse_switch_windows = "", + }, + }, + }, specs = { -- configure optional plugins + { "AstroNvim/astroui", opts = { icons = { Avante = "" } } }, { -- if copilot.lua is available, default to copilot provider "zbirenbaum/copilot.lua", optional = true, @@ -63,6 +77,7 @@ return { "yetone/avante.nvim", opts = { provider = "copilot", + auto_suggestions_provider = "copilot", }, }, },