From 13451e7ee45fd2f5e9283963944561442d041a97 Mon Sep 17 00:00:00 2001 From: Jongwook Choi Date: Thu, 21 Mar 2024 14:05:55 -0400 Subject: [PATCH] docs: fix invalid WindowConfig schema, should match to the docs (#1779) Problem: `cmp.WindowConfig` was defined twice. Solution: Introduce `cmp.CompletionWindowOptions` and `cmp.DocumentationWindowOptions`. Make fields of these two class consistent with |cmp-config.window.*| --- lua/cmp/types/cmp.lua | 18 ++++++++++++------ lua/cmp/view/custom_entries_view.lua | 2 ++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lua/cmp/types/cmp.lua b/lua/cmp/types/cmp.lua index 98173c8..9458c3b 100644 --- a/lua/cmp/types/cmp.lua +++ b/lua/cmp/types/cmp.lua @@ -107,10 +107,6 @@ cmp.ItemField = { ---@field public async_budget integer Maximum time (in ms) an async function is allowed to run during one step of the event loop. ---@field public max_view_entries integer ----@class cmp.WindowConfig ----@field completion? cmp.WindowConfig ----@field documentation? cmp.WindowConfig|nil - ---@class cmp.CompletionConfig ---@field public autocomplete? cmp.TriggerEvent[]|false ---@field public completeopt? string @@ -119,14 +115,24 @@ cmp.ItemField = { ---@field public keyword_pattern? string ---@class cmp.WindowConfig +---@field public completion? cmp.CompletionWindowOptions +---@field public documentation? cmp.DocumentationWindowOptions|nil + +---@class cmp.WindowOptions ---@field public border? string|string[] ---@field public winhighlight? string ---@field public zindex? integer|nil ----@field public max_width? integer|nil ----@field public max_height? integer|nil + +---@class cmp.CompletionWindowOptions: cmp.WindowOptions ---@field public scrolloff? integer|nil +---@field public col_offset? integer|nil +---@field public side_padding? integer|nil ---@field public scrollbar? boolean|true +---@class cmp.DocumentationWindowOptions: cmp.WindowOptions +---@field public max_height? integer|nil +---@field public max_width? integer|nil + ---@class cmp.ConfirmationConfig ---@field public default_behavior cmp.ConfirmBehavior ---@field public get_commit_characters fun(commit_characters: string[]): string[] diff --git a/lua/cmp/view/custom_entries_view.lua b/lua/cmp/view/custom_entries_view.lua index 9a665b1..7ed3736 100644 --- a/lua/cmp/view/custom_entries_view.lua +++ b/lua/cmp/view/custom_entries_view.lua @@ -118,6 +118,8 @@ end custom_entries_view.open = function(self, offset, entries) local completion = config.get().window.completion + assert(completion, 'config.get() must resolve window.completion with defaults') + self.offset = offset self.entries = {} self.column_width = { abbr = 0, kind = 0, menu = 0 }