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 -- ╰───────────────────────────╯  none
-- Enable ChatGPT plugin for AI chat -- Enable ChatGPT plugin for AI chat
vim.g.usechatgpt = false ---@type boolean Options: <true|false> 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 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ STATUS COLUMN ━━━━━━━━━━━━━━━━━━━━━━━━━━━━
vim.g.statuscolumn = "native" ---@type string Options: [statuscolumn] 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 -- See: data.types.ibl.char for a list of available characters
-- This option can provide multi-character cycling configurations -- This option can provide multi-character cycling configurations
-- Tab characters -- 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 -- 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 -- Scope characters
vim.g.scope_char_name = "scope" ---@type string Options: [scope char] vim.g.scope_char_name = "scope" ---@type string Options: [scope char]
+8
View File
@@ -25,10 +25,18 @@ M.barsNlines = function()
return false return false
end end
M.avante = function()
return func.check_global_var("useavante", true, false)
end
M.chatgpt = function() M.chatgpt = function()
return func.check_global_var("usechatgpt", true, false) return func.check_global_var("usechatgpt", true, false)
end end
M.gp = function()
return func.check_global_var("usegpai", true, false)
end
--- Codeium conditional options --- Codeium conditional options
M.codeium = function() M.codeium = function()
return func.check_global_var("aitool", "codeium", "neocodeium") return func.check_global_var("aitool", "codeium", "neocodeium")
+6
View File
@@ -6,6 +6,12 @@
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
local M = {} local M = {}
M.avante = {
"stevearc/dressing.nvim",
"nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim",
}
M.chatgpt = { M.chatgpt = {
"MunifTanjim/nui.nvim", "MunifTanjim/nui.nvim",
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
+20 -20
View File
@@ -268,25 +268,24 @@ M.arrow = {
buffer_leader_key = "m", -- Per Buffer Mappings buffer_leader_key = "m", -- Per Buffer Mappings
} }
--- Get the appropriate ordinal suffix for a given number. M.avante = {
--- @param number number The number to check for the ordinal suffix. provider = "openai",
--- @return string The number with its ordinal suffix. auto_suggestions_provider = "openai",
local function get_ordinal_suffix(number) behaviour = {
-- Determine the last two digits to handle 'teen' cases correctly auto_suggestions = false, -- Experimental stage
local suffix = "th" -- Default suffix auto_set_highlight_group = true,
local last_digit = number % 10 auto_set_keymaps = true,
local last_two_digits = number % 100 auto_apply_diff_after_generation = true,
support_paste_from_clipboard = false,
if last_digit == 1 and last_two_digits ~= 11 then },
suffix = "st" hints = { enabled = false },
elseif last_digit == 2 and last_two_digits ~= 12 then highlights = {
suffix = "nd" diff = {
elseif last_digit == 3 and last_two_digits ~= 13 then current = "MiniDiffOverChange",
suffix = "rd" incoming = "MiniDiffOverAdd",
end },
},
return tostring(number) .. suffix }
end
--- Bufferline configuration options --- Bufferline configuration options
M.bufferline = { M.bufferline = {
@@ -312,7 +311,8 @@ M.bufferline = {
themable = true, themable = true,
color_icons = true, color_icons = true,
numbers = function(opts) 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, end,
separator_style = "slant", separator_style = "slant",
auto_toggle_bufferline = true, auto_toggle_bufferline = true,
+10
View File
@@ -41,8 +41,18 @@ return {
}, },
{ -- GP { -- GP
"robitx/gp.nvim", "robitx/gp.nvim",
enabled = data.cond.gp,
lazy = false, lazy = false,
opts = data.types.gp, opts = data.types.gp,
keys = data.keys.gp.func, 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
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 --- Function to set up autocommands
---@return nil ---@return nil
function M.setup_autocommands() function M.setup_autocommands()
@@ -218,6 +242,7 @@ function M.setup_autocommands()
if not vim.tbl_contains(excluded_filetypes, filetype) then if not vim.tbl_contains(excluded_filetypes, filetype) then
M.setup_indent_highlight() M.setup_indent_highlight()
M.setup_minimap_highlight() M.setup_minimap_highlight()
M.setup_avante_highlights()
else else
if pcall(require, "auto-cursorline") then if pcall(require, "auto-cursorline") then
require("auto-cursorline").disable({ require("auto-cursorline").disable({