Skip to content

Commit a211d40

Browse files
committed
fix(buffers): remove legacy opts.buffers (closes #2519)
1 parent 578a11f commit a211d40

File tree

1 file changed

+30
-35
lines changed

1 file changed

+30
-35
lines changed

lua/fzf-lua/providers/buffers.lua

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -41,41 +41,36 @@ local filter_buffers = function(opts, unfiltered)
4141
end
4242

4343
local excluded, max_bufnr = {}, 0
44-
local bufnrs = type(opts.buffers) == "table"
45-
and vim.tbl_map(function(b)
46-
max_bufnr = math.max(max_bufnr, b)
47-
return b
48-
end, opts.buffers)
49-
or vim.tbl_filter(function(b)
50-
local buf_valid = vim.api.nvim_buf_is_valid(b)
51-
if not buf_valid then
52-
excluded[b] = true
53-
elseif not opts.show_unlisted and b ~= utils.CTX().bufnr and vim.fn.buflisted(b) ~= 1 then
54-
excluded[b] = true
55-
elseif not opts.show_unloaded and not vim.api.nvim_buf_is_loaded(b) then
56-
excluded[b] = true
57-
elseif opts.ignore_current_buffer and b == utils.CTX().bufnr then
58-
excluded[b] = true
59-
elseif opts.current_tab_only and not curtab_bufnrs[b] then
60-
excluded[b] = true
61-
elseif opts.no_term_buffers and utils.is_term_buffer(b) then
62-
excluded[b] = true
63-
elseif opts.cwd_only and not path.is_relative_to(vim.api.nvim_buf_get_name(b), utils.cwd()) then
64-
excluded[b] = true
65-
elseif opts.cwd and not path.is_relative_to(vim.api.nvim_buf_get_name(b), opts.cwd) then
66-
excluded[b] = true
67-
elseif type(opts.filter) == "function" then
68-
-- Custom buffer filter #2162
69-
excluded[b] = not opts.filter(b)
70-
end
71-
if buf_valid and vim.api.nvim_get_option_value("ft", { buf = b }) == "qf" then
72-
excluded[b] = not opts.show_quickfix and true or nil
73-
end
74-
if not excluded[b] and b > max_bufnr then
75-
max_bufnr = b
76-
end
77-
return not excluded[b]
78-
end, unfiltered)
44+
local bufnrs = vim.tbl_filter(function(b)
45+
local buf_valid = vim.api.nvim_buf_is_valid(b)
46+
if not buf_valid then
47+
excluded[b] = true
48+
elseif not opts.show_unlisted and b ~= utils.CTX().bufnr and vim.fn.buflisted(b) ~= 1 then
49+
excluded[b] = true
50+
elseif not opts.show_unloaded and not vim.api.nvim_buf_is_loaded(b) then
51+
excluded[b] = true
52+
elseif opts.ignore_current_buffer and b == utils.CTX().bufnr then
53+
excluded[b] = true
54+
elseif opts.current_tab_only and not curtab_bufnrs[b] then
55+
excluded[b] = true
56+
elseif opts.no_term_buffers and utils.is_term_buffer(b) then
57+
excluded[b] = true
58+
elseif opts.cwd_only and not path.is_relative_to(vim.api.nvim_buf_get_name(b), utils.cwd()) then
59+
excluded[b] = true
60+
elseif opts.cwd and not path.is_relative_to(vim.api.nvim_buf_get_name(b), opts.cwd) then
61+
excluded[b] = true
62+
elseif type(opts.filter) == "function" then
63+
-- Custom buffer filter #2162
64+
excluded[b] = not opts.filter(b)
65+
end
66+
if buf_valid and vim.api.nvim_get_option_value("ft", { buf = b }) == "qf" then
67+
excluded[b] = not opts.show_quickfix and true or nil
68+
end
69+
if not excluded[b] and b > max_bufnr then
70+
max_bufnr = b
71+
end
72+
return not excluded[b]
73+
end, unfiltered)
7974

8075
return bufnrs, excluded, max_bufnr
8176
end

0 commit comments

Comments
 (0)