From 7577f3a82ff60ef7425451b1f40dd83ffee12307 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 16 May 2024 21:49:01 +0200 Subject: [PATCH] fix(util): deprecation warnings for tbl_islist --- lua/trouble/command.lua | 2 +- lua/trouble/format.lua | 2 +- lua/trouble/spec.lua | 3 ++- lua/trouble/util.lua | 2 ++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lua/trouble/command.lua b/lua/trouble/command.lua index e8305489..01de83dd 100644 --- a/lua/trouble/command.lua +++ b/lua/trouble/command.lua @@ -43,7 +43,7 @@ function M.complete_opts() end local kk = top.k .. k candidates[#candidates + 1] = kk:gsub("^%.", "") .. "=" - if type(v) == "table" and not vim.tbl_islist(v) then + if type(v) == "table" and not Util.islist(v) then table.insert(stack, { k = kk, t = v }) end end diff --git a/lua/trouble/format.lua b/lua/trouble/format.lua index e1142fc0..69cd5756 100644 --- a/lua/trouble/format.lua +++ b/lua/trouble/format.lua @@ -151,7 +151,7 @@ function M.field(ctx) if not result then return end - result = type(result) == "table" and vim.tbl_islist(result) and result or { result } + result = type(result) == "table" and Util.islist(result) and result or { result } format = {} ---@cast result (string|trouble.Format)[] for _, f in ipairs(result) do diff --git a/lua/trouble/spec.lua b/lua/trouble/spec.lua index f5b35665..dd5ff54c 100644 --- a/lua/trouble/spec.lua +++ b/lua/trouble/spec.lua @@ -1,4 +1,5 @@ local Config = require("trouble.config") +local Util = require("trouble.util") ---@alias trouble.SorterFn fun(item: trouble.Item): any? @@ -103,7 +104,7 @@ end ---@param spec trouble.Sort.spec ---@return trouble.Sort[] function M.sort(spec) - spec = type(spec) == "table" and vim.tbl_islist(spec) and spec or { spec } + spec = type(spec) == "table" and Util.islist(spec) and spec or { spec } ---@cast spec (string|trouble.SorterFn|trouble.Filter.spec)[] local fields = {} ---@type trouble.Sort[] for f, field in ipairs(spec) do diff --git a/lua/trouble/util.lua b/lua/trouble/util.lua index 54988750..cc527c98 100644 --- a/lua/trouble/util.lua +++ b/lua/trouble/util.lua @@ -21,6 +21,8 @@ function M.try(fn, opts) end end +M.islist = vim.islist or vim.tbl_islist + ---@alias NotifyOpts {level?: number, title?: string, once?: boolean} ---@param msg string|string[]