Skip to content

Commit

Permalink
Move to non deprecated function calls (#1930)
Browse files Browse the repository at this point in the history
* Move to non deprecated function calls

* Keeping it compatible with older versions
  • Loading branch information
augustocdias authored May 17, 2024
1 parent 31a2939 commit abacd4c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lua/cmp/utils/misc.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
local misc = {}

local islist = vim.islist or vim.tbl_islist

---Create once callback
---@param callback function
---@return function
Expand Down Expand Up @@ -88,8 +90,8 @@ misc.none = vim.NIL
---@param tbl2 T
---@return T
misc.merge = function(tbl1, tbl2)
local is_dict1 = type(tbl1) == 'table' and (not vim.tbl_islist(tbl1) or vim.tbl_isempty(tbl1))
local is_dict2 = type(tbl2) == 'table' and (not vim.tbl_islist(tbl2) or vim.tbl_isempty(tbl2))
local is_dict1 = type(tbl1) == 'table' and (not islist(tbl1) or vim.tbl_isempty(tbl1))
local is_dict2 = type(tbl2) == 'table' and (not islist(tbl2) or vim.tbl_isempty(tbl2))
if is_dict1 and is_dict2 then
local new_tbl = {}
for k, v in pairs(tbl2) do
Expand Down Expand Up @@ -163,7 +165,7 @@ misc.copy = function(tbl)
return tbl
end

if vim.tbl_islist(tbl) then
if islist(tbl) then
local copy = {}
for i, value in ipairs(tbl) do
copy[i] = misc.copy(value)
Expand Down

0 comments on commit abacd4c

Please sign in to comment.