Skip to content

Commit

Permalink
fix: use vim.islist if available
Browse files Browse the repository at this point in the history
  • Loading branch information
b0o committed May 17, 2024
1 parent d72ddb6 commit 6e9eb6e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lua/incline/config/transform.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
local M = {}

local islist = vim.islist or vim.tbl_islist

M.extend = function(val, entry)
if type(val) ~= 'table' then
return val
end
if vim.tbl_islist(entry.default) and vim.tbl_islist(val) then
if islist(entry.default) and islist(val) then
local res = vim.deepcopy(entry.default)
vim.list_extend(res, val)
return res
Expand Down
4 changes: 3 additions & 1 deletion lua/incline/config/validate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ M.callable = function(val)
return false
end

local islist = vim.islist or vim.tbl_islist

local wrapped = function(base, tbl)
local newindex_inner
newindex_inner = function(self, fn)
Expand Down Expand Up @@ -205,7 +207,7 @@ M.number.natural = M.all { M.number._int, M.number._ge(1) }
-- percentages are numbers between 0 and 1, inclusive
M.number.percentage = M.number._between_r_inc(0, 1)

M.list = wrapped(vim.tbl_islist)
M.list = wrapped(islist)

M.list.of = function(of)
return function(val)
Expand Down

0 comments on commit 6e9eb6e

Please sign in to comment.