refactor: make it work on neovim version below 0.12
This commit is contained in:
parent
3ad6f73b57
commit
847d1b7190
3 changed files with 33 additions and 5 deletions
|
|
@ -50,4 +50,23 @@ function utils.indent(line, indent)
|
|||
return string.rep(char, indent)
|
||||
end
|
||||
|
||||
---@generic T
|
||||
---@param tbl T[]
|
||||
---@return T[]
|
||||
function utils.list_unique(tbl)
|
||||
if vim.fn.has "nvim-0.12" == 1 then
|
||||
return vim.list.unique(tbl)
|
||||
end
|
||||
|
||||
for i = #tbl, 1, -1 do
|
||||
for j = 1, i - 1 do
|
||||
if tbl[i] == tbl[j] then
|
||||
table.remove(tbl, i)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
return tbl
|
||||
end
|
||||
|
||||
return utils
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue