Skip to content

Commit 5132c96

Browse files
committed
chore: nvim 0.11 changes and deprecations
fix(devicons): lowercase extensions/file names fix(lines|blines): enable multiselection
1 parent e412b1b commit 5132c96

24 files changed

+138
-118
lines changed

lua/fzf-lua/actions.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ M.normalize_selected = function(actions, selected)
3636
-- so it can always be enumerated safely
3737
if not actions or not selected then return end
3838
local action = _default_action
39-
if utils.tbl_length(actions) > 1 or not actions[_default_action] then
39+
if utils.tbl_count(actions) > 1 or not actions[_default_action] then
4040
-- keybind should be in item #1
4141
-- default keybind is an empty string
4242
-- so we leave that as "default"

lua/fzf-lua/cmd.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function M.run_command(cmd, ...)
2222
local val = arg:match("=") and arg:match("=(.*)$")
2323
if val and #val > 0 then
2424
local ok, loaded = serpent.load(val)
25-
if ok and (type(loaded) ~= "table" or not vim.tbl_isempty(loaded)) then
25+
if ok and (type(loaded) ~= "table" or not utils.tbl_isempty(loaded)) then
2626
opts[key] = loaded
2727
else
2828
opts[key] = val
@@ -95,7 +95,7 @@ function M._candidates(line, cmp_items)
9595
if n < 0 then return end
9696

9797
if n == 0 then
98-
local commands = vim.tbl_flatten({ builtin_list })
98+
local commands = utils.tbl_flatten({ builtin_list })
9999
table.sort(commands)
100100

101101
commands = vim.tbl_filter(function(val)
@@ -147,7 +147,7 @@ function M._candidates(line, cmp_items)
147147
fzf_opts = false,
148148
__HLS = "hls", -- rename prefix
149149
}) do
150-
opts = vim.tbl_flatten({ opts, vim.tbl_filter(function(x)
150+
opts = utils.tbl_flatten({ opts, vim.tbl_filter(function(x)
151151
-- Exclude global options that can be specified only during `setup`,
152152
-- e.g.'`winopts.preview.default` as this might confuse the user
153153
return not M.options_md()["setup." .. x]
@@ -162,7 +162,7 @@ function M._candidates(line, cmp_items)
162162
vim.tbl_map(function(o)
163163
-- Cut the first part, e.g. "files.cwd" -> "cwd"
164164
o = o:match("%..*$"):sub(2)
165-
if not vim.tbl_contains(opts, o) then
165+
if not utils.tbl_contains(opts, o) then
166166
table.insert(opts, o)
167167
end
168168
end, opts_from_docs)

lua/fzf-lua/cmp_src.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ end
3434
---@return lsp.MarkupContent?
3535
function Src:_get_documentation(completion_item)
3636
local options_md = require("fzf-lua.cmd").options_md()
37-
if not options_md or vim.tbl_isempty(options_md) then return end
37+
if not options_md or not next(options_md) then return end
3838
-- Test for `label:lower()` to match both `grep_c{word|WORD}`
3939
local markdown = options_md[completion_item.label] or options_md[completion_item.label:lower()]
4040
if not markdown and completion_item.data then

lua/fzf-lua/core.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ local contents_from_arr = function(cont_arr)
7777
contents = {}
7878
for _, t in ipairs(cont_arr) do
7979
assert(type(t.contents) == cont_type, "Unable to combine contents of different types")
80-
contents = utils.tbl_extend(contents, t.prefix and
80+
contents = utils.tbl_join(contents, t.prefix and
8181
vim.tbl_map(function(x)
8282
return t.prefix .. x
8383
end, t.contents)
@@ -253,7 +253,7 @@ M.CTX = function(includeBuflist)
253253
-- buffers/tabs use these we only include the current
254254
-- list of buffers when requested
255255
if includeBuflist and not M.__CTX.buflist then
256-
-- also add a map for faster lookups than `vim.tbl_contains`
256+
-- also add a map for faster lookups than `utils.tbl_contains`
257257
-- TODO: is it really faster since we must use string keys?
258258
M.__CTX.bufmap = {}
259259
M.__CTX.buflist = vim.api.nvim_list_bufs()
@@ -515,7 +515,7 @@ M.create_fzf_colors = function(opts)
515515
table.insert(spec, list[i])
516516
end
517517
end
518-
if not vim.tbl_isempty(spec) then
518+
if not utils.tbl_isempty(spec) then
519519
table.insert(spec, 1, flag)
520520
table.insert(tbl, table.concat(spec, ":"))
521521
end
@@ -524,11 +524,11 @@ M.create_fzf_colors = function(opts)
524524
end
525525
end
526526

527-
return not vim.tbl_isempty(tbl) and table.concat(tbl, ",")
527+
return not utils.tbl_isempty(tbl) and table.concat(tbl, ",")
528528
end
529529

530530
M.create_fzf_binds = function(binds)
531-
if not binds or vim.tbl_isempty(binds) then return end
531+
if not binds or utils.tbl_isempty(binds) then return end
532532
local tbl = {}
533533
local dedup = {}
534534
for k, v in pairs(binds) do
@@ -900,7 +900,7 @@ M.set_header = function(opts, hdr_tbl)
900900
end
901901
end
902902
-- table.concat fails if the table indexes aren't consecutive
903-
return not vim.tbl_isempty(ret) and (function()
903+
return not utils.tbl_isempty(ret) and (function()
904904
local t = {}
905905
for _, i in pairs(ret) do
906906
table.insert(t, i)

lua/fzf-lua/defaults.lua

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -529,11 +529,9 @@ M.defaults.lines = {
529529
show_unlisted = false,
530530
no_term_buffers = true,
531531
fzf_opts = {
532-
["--no-multi"] = true,
533532
["--delimiter"] = "[\\]:]",
534533
["--nth"] = "2..",
535534
["--tiebreak"] = "index",
536-
["--tabstop"] = "1",
537535
},
538536
line_field_index = "{3}",
539537
_actions = function() return M.globals.actions.buffers end,
@@ -553,11 +551,9 @@ M.defaults.blines = {
553551
show_unlisted = true,
554552
no_term_buffers = false,
555553
fzf_opts = {
556-
["--no-multi"] = true,
557554
["--delimiter"] = "[:]",
558555
["--with-nth"] = "2..",
559556
["--tiebreak"] = "index",
560-
["--tabstop"] = "1",
561557
},
562558
line_field_index = "{2}",
563559
_actions = function() return M.globals.actions.buffers end,

lua/fzf-lua/devicons.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ M.load_icons = function()
7575
end
7676
return M.__DEVICONS_LIB.get_icons()
7777
end)
78-
if not ok or not all_devicons or vim.tbl_isempty(all_devicons) then
78+
if not ok or not all_devicons or utils.tbl_isempty(all_devicons) then
7979
-- something is wrong with devicons
8080
-- can't use `error` due to fast event
8181
print("[Fzf-lua] error: devicons.get_icons() is nil or empty!")
@@ -164,7 +164,7 @@ M.get_devicon = function(filepath, extensionOverride)
164164
end
165165

166166
local icon, color
167-
local filename = path.tail(filepath)
167+
local filename = path.tail(filepath):lower()
168168
local ext = extensionOverride or path.extension(filename, true)
169169

170170
-- lookup directly by filename
@@ -173,12 +173,14 @@ M.get_devicon = function(filepath, extensionOverride)
173173
icon, color = by_filename.icon, by_filename.color
174174
end
175175

176+
if ext then ext = ext:lower() end
177+
176178
-- check for `ext` as extension can be nil, e.g. "dockerfile"
177179
-- lookup by 2 part extensions, e.g. "foo.test.tsx"
178180
if ext and not icon and M.STATE.icons.ext_has_2part[ext] then
179181
local ext2 = path.extension(filename:sub(1, #filename - #ext - 1))
180182
if ext2 then
181-
local by_ext_2part = M.STATE.icons.by_ext_2part[ext2 .. "." .. ext]
183+
local by_ext_2part = M.STATE.icons.by_ext_2part[ext2:lower() .. "." .. ext]
182184
if by_ext_2part then
183185
icon, color = by_ext_2part.icon, by_ext_2part.color
184186
end

lua/fzf-lua/fzf.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ function M.raw_fzf(contents, fzf_cli_args, opts)
5656
-- instance never terminates which hangs fzf on exit
5757
local FZF_DEFAULT_COMMAND = nil
5858

59-
utils.tbl_extend(cmd, fzf_cli_args or {})
59+
utils.tbl_join(cmd, fzf_cli_args or {})
6060
if type(opts.fzf_cli_args) == "table" then
61-
utils.tbl_extend(cmd, opts.fzf_cli_args)
61+
utils.tbl_join(cmd, opts.fzf_cli_args)
6262
elseif type(opts.fzf_cli_args) == "string" then
63-
utils.tbl_extend(cmd, { opts.fzf_cli_args })
63+
utils.tbl_join(cmd, { opts.fzf_cli_args })
6464
end
6565

6666
if contents then
@@ -179,7 +179,7 @@ function M.raw_fzf(contents, fzf_cli_args, opts)
179179
-- error out, but that doesn't matter so we just break out of the loop.
180180
if contents then
181181
if type(contents) == "table" then
182-
if not vim.tbl_isempty(contents) then
182+
if not utils.tbl_isempty(contents) then
183183
write_cb(vim.tbl_map(function(x)
184184
return x .. "\n"
185185
end, contents))
@@ -251,7 +251,7 @@ function M.raw_fzf(contents, fzf_cli_args, opts)
251251
and { "cmd", "/d", "/e:off", "/f:off", "/v:off", "/c" }
252252
or { "sh", "-c" }
253253
if utils.__IS_WINDOWS then
254-
utils.tbl_extend(shell_cmd, cmd)
254+
utils.tbl_join(shell_cmd, cmd)
255255
else
256256
table.insert(shell_cmd, table.concat(cmd, " "))
257257
end

lua/fzf-lua/make_entry.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,9 @@ end
275275

276276
M.lcol = function(entry, opts)
277277
if not entry then return nil end
278-
local hl_colnr = vim.tbl_contains(opts._cached_hls or {}, "path_colnr")
278+
local hl_colnr = utils.tbl_contains(opts._cached_hls or {}, "path_colnr")
279279
and opts.hls.path_colnr or "blue"
280-
local hl_linenr = vim.tbl_contains(opts._cached_hls or {}, "path_linenr")
280+
local hl_linenr = utils.tbl_contains(opts._cached_hls or {}, "path_linenr")
281281
and opts.hls.path_linenr or "green"
282282
local filename = entry.filename or vim.api.nvim_buf_get_name(entry.bufnr)
283283
return string.format("%s:%s%s%s",

lua/fzf-lua/previewer/builtin.lua

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ function Previewer.buffer_or_file:populate_preview_buf(entry_str)
589589
-- stop ueberzug shell job
590590
self:stop_ueberzug()
591591
local entry = self:parse_entry(entry_str)
592-
if vim.tbl_isempty(entry) then return end
592+
if utils.tbl_isempty(entry) then return end
593593
if entry.bufnr and not api.nvim_buf_is_loaded(entry.bufnr)
594594
and vim.api.nvim_buf_is_valid(entry.bufnr) then
595595
-- buffer is not loaded, can happen when calling "lines" with `set nohidden`
@@ -648,7 +648,7 @@ function Previewer.buffer_or_file:populate_preview_buf(entry_str)
648648
assert(entry.path)
649649
-- not found in cache, attempt to load
650650
local tmpbuf = self:get_tmp_buffer()
651-
if self.extensions and not vim.tbl_isempty(self.extensions) then
651+
if self.extensions and not utils.tbl_isempty(self.extensions) then
652652
local ext = path.extension(entry.path)
653653
local cmd = ext and self.extensions[ext:lower()]
654654
if cmd and self:populate_terminal_cmd(tmpbuf, cmd, entry) then
@@ -727,7 +727,7 @@ local ts_attach_08 = function(bufnr, ft)
727727
local is_table = type(config.additional_vim_regex_highlighting) == "table"
728728
if
729729
config.additional_vim_regex_highlighting
730-
and (not is_table or vim.tbl_contains(config.additional_vim_regex_highlighting, lang))
730+
and (not is_table or utils.tbl_contains(config.additional_vim_regex_highlighting, lang))
731731
then
732732
vim.bo[bufnr].syntax = ft
733733
end
@@ -770,11 +770,9 @@ function Previewer.buffer_or_file:do_syntax(entry)
770770
if syntax_limit_reached > 0 and self.opts.silent == false then
771771
utils.info(string.format(
772772
"syntax disabled for '%s' (%s), consider increasing '%s(%d)'", entry.path,
773-
utils._if(syntax_limit_reached == 1,
774-
("%d lines"):format(lcount),
775-
("%db"):format(bytes)),
776-
utils._if(syntax_limit_reached == 1, "syntax_limit_l", "syntax_limit_b"),
777-
utils._if(syntax_limit_reached == 1, self.syntax_limit_l, self.syntax_limit_b)
773+
syntax_limit_reached == 1 and ("%d lines"):format(lcount) or ("%db"):format(bytes),
774+
syntax_limit_reached == 1 and "syntax_limit_l" or "syntax_limit_b",
775+
syntax_limit_reached == 1 and self.syntax_limit_l or self.syntax_limit_b
778776
))
779777
end
780778
if syntax_limit_reached == 0 then
@@ -796,9 +794,9 @@ function Previewer.buffer_or_file:do_syntax(entry)
796794
self.treesitter.enable == false or
797795
self.treesitter.disable == true or
798796
(type(self.treesitter.enable) == "table" and
799-
not vim.tbl_contains(self.treesitter.enable, ft)) or
797+
not utils.tbl_contains(self.treesitter.enable, ft)) or
800798
(type(self.treesitter.disable) == "table" and
801-
vim.tbl_contains(self.treesitter.disable, ft)) then
799+
utils.tbl_contains(self.treesitter.disable, ft)) then
802800
return false
803801
end
804802
return true
@@ -1220,7 +1218,7 @@ function Previewer.quickfix:populate_preview_buf(entry_str)
12201218
local qf_list = self.opts._is_loclist
12211219
and vim.fn.getloclist(self.win.src_winid, { all = "", nr = tonumber(nr) })
12221220
or vim.fn.getqflist({ all = "", nr = tonumber(nr) })
1223-
if vim.tbl_isempty(qf_list) or vim.tbl_isempty(qf_list.items) then
1221+
if utils.tbl_isempty(qf_list) or utils.tbl_isempty(qf_list.items) then
12241222
return
12251223
end
12261224

@@ -1262,7 +1260,7 @@ end
12621260
function Previewer.autocmds:populate_preview_buf(entry_str)
12631261
if not self.win or not self.win:validate_preview() then return end
12641262
local entry = self:parse_entry(entry_str)
1265-
if vim.tbl_isempty(entry) then return end
1263+
if utils.tbl_isempty(entry) then return end
12661264
self._is_vimL_command = false
12671265
if entry.path == "<none>" then
12681266
self._is_vimL_command = true

lua/fzf-lua/previewer/codeaction.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ local function diff_workspace_edit(workspace_edit, offset_encoding, diff_opts)
102102
end
103103

104104
local all_changes = workspace_edit.changes
105-
if all_changes and not vim.tbl_isempty(all_changes) then
105+
if all_changes and not utils.tbl_isempty(all_changes) then
106106
for uri, changes in pairs(all_changes) do
107107
local path = vim.fn.fnamemodify(vim.uri_to_fname(uri), ":.")
108108
local bufnr = vim.uri_to_bufnr(uri)
@@ -170,11 +170,11 @@ local function preview_action_tuple(self, idx, callback)
170170
local choice = self.opts._items[idx]
171171
local bufnr = assert(choice.ctx.bufnr, "Must have buffer number")
172172
local reg = client.dynamic_capabilities:get(ms.textDocument_codeAction, { bufnr = bufnr })
173-
return vim.tbl_get(reg or {}, "registerOptions", "resolveProvider")
173+
return utils.tbl_get(reg or {}, "registerOptions", "resolveProvider")
174174
or client.supports_method(ms.codeAction_resolve)
175175
end)()
176176
-- prior to nvim 0.10 we could check `client.server_capabilities`
177-
or vim.tbl_get(client.server_capabilities, "codeActionProvider", "resolveProvider")
177+
or utils.tbl_get(client.server_capabilities, "codeActionProvider", "resolveProvider")
178178
if not action.edit and client and supports_resolve then
179179
-- Action is not a workspace edit, attempt to resolve the code action
180180
-- in case it resolves to a workspace edit

0 commit comments

Comments
 (0)