From 331bf6f859112dd109442bc70d67ff4f48d0268f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BF=87=E6=9C=9F=E8=96=AF=E6=9D=A1?= Date: Thu, 5 Sep 2024 14:22:34 -0400 Subject: [PATCH] feat(completion): added `avante-nvim` plugin (#1184) * add avante plug and readme * test and add render-markdown.nvim as recommended * fix typo * change to mini.icons * switch to fenced link * remove redundant config * add avante cmds * add keymaps opts that have api impl and documented bindings * add keymaps opts that have cmds * Update lua/astrocommunity/completion/avante-nvim/init.lua To ensure the plugin is loading as expected Co-authored-by: Uzair Aftab <48220549+Uzaaft@users.noreply.github.com> * Update lua/astrocommunity/completion/avante-nvim/init.lua Removed because `lazy = false` is added Co-authored-by: Uzair Aftab <48220549+Uzaaft@users.noreply.github.com> * Update lua/astrocommunity/completion/avante-nvim/README.md Co-authored-by: Uzair Aftab <48220549+Uzaaft@users.noreply.github.com> * adjust plugin loading and its dependency * re-add cmd define * remove default icon package config Co-authored-by: Micah Halter * remove optional dependency: copilot provider Co-authored-by: Micah Halter * remove all optional dependencies * add configuration of optional plugins --------- Co-authored-by: Uzair Aftab <48220549+Uzaaft@users.noreply.github.com> Co-authored-by: Micah Halter --- .../completion/avante-nvim/README.md | 10 ++ .../completion/avante-nvim/init.lua | 101 ++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 lua/astrocommunity/completion/avante-nvim/README.md create mode 100644 lua/astrocommunity/completion/avante-nvim/init.lua diff --git a/lua/astrocommunity/completion/avante-nvim/README.md b/lua/astrocommunity/completion/avante-nvim/README.md new file mode 100644 index 000000000..9d59d4f75 --- /dev/null +++ b/lua/astrocommunity/completion/avante-nvim/README.md @@ -0,0 +1,10 @@ +Avante.nvim is a Neovim plugin that emulates the Cursor AI IDE's functionality. It provides AI-driven code suggestions and allows users to apply these recommendations directly to their source files with minimal effort. + + +> [!IMPORTANT] +> +> `avante.nvim` is currently only compatible with Neovim 0.10.1 or later. + +For more information, please refer to: + +Repository: diff --git a/lua/astrocommunity/completion/avante-nvim/init.lua b/lua/astrocommunity/completion/avante-nvim/init.lua new file mode 100644 index 000000000..10d316614 --- /dev/null +++ b/lua/astrocommunity/completion/avante-nvim/init.lua @@ -0,0 +1,101 @@ +return { + "yetone/avante.nvim", + build = ":AvanteBuild", + cmd = { + "AvanteAsk", + "AvanteBuild", + "AvanteConflictChooseAllTheirs", + "AvanteConflictChooseBase", + "AvanteConflictChooseBoth", + "AvanteConflictChooseCursor", + "AvanteConflictChooseNone", + "AvanteConflictChooseOurs", + "AvanteConflictChooseTheirs", + "AvanteConflictListQf", + "AvanteConflictNextConflict", + "AvanteConflictPrevConflict", + "AvanteEdit", + "AvanteRefresh", + "AvanteSwitchProvider", + }, + dependencies = { + "stevearc/dressing.nvim", + "nvim-lua/plenary.nvim", + "MunifTanjim/nui.nvim", + { + "AstroNvim/astrocore", + opts = function(_, opts) + local maps = assert(opts.mappings) + local prefix = "a" + + maps.n[prefix] = { desc = "Avante functionalities" } + + 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.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 = { ":AvanteConflictChooseOurs", desc = "Choose ours" } + maps.v.co = { ":AvanteConflictChooseOurs", desc = "Choose ours" } + + maps.n.ct = { ":AvanteConflictChooseTheirs", desc = "Choose theirs" } + maps.v.ct = { ":AvanteConflictChooseTheirs", desc = "Choose theirs" } + + maps.n.ca = { ":AvanteConflictChooseAllTheirs", desc = "Choose all theirs" } + maps.v.ca = { ":AvanteConflictChooseAllTheirs", desc = "Choose all theirs" } + + maps.n.c0 = { ":AvanteConflictChooseNone", desc = "Choose none" } + maps.v.c0 = { ":AvanteConflictChooseNone", desc = "Choose none" } + + maps.n.cb = { ":AvanteConflictChooseBoth", desc = "Choose both" } + maps.v.cb = { ":AvanteConflictChooseBoth", desc = "Choose both" } + + maps.n.cc = { ":AvanteConflictChooseCursor", desc = "Choose cursor" } + maps.v.cc = { ":AvanteConflictChooseCursor", desc = "Choose cursor" } + + maps.n["]x"] = { ":AvanteConflictPrevConflict", desc = "Move to previous conflict" } + maps.v["]x"] = { ":AvanteConflictPrevConflict", desc = "Move to previous conflict" } + + maps.n["[x"] = { ":AvanteConflictNextConflict", desc = "Move to next conflict" } + maps.x["[x"] = { ":AvanteConflictNextConflict", desc = "Move to next conflict" } + end, + }, + }, + opts = {}, + specs = { -- configure optional plugins + { -- if copilot.lua is available, default to copilot provider + "zbirenbaum/copilot.lua", + optional = true, + specs = { + { + "yetone/avante.nvim", + opts = { + provider = "copilot", + }, + }, + }, + }, + { + -- make sure `Avante` is added as a filetype + "MeanderingProgrammer/render-markdown.nvim", + optional = true, + opts = function(_, opts) + if not opts.file_types then opts.filetypes = { "markdown" } end + opts.file_types = require("astrocore").list_insert_unique(opts.file_types, { "Avante" }) + end, + }, + { + -- make sure `Avante` is added as a filetype + "OXY2DEV/markview.nvim", + optional = true, + opts = function(_, opts) + if not opts.filetypes then opts.filetypes = { "markdown", "quarto", "rmd" } end + opts.filetypes = require("astrocore").list_insert_unique(opts.filetypes, { "Avante" }) + end, + }, + }, +}