diff --git a/lazy-lock.json b/lazy-lock.json index 57d5dad..9d4a60f 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -8,6 +8,7 @@ "astrolsp": { "branch": "main", "commit": "5d92b868586c4b79298003b307e8dc3e9a357816" }, "astrotheme": { "branch": "main", "commit": "037c3dbd161d6744d274243dd71314b2964753b2" }, "astroui": { "branch": "main", "commit": "7adeb60d76939d3cd66c9852e0e8621bd42014dd" }, + "avante.nvim": { "branch": "main", "commit": "f9520c4fdfed08e9cc609d6cd319b358e4ea33a5" }, "better-escape.nvim": { "branch": "master", "commit": "f45b52f8f87792e8659526f23261ffe278a54be5" }, "catppuccin": { "branch": "main", "commit": "63685e1562ef53873c9764b483d7ac5c7a608922" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, @@ -23,6 +24,7 @@ "harpoon": { "branch": "harpoon2", "commit": "0378a6c428a0bed6a2781d459d7943843f374bce" }, "heirline.nvim": { "branch": "master", "commit": "0d797435e54645a5f98bad7ad6046aac1ef95c1e" }, "image.nvim": { "branch": "master", "commit": "4007cddc4cfc1b5ddd49744a38362e7b0432b3a0" }, + "img-clip.nvim": { "branch": "main", "commit": "28a32d811d69042f4fa5c3d5fa35571df2bc1623" }, "indent-blankline.nvim": { "branch": "master", "commit": "18603eb949eba08300799f64027af11ef922283f" }, "lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" }, "lazydev.nvim": { "branch": "main", "commit": "491452cf1ca6f029e90ad0d0368848fac717c6d2" }, @@ -56,6 +58,7 @@ "plenary.nvim": { "branch": "master", "commit": "ec289423a1693aeae6cd0d503bac2856af74edaa" }, "presence.nvim": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" }, "promise-async": { "branch": "main", "commit": "38a4575da9497326badd3995e768b4ccf0bb153e" }, + "render-markdown.nvim": { "branch": "main", "commit": "06c8d76b20baa7c71b494fa2c2479d5740d9e2d7" }, "resession.nvim": { "branch": "master", "commit": "cc819b0489938d03e4f3532a583354f0287c015b" }, "smart-splits.nvim": { "branch": "master", "commit": "1a2b268a7ec7aeef879cdd15973339010ec134f7" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, diff --git a/lua/plugins/avante.lua b/lua/plugins/avante.lua new file mode 100644 index 0000000..f26e996 --- /dev/null +++ b/lua/plugins/avante.lua @@ -0,0 +1,108 @@ +---@type LazySpec +return { + "yetone/avante.nvim", + event = "VeryLazy", + lazy = false, + version = false, -- set this if you want to always pull the latest change + opts = { + provider = "copilot", + vendors = { + ---@type AvanteProvider + ollama = { + ["local"] = true, + endpoint = "127.0.0.1:11434/v1", + model = "llama3", + parse_curl_args = function(opts, code_opts) + return { + url = opts.endpoint .. "/chat/completions", + headers = { + ["Accept"] = "application/json", + ["Content-Type"] = "application/json", + }, + body = { + model = opts.model, + messages = require("avante.providers").copilot.parse_message(code_opts), -- you can make your own message, but this is very advanced + max_tokens = 2048, + stream = true, + }, + } + end, + parse_response_data = function(data_stream, event_state, opts) + require("avante.providers").openai.parse_response(data_stream, event_state, opts) + end, + }, + }, + mappings = { + ask = "ma", + edit = "me", + refresh = "mr", + }, + keys = function(_, keys) + ---@type avante.Config + local opts = require("lazy.core.plugin").values( + require("lazy.core.config").spec.plugins["avante.nvim"], + "opts", + false + ) + + local mappings = { + { + opts.mappings.ask, + function() require("avante.api").ask() end, + desc = "avante: ask", + mode = { "n", "v" }, + }, + { + opts.mappings.refresh, + function() require("avante.api").refresh() end, + desc = "avante: refresh", + mode = "v", + }, + { + opts.mappings.edit, + function() require("avante.api").edit() end, + desc = "avante: edit", + mode = { "n", "v" }, + }, + } + mappings = vim.tbl_filter(function(m) return m[1] and #m[1] > 0 end, mappings) + return vim.list_extend(mappings, keys) + end, + }, + -- if you want to build from source then do `make BUILD_FROM_SOURCE=true` + build = "make", + -- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows + dependencies = { + "stevearc/dressing.nvim", + "nvim-lua/plenary.nvim", + "MunifTanjim/nui.nvim", + --- The below dependencies are optional, + "nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons + "zbirenbaum/copilot.lua", -- for providers='copilot' + { + -- support for image pasting + "HakonHarnes/img-clip.nvim", + event = "VeryLazy", + opts = { + -- recommended settings + default = { + embed_image_as_base64 = false, + prompt_for_file_name = false, + drag_and_drop = { + insert_mode = true, + }, + -- required for Windows users + use_absolute_path = true, + }, + }, + }, + { + -- Make sure to set this up properly if you have lazy=true + "MeanderingProgrammer/render-markdown.nvim", + opts = { + file_types = { "markdown", "Avante" }, + }, + ft = { "markdown", "Avante" }, + }, + }, +}