tabs: 'ctrl-x': enable multi-delete and resume

main
bhagwan 2 years ago
parent bc3edb68cf
commit d15b90e8c3

@ -175,14 +175,20 @@ end
M.vimcmd_buf = function(vimcmd, selected, _)
for i = 1, #selected do
local bufnr = string.match(selected[i], "%[(%d+)")
if vimcmd == 'b'
and not vim.o.hidden and
utils.buffer_is_dirty(nil, true) then
-- warn the user when trying to switch from a dirty buffer
-- when `:set nohidden`
return
if bufnr then
if vimcmd == 'b'
and not vim.o.hidden and
utils.buffer_is_dirty(nil, true) then
-- warn the user when trying to switch from a dirty buffer
-- when `:set nohidden`
return
end
local cmd = vimcmd .. " " .. bufnr
local ok, res = pcall(vim.cmd, cmd)
if not ok then
utils.warn(("':%s' failed: %s"):format(cmd, res))
end
end
vim.cmd(vimcmd .. " " .. bufnr)
end
end

@ -317,7 +317,7 @@ M.globals.tabs = {
["ctrl-s"] = actions.buf_split,
["ctrl-v"] = actions.buf_vsplit,
["ctrl-t"] = actions.buf_tabedit,
["ctrl-x"] = actions.buf_del,
["ctrl-x"] = { actions.buf_del, actions.resume },
},
}
M.globals.lines = {

@ -266,14 +266,13 @@ M.tabs = function(opts)
opts.fn_pre_fzf = UPDATE_STATE
opts._tab_to_buf = {}
opts._list_bufs = function()
local res = {}
for _, t in ipairs(vim.api.nvim_list_tabpages()) do
for _, w in ipairs(vim.api.nvim_tabpage_list_wins(t)) do
local b = vim.api.nvim_win_get_buf(w)
opts._tab_to_buf[t] = opts._tab_to_buf[t] or {}
opts._tab_to_buf[t][b] = true
opts._tab_to_buf[t][b] = t
table.insert(res, b)
end
end
@ -281,6 +280,9 @@ M.tabs = function(opts)
end
local contents = function(cb)
opts._tab_to_buf = {}
local filtered, excluded = filter_buffers(opts, opts._list_bufs)
if not next(filtered) then return end
@ -313,7 +315,7 @@ M.tabs = function(opts)
cb(nil)
end
opts.fzf_opts["--no-multi"] = ''
-- opts.fzf_opts["--no-multi"] = ''
opts.fzf_opts["--preview-window"] = 'hidden:right:0'
opts.fzf_opts["--delimiter"] = vim.fn.shellescape('[\\)]')
opts.fzf_opts["--with-nth"] = '2'

Loading…
Cancel
Save