From ee88563215cf08db91a2fad919c6a3e9ee93038f Mon Sep 17 00:00:00 2001 From: yetone Date: Sun, 25 Aug 2024 14:26:42 +0800 Subject: [PATCH] fix: types (#208) --- lua/avante/config.lua | 2 +- lua/avante/providers/init.lua | 1 + lua/avante/sidebar.lua | 8 +++++--- lua/avante/types.lua | 26 ++++++++++++++++++++++++++ 4 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 lua/avante/types.lua diff --git a/lua/avante/config.lua b/lua/avante/config.lua index 6bbd5ef1b..fe11cbd0d 100644 --- a/lua/avante/config.lua +++ b/lua/avante/config.lua @@ -58,7 +58,7 @@ M.defaults = { max_tokens = 4096, ["local"] = false, }, - ---@type AvanteGeminiProvider + ---@type AvanteSupportedProvider cohere = { endpoint = "https://api.cohere.com/v1", model = "command-r-plus", diff --git a/lua/avante/providers/init.lua b/lua/avante/providers/init.lua index c3a9622fe..81b34a329 100644 --- a/lua/avante/providers/init.lua +++ b/lua/avante/providers/init.lua @@ -69,6 +69,7 @@ local Dressing = require("avante.ui.dressing") ---@field setup fun(): nil ---@field has fun(): boolean ---@field api_key_name string +---@field model? string ---@field parse_api_key fun(): string | nil ---@field parse_stream_data? AvanteStreamParser --- diff --git a/lua/avante/sidebar.lua b/lua/avante/sidebar.lua index 2074509e2..95c310826 100644 --- a/lua/avante/sidebar.lua +++ b/lua/avante/sidebar.lua @@ -31,11 +31,11 @@ local Sidebar = {} ---@field augroup integer ---@field code avante.CodeState ---@field winids table this table stores the winids of the sidebar components (result_container, result, selected_code_container, selected_code, input_container, input), even though they are destroyed. ----@field result_container NuiSplit | nil +---@field result_container AvanteComp | nil ---@field result FloatingWindow | nil ----@field selected_code_container NuiSplit | nil +---@field selected_code_container AvanteComp | nil ---@field selected_code FloatingWindow | nil ----@field input_container NuiSplit | nil +---@field input_container AvanteComp | nil ---@field input FloatingWindow | nil ---@param id integer the tabpage id retrieved from api.nvim_get_current_tabpage() @@ -416,7 +416,9 @@ function Sidebar:render_input_container() ---@type string local icon + ---@diagnostic disable-next-line: undefined-field if _G.MiniIcons ~= nil then + ---@diagnostic disable-next-line: undefined-global icon, _, _ = MiniIcons.get("filetype", filetype) else icon = require("nvim-web-devicons").get_icon_by_filetype(filetype, {}) diff --git a/lua/avante/types.lua b/lua/avante/types.lua new file mode 100644 index 000000000..463404dba --- /dev/null +++ b/lua/avante/types.lua @@ -0,0 +1,26 @@ +---@meta + +---@class AvanteComp +---@field winid integer | nil +---@field bufnr integer | nil +local AvanteComp = {} + +---@return nil +function AvanteComp:mount() end + +---@return nil +function AvanteComp:unmount() end + +---@param event string | string[] +---@param handler string | function +---@param options? table<"'once'" | "'nested'", boolean> +---@return nil +function AvanteComp:on(event, handler, options) end + +-- set keymap for this split +---@param mode string check `:h :map-modes` +---@param key string|string[] key for the mapping +---@param handler string | fun(): nil handler for the mapping +---@param opts? table<"'expr'"|"'noremap'"|"'nowait'"|"'remap'"|"'script'"|"'silent'"|"'unique'", boolean> +---@return nil +function AvanteComp:map(mode, key, handler, opts, ___force___) end