refactor(compat): use svim.islist

This commit is contained in:
Folke Lemaitre 2025-02-20 06:59:12 +01:00
parent bc902f7032
commit 63277f96c9
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
5 changed files with 5 additions and 11 deletions

View file

@ -54,9 +54,8 @@ M.config = setmetatable({}, {
end,
})
local islist = vim.islist or vim.tbl_islist
local is_dict_like = function(v) -- has string and number keys
return type(v) == "table" and (vim.tbl_isempty(v) or not islist(v))
return type(v) == "table" and (vim.tbl_isempty(v) or not svim.islist(v))
end
local is_dict = function(v) -- has only string keys
return type(v) == "table" and (vim.tbl_isempty(v) or not v[1])

View file

@ -9,8 +9,6 @@ local M = {}
---@field desc? string
---@field name? string
local islist = vim.islist or vim.tbl_islist
---@param picker snacks.Picker
function M.get(picker)
local ref = picker:ref()
@ -91,7 +89,7 @@ function M.resolve(action, picker, name, stack)
action,
stack
)
elseif type(action) == "table" and islist(action) then
elseif type(action) == "table" and svim.islist(action) then
---@type snacks.picker.Action[]
local actions = vim.tbl_map(function(a)
return M.resolve(a, picker, nil, stack)

View file

@ -5,8 +5,6 @@ local Async = require("snacks.picker.util.async")
local M = {}
local islist = vim.islist or vim.tbl_islist
---@alias lsp.Symbol lsp.SymbolInformation|lsp.DocumentSymbol
---@alias lsp.Loc lsp.Location|lsp.LocationLink
@ -195,7 +193,7 @@ function M.get_locations(method, opts, filter)
end, function(client, result)
result = result or {}
-- Result can be a single item or a list of items
result = vim.tbl_isempty(result) and {} or islist(result) and result or { result }
result = vim.tbl_isempty(result) and {} or svim.islist(result) and result or { result }
local items = vim.lsp.util.locations_to_items(result or {}, client.offset_encoding)
M.fix_locs(items)

View file

@ -5,7 +5,6 @@ local M = {}
local uv = vim.uv or vim.loop
M.USE_QUEUE = true
local islist = vim.islist or vim.tbl_islist
---@class snacks.picker.proc.Config: snacks.picker.Config
---@field cmd string
@ -19,7 +18,7 @@ local islist = vim.islist or vim.tbl_islist
---@param opts snacks.picker.proc.Config|{[1]: snacks.picker.Config, [2]: snacks.picker.proc.Config}
---@type snacks.picker.finder
function M.proc(opts, ctx)
if islist(opts) then
if svim.islist(opts) then
local transform = opts[2].transform
opts = Snacks.config.merge(unpack(vim.deepcopy(opts))) --[[@as snacks.picker.proc.Config]]
opts.transform = transform