feat: add Avante plugin support with configuration options

This commit is contained in:
2024-09-24 14:49:22 -04:00
parent e5b552bab7
commit 1d5e9aeea2
6 changed files with 75 additions and 22 deletions
+6 -2
View File
@@ -68,6 +68,10 @@ vim.g.aitool = "neocodeium" ---@type string Options: [ai tool]
-- ╰───────────────────────────╯  none
-- Enable ChatGPT plugin for AI chat
vim.g.usechatgpt = false ---@type boolean Options: <true|false>
-- Enable Avante plugin for AI chat
vim.g.useavante = true ---@type boolean Options: <true|false>
-- Enable GP plugin for AI chat
vim.g.usegpai = false ---@type boolean Options: <true|false>
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ STATUS COLUMN ━━━━━━━━━━━━━━━━━━━━━━━━━━━━
vim.g.statuscolumn = "native" ---@type string Options: [statuscolumn]
@@ -148,9 +152,9 @@ vim.opt.colorcolumn = "120" ---@type string|table Options: [column]
-- See: data.types.ibl.char for a list of available characters
-- This option can provide multi-character cycling configurations
-- Tab characters
vim.g.tab_char_name = "fancy" ---@type string Options: [tab char]
vim.g.tab_char_name = "none" ---@type string Options: [tab char]
-- Indent characters
vim.g.indent_char_name = "fancy" ---@type string Options: [indent char]
vim.g.indent_char_name = "none" ---@type string Options: [indent char]
-- Scope characters
vim.g.scope_char_name = "scope" ---@type string Options: [scope char]
+8
View File
@@ -25,10 +25,18 @@ M.barsNlines = function()
return false
end
M.avante = function()
return func.check_global_var("useavante", true, false)
end
M.chatgpt = function()
return func.check_global_var("usechatgpt", true, false)
end
M.gp = function()
return func.check_global_var("usegpai", true, false)
end
--- Codeium conditional options
M.codeium = function()
return func.check_global_var("aitool", "codeium", "neocodeium")
+6
View File
@@ -6,6 +6,12 @@
-- ╰─────────────────────────────────────────────────────────╯
local M = {}
M.avante = {
"stevearc/dressing.nvim",
"nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim",
}
M.chatgpt = {
"MunifTanjim/nui.nvim",
"nvim-lua/plenary.nvim",
+20 -20
View File
@@ -268,25 +268,24 @@ M.arrow = {
buffer_leader_key = "m", -- Per Buffer Mappings
}
--- Get the appropriate ordinal suffix for a given number.
--- @param number number The number to check for the ordinal suffix.
--- @return string The number with its ordinal suffix.
local function get_ordinal_suffix(number)
-- Determine the last two digits to handle 'teen' cases correctly
local suffix = "th" -- Default suffix
local last_digit = number % 10
local last_two_digits = number % 100
if last_digit == 1 and last_two_digits ~= 11 then
suffix = "st"
elseif last_digit == 2 and last_two_digits ~= 12 then
suffix = "nd"
elseif last_digit == 3 and last_two_digits ~= 13 then
suffix = "rd"
end
return tostring(number) .. suffix
end
M.avante = {
provider = "openai",
auto_suggestions_provider = "openai",
behaviour = {
auto_suggestions = false, -- Experimental stage
auto_set_highlight_group = true,
auto_set_keymaps = true,
auto_apply_diff_after_generation = true,
support_paste_from_clipboard = false,
},
hints = { enabled = false },
highlights = {
diff = {
current = "MiniDiffOverChange",
incoming = "MiniDiffOverAdd",
},
},
}
--- Bufferline configuration options
M.bufferline = {
@@ -312,7 +311,8 @@ M.bufferline = {
themable = true,
color_icons = true,
numbers = function(opts)
return get_ordinal_suffix(opts.ordinal) .. ":" -- .. " (#" .. opts.id .. ")""
local get_suffix = require("data.func").get_ordinal_suffix
return get_suffix(opts.ordinal) .. ""
end,
separator_style = "slant",
auto_toggle_bufferline = true,
+10
View File
@@ -41,8 +41,18 @@ return {
},
{ -- GP
"robitx/gp.nvim",
enabled = data.cond.gp,
lazy = false,
opts = data.types.gp,
keys = data.keys.gp.func,
},
{ -- Avante
"yetone/avante.nvim",
enabled = data.cond.avante,
event = "VeryLazy",
lazy = false,
opts = data.types.avante,
build = "make",
dependencies = data.deps.avante,
},
}
+25
View File
@@ -199,6 +199,30 @@ function M.setup_transparency()
end
end
function M.setup_avante_highlights()
-- Apply highlights for title
set_hl(0, "AvanteTitle", { link = "lualine_a_command" })
set_hl(0, "AvanteReversedTitle", {
bg = get_bg_color("Normal"),
fg = get_bg_color("lualine_a_command"),
})
-- Apply highlights for subtitle
set_hl(0, "AvanteSubtitle", { link = "lualine_a_replace" })
set_hl(0, "AvanteReversedSubtitle", {
bg = get_bg_color("Normal"),
fg = get_bg_color("lualine_a_replace"),
})
-- Apply highlights for prompt
set_hl(0, "AvanteThirdTitle", { link = "lualine_a_insert" })
set_hl(0, "AvanteReversedThirdTitle", {
bg = get_bg_color("Normal"),
fg = get_bg_color("lualine_a_insert"),
})
-- Apply highlights for hints
set_hl(0, "AvanteInlineHint", { link = "LspDiagnosticsVirtualTextHint" })
set_hl(0, "AvantePopupHint", { link = "DiagnosticVirtualTextHint" })
end
--- Function to set up autocommands
---@return nil
function M.setup_autocommands()
@@ -218,6 +242,7 @@ function M.setup_autocommands()
if not vim.tbl_contains(excluded_filetypes, filetype) then
M.setup_indent_highlight()
M.setup_minimap_highlight()
M.setup_avante_highlights()
else
if pcall(require, "auto-cursorline") then
require("auto-cursorline").disable({