From 5dfd807771dbd68b1b776e489c043337baccf638 Mon Sep 17 00:00:00 2001 From: Svetlozar Iliev Date: Mon, 30 Jan 2023 19:09:29 +0200 Subject: feat: Allow filtering for oldfiles and buffers (#2353) --- lua/telescope/builtin/__internal.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lua/telescope/builtin/__internal.lua') diff --git a/lua/telescope/builtin/__internal.lua b/lua/telescope/builtin/__internal.lua index 613643b..e1b6ce3 100644 --- a/lua/telescope/builtin/__internal.lua +++ b/lua/telescope/builtin/__internal.lua @@ -523,8 +523,9 @@ internal.oldfiles = function(opts) end end - if opts.cwd_only then - local cwd = vim.loop.cwd() .. utils.get_separator() + if opts.cwd_only or opts.cwd then + local cwd = opts.cwd_only and vim.loop.cwd() or opts.cwd + cwd = cwd .. utils.get_separator() cwd = cwd:gsub([[\]], [[\\]]) results = vim.tbl_filter(function(file) return vim.fn.matchstrpos(file, cwd)[2] ~= -1 @@ -878,6 +879,9 @@ internal.buffers = function(opts) if opts.cwd_only and not string.find(vim.api.nvim_buf_get_name(b), vim.loop.cwd(), 1, true) then return false end + if not opts.cwd_only and opts.cwd and not string.find(vim.api.nvim_buf_get_name(b), opts.cwd, 1, true) then + return false + end return true end, vim.api.nvim_list_bufs()) if not next(bufnrs) then -- cgit v1.2.3