mirror of
https://github.com/LazyVim/starter.git
synced 2026-07-25 14:01:03 +00:00
integrate ai edit
This commit is contained in:
parent
bfbd02928a
commit
0eb08a8e3a
2 changed files with 63 additions and 0 deletions
|
|
@ -1,3 +1,11 @@
|
||||||
|
-- Define a convenience function for feeding keys
|
||||||
|
local function feed_keys(keys, mode)
|
||||||
|
-- Convert special notation (e.g., <Esc>) to internal key codes
|
||||||
|
local termcodes = vim.api.nvim_replace_termcodes(keys, true, false, true)
|
||||||
|
-- Feed the keys into Neovim
|
||||||
|
vim.api.nvim_feedkeys(termcodes, mode, false)
|
||||||
|
end
|
||||||
|
|
||||||
-- Keymaps are automatically loaded on the VeryLazy event
|
-- Keymaps are automatically loaded on the VeryLazy event
|
||||||
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
|
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
|
||||||
-- Add any additional keymaps here
|
-- Add any additional keymaps here
|
||||||
|
|
@ -56,3 +64,8 @@ vim.keymap.set("n", "<leader>ct", function()
|
||||||
LazyVim.format({ force = true })
|
LazyVim.format({ force = true })
|
||||||
end, 500)
|
end, 500)
|
||||||
end, { desc = "Tidy typescript code" })
|
end, { desc = "Tidy typescript code" })
|
||||||
|
-- AI implementation from comment
|
||||||
|
vim.keymap.set("v", "<leader>ai", function()
|
||||||
|
vim.cmd("AvanteEdit")
|
||||||
|
feed_keys("Do what the first comment says. Do nothing if there is no actionable comment.<C-s>", "i")
|
||||||
|
end, { desc = "AI implement what the comment says" })
|
||||||
|
|
|
||||||
50
lua/plugins/avante.lua
Normal file
50
lua/plugins/avante.lua
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
return {
|
||||||
|
"yetone/avante.nvim",
|
||||||
|
event = "VeryLazy",
|
||||||
|
lazy = false,
|
||||||
|
version = false, -- set this if you want to always pull the latest change
|
||||||
|
opts = {
|
||||||
|
-- add any opts here
|
||||||
|
provider = "openai",
|
||||||
|
openai = {
|
||||||
|
model = "gpt-4o-mini",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
-- 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,
|
||||||
|
"hrsh7th/nvim-cmp", -- autocompletion for avante commands and mentions
|
||||||
|
"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" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue