mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-04 06:40:06 +08:00
18 lines
449 B
Lua
18 lines
449 B
Lua
local buffer = {}
|
|
|
|
buffer.ensure = setmetatable({
|
|
cache = {},
|
|
}, {
|
|
__call = function(self, name)
|
|
if not (self.cache[name] and vim.api.nvim_buf_is_valid(self.cache[name])) then
|
|
local buf = vim.api.nvim_create_buf(false, true)
|
|
vim.api.nvim_buf_set_option(buf, 'buftype', 'nofile')
|
|
vim.api.nvim_buf_set_option(buf, 'bufhidden', 'hide')
|
|
self.cache[name] = buf
|
|
end
|
|
return self.cache[name]
|
|
end,
|
|
})
|
|
|
|
return buffer
|