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
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
local u = require "gopher._utils"
|
||||
|
||||
---@param option string
|
||||
local function option_to_tag(option)
|
||||
return option:match "^(.-)="
|
||||
|
|
@ -32,12 +34,9 @@ function struct_tags.parse_args(args)
|
|||
end
|
||||
end
|
||||
|
||||
-- todo: it's incompatible with vim lower 0.12
|
||||
tags = vim.list.unique(tags)
|
||||
options = vim.list.unique(options)
|
||||
return {
|
||||
tags = table.concat(tags, ","),
|
||||
options = table.concat(options, ","),
|
||||
tags = table.concat(u.list_unique(tags), ","),
|
||||
options = table.concat(u.list_unique(options), ","),
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue