From 97dc716fc914c46577a4f254035ebef1aa72558a Mon Sep 17 00:00:00 2001 From: Yi Ming Date: Sun, 24 Mar 2024 19:44:34 +0800 Subject: [PATCH] feat: make winblend configurable (#1861) --- doc/cmp.txt | 6 ++++++ lua/cmp/config/default.lua | 2 ++ lua/cmp/types/cmp.lua | 1 + lua/cmp/view/custom_entries_view.lua | 2 +- lua/cmp/view/docs_view.lua | 2 +- 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/doc/cmp.txt b/doc/cmp.txt index 110c9f0..e642f4c 100644 --- a/doc/cmp.txt +++ b/doc/cmp.txt @@ -696,6 +696,12 @@ window.{completion,documentation}.border~ window.{completion,documentation}.winhighlight~ `string | cmp.WinhighlightConfig` Specify the window's winhighlight option. + See |nvim_open_win|. + + *cmp-config.window.{completion,documentation}.winblend* +window.{completion,documentation}.winblend~ + `string | cmp.WinhighlightConfig` + Specify the window's winblend option. See |nvim_open_win|. *cmp-config.window.{completion,documentation}.zindex* diff --git a/lua/cmp/config/default.lua b/lua/cmp/config/default.lua index f5dda4e..592ca28 100644 --- a/lua/cmp/config/default.lua +++ b/lua/cmp/config/default.lua @@ -107,6 +107,7 @@ return function() completion = { border = { '', '', '', '', '', '', '', '' }, winhighlight = 'Normal:Pmenu,FloatBorder:Pmenu,CursorLine:PmenuSel,Search:None', + winblend = vim.o.pumblend, scrolloff = 0, col_offset = 0, side_padding = 1, @@ -117,6 +118,7 @@ return function() max_width = math.floor((WIDE_HEIGHT * 2) * (vim.o.columns / (WIDE_HEIGHT * 2 * 16 / 9))), border = { '', '', '', ' ', '', '', '', ' ' }, winhighlight = 'FloatBorder:NormalFloat', + winblend = vim.o.pumblend, }, }, } diff --git a/lua/cmp/types/cmp.lua b/lua/cmp/types/cmp.lua index 9458c3b..8040eee 100644 --- a/lua/cmp/types/cmp.lua +++ b/lua/cmp/types/cmp.lua @@ -121,6 +121,7 @@ cmp.ItemField = { ---@class cmp.WindowOptions ---@field public border? string|string[] ---@field public winhighlight? string +---@field public winblend? number ---@field public zindex? integer|nil ---@class cmp.CompletionWindowOptions: cmp.WindowOptions diff --git a/lua/cmp/view/custom_entries_view.lua b/lua/cmp/view/custom_entries_view.lua index 7ed3736..9d703c9 100644 --- a/lua/cmp/view/custom_entries_view.lua +++ b/lua/cmp/view/custom_entries_view.lua @@ -201,7 +201,7 @@ custom_entries_view.open = function(self, offset, entries) end -- Apply window options (that might be changed) on the custom completion menu. - self.entries_win:option('winblend', vim.o.pumblend) + self.entries_win:option('winblend', completion.winblend) self.entries_win:option('winhighlight', completion.winhighlight) self.entries_win:option('scrolloff', completion.scrolloff) self.entries_win:open({ diff --git a/lua/cmp/view/docs_view.lua b/lua/cmp/view/docs_view.lua index 4c22b29..346e987 100644 --- a/lua/cmp/view/docs_view.lua +++ b/lua/cmp/view/docs_view.lua @@ -100,7 +100,7 @@ docs_view.open = function(self, e, view) end -- Render window. - self.window:option('winblend', vim.o.pumblend) + self.window:option('winblend', documentation.winblend) self.window:option('winhighlight', documentation.winhighlight) local style = { relative = 'editor',