Skip to content

Commit

Permalink
fix: replace tbl_flatten to flatten():totable() (#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
pablobfonseca authored May 20, 2024
1 parent 5934302 commit 71bfe9b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lua/dapui/logging.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function Logger.new(filename, opts)
end)()

local function path_join(...)
return table.concat(vim.tbl_flatten({ ... }), path_sep)
return table.concat(vim.iter({ ... }):flatten():totable(), path_sep)
end

logger._level = opts.level or config.log_level
Expand Down
16 changes: 7 additions & 9 deletions scripts/gendocs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ H.pattern_sets = {
-- Determine if line is a function definition. Captures function name and
-- arguments. For reference see '2.5.9 – Function Definitions' in Lua manual.
afterline_fundef = {
"%s*function%s+(%S-)(%b())", -- Regular definition
"^local%s+function%s+(%S-)(%b())", -- Local definition
"^(%S+)%s*=%s*function(%b())", -- Regular assignment
"%s*function%s+(%S-)(%b())", -- Regular definition
"^local%s+function%s+(%S-)(%b())", -- Local definition
"^(%S+)%s*=%s*function(%b())", -- Regular assignment
"^local%s+(%S+)%s*=%s*function(%b())", -- Local assignment
},

-- Determine if line is a general assignment
afterline_assign = {
"^(%S-)%s*=", -- General assignment
"^(%S-)%s*=", -- General assignment
"^local%s+(%S-)%s*=", -- Local assignment
},

Expand Down Expand Up @@ -108,7 +108,7 @@ H.default_input = function()
table.insert(res, files)
end

return vim.tbl_flatten(res)
return vim.iter(res):flatten():totable()
end

H.default_output = function()
Expand Down Expand Up @@ -303,7 +303,7 @@ H.toc_insert = function(s)
toc_entry:clear_lines()
end

for _, l in ipairs(vim.tbl_flatten(toc_lines)) do
for _, l in ipairs(vim.iter(toc_lines):flatten():totable()) do
s:insert(l)
end
end
Expand Down Expand Up @@ -626,7 +626,7 @@ H.collect_strings = function(x)
end
end, x)
-- Flatten to only have strings and not table of strings (from `vim.split`)
return vim.tbl_flatten(res)
return vim.iter(res):flatten():totable()
end

H.file_read = function(path)
Expand Down Expand Up @@ -733,7 +733,6 @@ minidoc.generate(
)
end,
section_post = function(section)

for i, line in ipairs(section) do
if type(line) == "string" then
if string.find(line, "^```") then
Expand All @@ -743,7 +742,6 @@ minidoc.generate(
end
end
end

end,
sections = {
["@generic"] = function(s)
Expand Down

0 comments on commit 71bfe9b

Please sign in to comment.