@@ -25,21 +25,28 @@ local window = {}
|
|||||||
---@return cmp.Window
|
---@return cmp.Window
|
||||||
window.new = function()
|
window.new = function()
|
||||||
local self = setmetatable({}, { __index = window })
|
local self = setmetatable({}, { __index = window })
|
||||||
self.buf = vim.api.nvim_create_buf(false, true)
|
self:ensure()
|
||||||
vim.api.nvim_buf_set_option(self.buf, 'undolevels', -1)
|
|
||||||
vim.api.nvim_buf_set_option(self.buf, 'buftype', 'nofile')
|
|
||||||
self.win = nil
|
self.win = nil
|
||||||
self.style = {}
|
|
||||||
self.sbuf1 = vim.api.nvim_create_buf(false, true)
|
|
||||||
self.swin1 = nil
|
self.swin1 = nil
|
||||||
self.sbuf2 = vim.api.nvim_create_buf(false, true)
|
|
||||||
self.swin2 = nil
|
self.swin2 = nil
|
||||||
|
self.style = {}
|
||||||
self.cache = cache.new()
|
self.cache = cache.new()
|
||||||
self.opt = {}
|
self.opt = {}
|
||||||
self.id = 0
|
self.id = 0
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Ensure valid state.
|
||||||
|
window.ensure = function(self)
|
||||||
|
for _, name in ipairs({ 'buf', 'sbuf1', 'subf2' }) do
|
||||||
|
if not (self[name] and vim.api.nvim_buf_is_valid(self[name])) then
|
||||||
|
self[name] = vim.api.nvim_create_buf(false, true)
|
||||||
|
vim.api.nvim_buf_set_option(self[name], 'undolevels', -1)
|
||||||
|
vim.api.nvim_buf_set_option(self[name], 'buftype', 'nofile')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
---Set window option.
|
---Set window option.
|
||||||
---NOTE: If the window already visible, immediately applied to it.
|
---NOTE: If the window already visible, immediately applied to it.
|
||||||
---@param key string
|
---@param key string
|
||||||
|
|||||||
@@ -89,6 +89,8 @@ custom_entries_view.redraw = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
custom_entries_view.open = function(self, offset, entries)
|
custom_entries_view.open = function(self, offset, entries)
|
||||||
|
self.entries_win:ensure()
|
||||||
|
|
||||||
self.offset = offset
|
self.offset = offset
|
||||||
self.entries = {}
|
self.entries = {}
|
||||||
self.column_bytes = { abbr = 0, kind = 0, menu = 0 }
|
self.column_bytes = { abbr = 0, kind = 0, menu = 0 }
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ end
|
|||||||
---@param e cmp.Entry
|
---@param e cmp.Entry
|
||||||
---@param view cmp.WindowStyle
|
---@param view cmp.WindowStyle
|
||||||
docs_view.open = function(self, e, view)
|
docs_view.open = function(self, e, view)
|
||||||
|
self.window:ensure()
|
||||||
|
|
||||||
local documentation = config.get().documentation
|
local documentation = config.get().documentation
|
||||||
if not documentation then
|
if not documentation then
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user