Skip to content

Commit

Permalink
fix: flatten
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jul 6, 2024
1 parent 099f30f commit cdbd1f2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lua/neoconf/build/annotations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function M.get_type(prop)
if vim.tbl_isempty(types) then
types = { "any" }
end
return vim.iter(types):flatten():join("|")
return table.concat(util.flatten(types), "|")
end

function M.process_object(name, prop)
Expand Down
2 changes: 1 addition & 1 deletion lua/neoconf/build/schemas.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function M.translate(props, nls_url)
desc = nls[desc:gsub("%%", "")] or desc
if type(desc) == "table" then
local lines = vim.tbl_values(desc)
lines = vim.iter(lines):flatten():totable()
lines = Util.flatten(lines)
table.sort(lines)
desc = table.concat(lines, "\n\n")
end
Expand Down
14 changes: 14 additions & 0 deletions lua/neoconf/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@ function M.on_config(opts)
end)
end

---@param t table
---@param ret? table
function M.flatten(t, ret)
ret = ret or {}
for _, v in pairs(t) do
if type(v) == "table" then
M.flatten(v, ret)
else
ret[#ret + 1] = v
end
end
return ret
end

---@param opts? { local: boolean, global: boolean, autocmd: boolean }
---@return string[]
function M.file_patterns(opts)
Expand Down

0 comments on commit cdbd1f2

Please sign in to comment.