move tabufline related functions to ui repo
This commit is contained in:
parent
97062ae15f
commit
83572cc15b
3 changed files with 11 additions and 78 deletions
|
|
@ -1,18 +1,6 @@
|
|||
local M = {}
|
||||
local api = vim.api
|
||||
|
||||
local merge_tb = vim.tbl_deep_extend
|
||||
|
||||
M.close_buffer = function(bufnr)
|
||||
if vim.bo.buftype == "terminal" then
|
||||
vim.cmd(vim.bo.buflisted and "set nobl | enew" or "hide")
|
||||
else
|
||||
bufnr = bufnr or api.nvim_get_current_buf()
|
||||
require("core.utils").tabuflinePrev()
|
||||
vim.cmd("confirm bd" .. bufnr)
|
||||
end
|
||||
end
|
||||
|
||||
M.load_config = function()
|
||||
local config = require "core.default_config"
|
||||
local chadrc_exists, chadrc = pcall(require, "custom.chadrc")
|
||||
|
|
@ -201,59 +189,4 @@ M.packer_sync = function(...)
|
|||
end
|
||||
end
|
||||
|
||||
M.bufilter = function()
|
||||
local bufs = vim.t.bufs or nil
|
||||
|
||||
if not bufs then
|
||||
return {}
|
||||
end
|
||||
|
||||
for i = #bufs, 1, -1 do
|
||||
if not vim.api.nvim_buf_is_valid(bufs[i]) then
|
||||
table.remove(bufs, i)
|
||||
end
|
||||
end
|
||||
|
||||
return bufs
|
||||
end
|
||||
|
||||
M.tabuflineNext = function()
|
||||
local bufs = M.bufilter() or {}
|
||||
|
||||
for i, v in ipairs(bufs) do
|
||||
if api.nvim_get_current_buf() == v then
|
||||
vim.cmd(i == #bufs and "b" .. bufs[1] or "b" .. bufs[i + 1])
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
M.tabuflinePrev = function()
|
||||
local bufs = M.bufilter() or {}
|
||||
|
||||
for i, v in ipairs(bufs) do
|
||||
if api.nvim_get_current_buf() == v then
|
||||
vim.cmd(i == 1 and "b" .. bufs[#bufs] or "b" .. bufs[i - 1])
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- closes tab + all of its buffers
|
||||
M.closeAllBufs = function(action)
|
||||
local bufs = vim.t.bufs
|
||||
|
||||
if action == "closeTab" then
|
||||
vim.cmd "tabclose"
|
||||
end
|
||||
|
||||
for _, buf in ipairs(bufs) do
|
||||
M.close_buffer(buf)
|
||||
end
|
||||
|
||||
if action ~= "closeTab" then
|
||||
vim.cmd "enew"
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue