Add tabs module
This commit is contained in:
24
config/nvim/lua/user/tabs.lua
Normal file
24
config/nvim/lua/user/tabs.lua
Normal file
@@ -0,0 +1,24 @@
|
||||
local M = {
|
||||
history = {},
|
||||
}
|
||||
|
||||
M.close_tab = function()
|
||||
table.insert(M.history, vim.fn.bufnr("%"))
|
||||
vim.cmd("tabclose")
|
||||
end
|
||||
|
||||
M.restore_tab = function()
|
||||
local buflen = #M.history
|
||||
|
||||
if buflen == 0 then
|
||||
print("No buffers remaining")
|
||||
return
|
||||
end
|
||||
|
||||
local buf = M.history[buflen]
|
||||
vim.cmd("tabnew +" .. tostring(buf) .. "buf")
|
||||
|
||||
table.remove(M.history, buflen)
|
||||
end
|
||||
|
||||
return M
|
||||
Reference in New Issue
Block a user