From 34160fe8d34e51c3104b515d80a7657b65052e89 Mon Sep 17 00:00:00 2001 From: Ivan Smirnov <46977173+Wansmer@users.noreply.github.com> Date: Mon, 22 Apr 2024 09:35:17 +0300 Subject: [PATCH] refactor: rename `tbl_islist` to `islist` for nvim-0.10+ (#29) --- lua/langmapper/helpers.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lua/langmapper/helpers.lua b/lua/langmapper/helpers.lua index d7f3308..8460d8f 100644 --- a/lua/langmapper/helpers.lua +++ b/lua/langmapper/helpers.lua @@ -1,5 +1,7 @@ local M = {} +M.is_list = vim.fn.has('nvim-0.10') == 1 and vim.islist or vim.tbl_islist + ---Bind first param to function ---@param cb function ---@param first any First param @@ -18,7 +20,7 @@ function M.is_dict(tbl) return false end - return not vim.tbl_islist(tbl) + return not M.is_list(tbl) end ---Checks if some item of list meets the condition. @@ -27,7 +29,7 @@ end ---@param cb function Callback for checking every item ---@return boolean function M.some(tbl, cb) - if not vim.tbl_islist(tbl) or vim.tbl_isempty(tbl) then + if not M.is_list(tbl) or vim.tbl_isempty(tbl) then return false end @@ -46,7 +48,7 @@ end ---@param cb function Callback for checking every item ---@return boolean function M.every(tbl, cb) - if type(tbl) ~= 'table' or not vim.tbl_islist(tbl) or vim.tbl_isempty(tbl) then + if type(tbl) ~= 'table' or not M.is_list(tbl) or vim.tbl_isempty(tbl) then return false end