fix(sidebar): cmp appears only once (#629)
This commit is contained in:
parent
5aec0ba48b
commit
a016663cda
@ -27,7 +27,6 @@ local Sidebar = {}
|
|||||||
|
|
||||||
---@class avante.Sidebar
|
---@class avante.Sidebar
|
||||||
---@field id integer
|
---@field id integer
|
||||||
---@field registered_cmp boolean
|
|
||||||
---@field augroup integer
|
---@field augroup integer
|
||||||
---@field code avante.CodeState
|
---@field code avante.CodeState
|
||||||
---@field winids table<string, integer> this table stores the winids of the sidebar components (result, selected_code, input), even though they are destroyed.
|
---@field winids table<string, integer> this table stores the winids of the sidebar components (result, selected_code, input), even though they are destroyed.
|
||||||
@ -39,7 +38,6 @@ local Sidebar = {}
|
|||||||
function Sidebar:new(id)
|
function Sidebar:new(id)
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
id = id,
|
id = id,
|
||||||
registered_cmp = false,
|
|
||||||
code = { bufnr = 0, winid = 0, selection = nil },
|
code = { bufnr = 0, winid = 0, selection = nil },
|
||||||
winids = {
|
winids = {
|
||||||
result = 0,
|
result = 0,
|
||||||
@ -1388,14 +1386,11 @@ function Sidebar:create_input(opts)
|
|||||||
callback = function()
|
callback = function()
|
||||||
local has_cmp, cmp = pcall(require, "cmp")
|
local has_cmp, cmp = pcall(require, "cmp")
|
||||||
if has_cmp then
|
if has_cmp then
|
||||||
if not self.registered_cmp then
|
cmp.register_source("avante_commands", require("cmp_avante.commands").new(self))
|
||||||
self.registered_cmp = true
|
cmp.register_source(
|
||||||
cmp.register_source("avante_commands", require("cmp_avante.commands").new(self))
|
"avante_mentions",
|
||||||
cmp.register_source(
|
require("cmp_avante.mentions").new(Utils.get_mentions(), self.input.bufnr)
|
||||||
"avante_mentions",
|
)
|
||||||
require("cmp_avante.mentions").new(Utils.get_mentions(), self.input.bufnr)
|
|
||||||
)
|
|
||||||
end
|
|
||||||
cmp.setup.buffer({
|
cmp.setup.buffer({
|
||||||
enabled = true,
|
enabled = true,
|
||||||
sources = {
|
sources = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user