feat: add buffer list (#30)

NOTE: Buffer entry sometimes uses unstyled window, and I can't figure out why.

* feat: add buffers

* fixup
This commit is contained in:
TJ DeVries
2020-09-05 07:34:38 -04:00
committed by GitHub
parent 4abb5f7867
commit c70d6e58a0
3 changed files with 66 additions and 7 deletions

View File

@@ -22,6 +22,7 @@ local pickers = require('telescope.pickers')
local sorters = require('telescope.sorters')
local utils = require('telescope.utils')
local filter = vim.tbl_filter
local flatten = vim.tbl_flatten
-- TODO: Support silver search here.
@@ -340,4 +341,26 @@ builtin.fd = function(opts)
}):find()
end
-- TODO: This is partially broken, but I think it might be an nvim bug.
builtin.buffers = function(opts)
opts = opts or {}
local buffers = filter(function(b)
return
vim.api.nvim_buf_is_loaded(b)
and 1 == vim.fn.buflisted(b)
end, vim.api.nvim_list_bufs())
pickers.new(opts, {
prompt = 'Buffers',
finder = finders.new_table {
results = buffers,
entry_maker = make_entry.gen_from_buffer(opts)
},
previewer = previewers.vim_buffer.new(opts),
sorter = sorters.get_norcalli_sorter(),
}):find()
end
return builtin