From cf87220dff58629c610147defc42341b5b0580cb Mon Sep 17 00:00:00 2001 From: Avinash Thakur <19588421+80avin@users.noreply.github.com> Date: Tue, 17 Jun 2025 13:39:12 +0530 Subject: [PATCH] docs: fix doc types. Add lua type to `opts` in readme (#2200) * docs: fix doc types. Add lua type to `opts` in readme * [pre-commit.ci lite] apply automatic fixes * chore: fix type error in sidebar.lua --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> --- README.md | 7 +++++++ README_zh.md | 2 ++ lua/avante/config.lua | 6 ++++++ lua/avante/sidebar.lua | 1 + 4 files changed, 16 insertions(+) diff --git a/README.md b/README.md index 7a8c0d6..fc80caa 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,8 @@ For building binary if you wish to build from source, then `cargo` is required. "yetone/avante.nvim", event = "VeryLazy", version = false, -- Never set this value to "*"! Never! + ---@module 'avante' + ---@type avante.Config opts = { -- add any opts here -- for example @@ -335,8 +337,10 @@ _See [config.lua#L9](./lua/avante/config.lua) for the full config_ ```lua { ---@alias Provider "claude" | "openai" | "azure" | "gemini" | "cohere" | "copilot" | string + ---@type Provider provider = "claude", -- The provider used in Aider mode or in the planning phase of Cursor Planning Mode ---@alias Mode "agentic" | "legacy" + ---@type Mode mode = "agentic", -- The default mode for interaction. "agentic" uses tools to automatically generate code, "legacy" uses the old planning method to generate code. -- WARNING: Since auto-suggestions are a high-frequency operation and therefore expensive, -- currently designating it as `copilot` provider is dangerous because: https://github.com/yetone/avante.nvim/issues/1048 @@ -488,6 +492,7 @@ or you can use [Kaiser-Yang/blink-cmp-avante](https://github.com/Kaiser-Yang/bli ```lua selector = { --- @alias avante.SelectorProvider "native" | "fzf_lua" | "mini_pick" | "snacks" | "telescope" | fun(selector: avante.ui.Selector): nil + --- @type avante.SelectorProvider provider = "fzf", -- Options override for custom providers provider_opts = {}, @@ -542,6 +547,7 @@ For enhanced input UI with better styling and features: ``` You'll need to install dressing.nvim: + ```lua -- With lazy.nvim { "stevearc/dressing.nvim" } @@ -568,6 +574,7 @@ For modern, feature-rich input UI: ``` You'll need to install snacks.nvim: + ```lua -- With lazy.nvim { "folke/snacks.nvim" } diff --git a/README_zh.md b/README_zh.md index 8f7f9a2..bd1ccd2 100644 --- a/README_zh.md +++ b/README_zh.md @@ -60,6 +60,8 @@ "yetone/avante.nvim", event = "VeryLazy", version = false, -- 永远不要将此值设置为 "*"!永远不要! + ---@module 'avante' + ---@type avante.Config opts = { -- 在此处添加任何选项 -- 例如 diff --git a/lua/avante/config.lua b/lua/avante/config.lua index c499157..fb5c4b2 100644 --- a/lua/avante/config.lua +++ b/lua/avante/config.lua @@ -21,8 +21,10 @@ local M = {} M._defaults = { debug = false, ---@alias avante.Mode "agentic" | "legacy" + ---@type avante.Mode mode = "agentic", ---@alias avante.ProviderName "claude" | "openai" | "azure" | "gemini" | "vertex" | "cohere" | "copilot" | "bedrock" | "ollama" | string + ---@type avante.ProviderName provider = "claude", -- WARNING: Since auto-suggestions are a high-frequency operation and therefore expensive, -- currently designating it as `copilot` provider is dangerous because: https://github.com/yetone/avante.nvim/issues/1048 @@ -30,6 +32,7 @@ M._defaults = { auto_suggestions_provider = nil, memory_summary_provider = nil, ---@alias Tokenizer "tiktoken" | "hf" + ---@type Tokenizer -- Used for counting tokens and encoding text. -- By default, we will use tiktoken. -- For most providers that we support we will determine this automatically. @@ -518,6 +521,7 @@ M._defaults = { }, windows = { ---@alias AvantePosition "right" | "left" | "top" | "bottom" | "smart" + ---@type AvantePosition position = "right", fillchars = "eob: ", wrap = true, -- similar to vim.o.wrap @@ -541,6 +545,7 @@ M._defaults = { border = { " ", " ", " ", " ", " ", " ", " ", " " }, start_insert = true, -- Start insert mode when opening the ask window ---@alias AvanteInitialDiff "ours" | "theirs" + ---@type AvanteInitialDiff focus_on_apply = "ours", -- which diff to focus after applying }, }, @@ -569,6 +574,7 @@ M._defaults = { }, selector = { ---@alias avante.SelectorProvider "native" | "fzf_lua" | "mini_pick" | "snacks" | "telescope" | fun(selector: avante.ui.Selector): nil + ---@type avante.SelectorProvider provider = "native", provider_opts = {}, exclude_auto_select = {}, -- List of items to exclude from auto selection diff --git a/lua/avante/sidebar.lua b/lua/avante/sidebar.lua index 3f345b3..42124c2 100644 --- a/lua/avante/sidebar.lua +++ b/lua/avante/sidebar.lua @@ -1613,6 +1613,7 @@ local function calculate_config_window_position() end end + ---@cast position -"smart", -string return position end