Skip to content

Commit

Permalink
feat(completion): added avante-nvim plugin (#1184)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

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

Removed because `lazy = false` is added

Co-authored-by: Uzair Aftab <[email protected]>

* Update lua/astrocommunity/completion/avante-nvim/README.md

Co-authored-by: Uzair Aftab <[email protected]>

* adjust plugin loading and its dependency

* re-add cmd define

* remove default icon package config

Co-authored-by: Micah Halter <[email protected]>

* remove optional dependency: copilot provider

Co-authored-by: Micah Halter <[email protected]>

* remove all optional dependencies

* add configuration of optional plugins

---------

Co-authored-by: Uzair Aftab <[email protected]>
Co-authored-by: Micah Halter <[email protected]>
  • Loading branch information
3 people authored Sep 5, 2024
1 parent 19a23e9 commit 331bf6f
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lua/astrocommunity/completion/avante-nvim/README.md
Original file line number Diff line number Diff line change
@@ -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: <https://github.com/yetone/avante.nvim>
101 changes: 101 additions & 0 deletions lua/astrocommunity/completion/avante-nvim/init.lua
Original file line number Diff line number Diff line change
@@ -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 = "<Leader>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<CR>", desc = "Choose ours" }
maps.v.co = { ":AvanteConflictChooseOurs<CR>", desc = "Choose ours" }

maps.n.ct = { ":AvanteConflictChooseTheirs<CR>", desc = "Choose theirs" }
maps.v.ct = { ":AvanteConflictChooseTheirs<CR>", desc = "Choose theirs" }

maps.n.ca = { ":AvanteConflictChooseAllTheirs<CR>", desc = "Choose all theirs" }
maps.v.ca = { ":AvanteConflictChooseAllTheirs<CR>", desc = "Choose all theirs" }

maps.n.c0 = { ":AvanteConflictChooseNone<CR>", desc = "Choose none" }
maps.v.c0 = { ":AvanteConflictChooseNone<CR>", desc = "Choose none" }

maps.n.cb = { ":AvanteConflictChooseBoth<CR>", desc = "Choose both" }
maps.v.cb = { ":AvanteConflictChooseBoth<CR>", desc = "Choose both" }

maps.n.cc = { ":AvanteConflictChooseCursor<CR>", desc = "Choose cursor" }
maps.v.cc = { ":AvanteConflictChooseCursor<CR>", desc = "Choose cursor" }

maps.n["]x"] = { ":AvanteConflictPrevConflict<CR>", desc = "Move to previous conflict" }
maps.v["]x"] = { ":AvanteConflictPrevConflict<CR>", desc = "Move to previous conflict" }

maps.n["[x"] = { ":AvanteConflictNextConflict<CR>", desc = "Move to next conflict" }
maps.x["[x"] = { ":AvanteConflictNextConflict<CR>", 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,
},
},
}

0 comments on commit 331bf6f

Please sign in to comment.