Fix #296
Fix #293
Fix #291
This commit is contained in:
hrsh7th
2021-10-10 11:54:30 +09:00
parent 68f7eeb3f0
commit 2ebdccf61a
3 changed files with 17 additions and 6 deletions

View File

@@ -25,21 +25,28 @@ local window = {}
---@return cmp.Window
window.new = function()
local self = setmetatable({}, { __index = window })
self.buf = vim.api.nvim_create_buf(false, true)
vim.api.nvim_buf_set_option(self.buf, 'undolevels', -1)
vim.api.nvim_buf_set_option(self.buf, 'buftype', 'nofile')
self:ensure()
self.win = nil
self.style = {}
self.sbuf1 = vim.api.nvim_create_buf(false, true)
self.swin1 = nil
self.sbuf2 = vim.api.nvim_create_buf(false, true)
self.swin2 = nil
self.style = {}
self.cache = cache.new()
self.opt = {}
self.id = 0
return self
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.
---NOTE: If the window already visible, immediately applied to it.
---@param key string