added 'buffers'

main
bhagwan 3 years ago
parent f3f373beaf
commit c4a829e83e

@ -134,6 +134,7 @@ vim.api.nvim_set_keymap('n', '<c-P>',
|`loclist`|location list|
|`lines`|open buffers lines|
|`blines`|current buffer lines|
|`tabs`|open tabs|
### Search
| Command | List |

@ -253,6 +253,19 @@ M.globals.buffers = {
["ctrl-x"] = actions.buf_del,
},
}
M.globals.tabs = {
previewer = "builtin",
prompt = 'Tabs> ',
file_icons = true and M._has_devicons,
color_icons = true,
actions = {
["default"] = actions.buf_edit,
["ctrl-s"] = actions.buf_split,
["ctrl-v"] = actions.buf_vsplit,
["ctrl-t"] = actions.buf_tabedit,
["ctrl-x"] = actions.buf_del,
},
}
M.globals.lines = {
previewer = "builtin",
prompt = 'Lines> ',

@ -61,6 +61,7 @@ M.oldfiles = require'fzf-lua.providers.oldfiles'.oldfiles
M.quickfix = require'fzf-lua.providers.quickfix'.quickfix
M.loclist = require'fzf-lua.providers.quickfix'.loclist
M.buffers = require'fzf-lua.providers.buffers'.buffers
M.tabs = require'fzf-lua.providers.buffers'.tabs
M.lines = require'fzf-lua.providers.buffers'.lines
M.blines = require'fzf-lua.providers.buffers'.blines
M.help_tags = require'fzf-lua.providers.helptags'.helptags

@ -60,7 +60,7 @@ M.buffers = function(opts)
return false
end
return true
end, vim.api.nvim_list_bufs())
end, opts._list_bufs and opts._list_bufs() or vim.api.nvim_list_bufs())
if not next(bufnrs) then return end
local header_line = false
@ -250,4 +250,34 @@ M.buffer_lines = function(opts)
end)()
end
M.tabs = function(opts)
opts = config.normalize_opts(opts, config.globals.tabs)
if not opts then return end
local buf_to_tab = {}
opts._list_bufs = function()
local res = {}
for _, t in ipairs(vim.api.nvim_list_tabpages()) do
local w = vim.api.nvim_tabpage_get_win(t)
local b = vim.api.nvim_win_get_buf(w)
buf_to_tab[b] = t
table.insert(res, b)
end
return res
end
opts.nomulti = true
opts.preview_window = 'hidden:right:0'
opts.fzf_cli_args = "--delimiter=']' --nth 2,-1" --with-nth 2"
opts.actions["default"] = function(selected)
local bufnr = tonumber(selected[2])
local tabnr = buf_to_tab[bufnr]
vim.cmd("tabn " .. tabnr)
end
M.buffers(opts)
end
return M

Loading…
Cancel
Save