fix: cmp slash commands disappeared (#869)
This commit is contained in:
@@ -1,16 +1,21 @@
|
||||
local api = vim.api
|
||||
|
||||
---@class commands_source
|
||||
---@field sidebar avante.Sidebar
|
||||
---@field commands AvanteSlashCommand[]
|
||||
---@field bufnr integer
|
||||
local commands_source = {}
|
||||
|
||||
---@param sidebar avante.Sidebar
|
||||
function commands_source.new(sidebar)
|
||||
---@param commands AvanteSlashCommand[]
|
||||
---@param bufnr integer
|
||||
function commands_source.new(commands, bufnr)
|
||||
---@type cmp.Source
|
||||
return setmetatable({
|
||||
sidebar = sidebar,
|
||||
commands = commands,
|
||||
bufnr = bufnr,
|
||||
}, { __index = commands_source })
|
||||
end
|
||||
|
||||
function commands_source:is_available() return vim.bo.filetype == "AvanteInput" end
|
||||
function commands_source:is_available() return api.nvim_get_current_buf() == self.bufnr end
|
||||
|
||||
commands_source.get_position_encoding_kind = function() return "utf-8" end
|
||||
|
||||
@@ -23,9 +28,7 @@ function commands_source:complete(_, callback)
|
||||
|
||||
local items = {}
|
||||
|
||||
local commands = self.sidebar:get_commands()
|
||||
|
||||
for _, command in ipairs(commands) do
|
||||
for _, command in ipairs(self.commands) do
|
||||
table.insert(items, {
|
||||
label = "/" .. command.command,
|
||||
kind = kind,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
local api = vim.api
|
||||
|
||||
---@class mentions_source
|
||||
---@field mentions {description: string, command: AvanteMentions, details: string, shorthelp?: string, callback?: AvanteMentionCallback}[]
|
||||
---@field bufnr integer
|
||||
@@ -13,7 +15,7 @@ function mentions_source.new(mentions, bufnr)
|
||||
}, { __index = mentions_source })
|
||||
end
|
||||
|
||||
function mentions_source:is_available() return vim.api.nvim_get_current_buf() == self.bufnr end
|
||||
function mentions_source:is_available() return api.nvim_get_current_buf() == self.bufnr end
|
||||
|
||||
mentions_source.get_position_encoding_kind = function() return "utf-8" end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user