diff --git a/lua/dial/util.lua b/lua/dial/util.lua index 8032943..0acd16d 100644 --- a/lua/dial/util.lua +++ b/lua/dial/util.lua @@ -1,6 +1,9 @@ -- utils local M = {} +-- NOTE: Needed until compatibility with Neovim 0.9 is dropped +local islist = vim.fn.has('nvim-0.10') == 1 and vim.islist or vim.tbl_islist + ---@generic T ---@param cond boolean ---@param branch_true T @@ -38,7 +41,7 @@ end ---@param arg1 string | function ---@param arg2? string function M.validate_list(name, list, arg1, arg2) - if not vim.tbl_islist(list) then + if not islist(list) then error(("%s is not list."):format(name)) end @@ -160,7 +163,7 @@ end -- util.try_get_keys({foo = "bar", hoge = "fuga", teka = "pika"}, ["teka", "foo"]) -- -> ["pika", "bar"] function M.try_get_keys(tbl, keylst) - if not vim.tbl_islist(keylst) then + if not islist(keylst) then return nil, "the 2nd argument is not list." end