refactor(promptLogger): move highlight definition into promptLogger code
Separate managing of a sign (">") placement for the input buffer and
defining a highlight for prompt logger and move the latter into
PromptLogger.init().
This commit is contained in:
@@ -2934,15 +2934,7 @@ function Sidebar:create_input_container()
|
|||||||
local group = "avante_input_prompt_group"
|
local group = "avante_input_prompt_group"
|
||||||
|
|
||||||
fn.sign_unplace(group, { buffer = bufnr })
|
fn.sign_unplace(group, { buffer = bufnr })
|
||||||
|
|
||||||
fn.sign_place(0, group, "AvanteInputPromptSign", bufnr, { lnum = 1 })
|
fn.sign_place(0, group, "AvanteInputPromptSign", bufnr, { lnum = 1 })
|
||||||
vim.api.nvim_set_hl(0, "AvantePromptInputHL", {
|
|
||||||
fg = "#ff7700",
|
|
||||||
bg = "#333333",
|
|
||||||
bold = true,
|
|
||||||
italic = true,
|
|
||||||
underline = true,
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
place_sign_at_first_line(self.containers.input.bufnr)
|
place_sign_at_first_line(self.containers.input.bufnr)
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
local Config = require("avante.config")
|
local Config = require("avante.config")
|
||||||
local Utils = require("avante.utils")
|
local Utils = require("avante.utils")
|
||||||
|
|
||||||
|
local AVANTE_PROMPT_INPUT_HL = "AvantePromptInputHL"
|
||||||
|
|
||||||
-- last one in entries is always to hold current input
|
-- last one in entries is always to hold current input
|
||||||
local entries, idx = {}, 0
|
local entries, idx = {}, 0
|
||||||
local filtered_entries = {}
|
local filtered_entries = {}
|
||||||
@@ -9,6 +11,14 @@ local filtered_entries = {}
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
function M.init()
|
function M.init()
|
||||||
|
vim.api.nvim_set_hl(0, AVANTE_PROMPT_INPUT_HL, {
|
||||||
|
fg = "#ff7700",
|
||||||
|
bg = "#333333",
|
||||||
|
bold = true,
|
||||||
|
italic = true,
|
||||||
|
underline = true,
|
||||||
|
})
|
||||||
|
|
||||||
entries = {}
|
entries = {}
|
||||||
local dir = Config.prompt_logger.log_dir
|
local dir = Config.prompt_logger.log_dir
|
||||||
local log_file = Utils.join_paths(dir, "avante_prompts.log")
|
local log_file = Utils.join_paths(dir, "avante_prompts.log")
|
||||||
@@ -102,7 +112,7 @@ local function update_current_input()
|
|||||||
-- Add the current input as the last entry
|
-- Add the current input as the last entry
|
||||||
table.insert(filtered_entries, entries[#entries])
|
table.insert(filtered_entries, entries[#entries])
|
||||||
|
|
||||||
vim.fn.matchadd("AvantePromptInputHL", user_input)
|
vim.fn.matchadd(AVANTE_PROMPT_INPUT_HL, user_input)
|
||||||
else
|
else
|
||||||
filtered_entries = entries
|
filtered_entries = entries
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user