Skip to content

Commit

Permalink
Update to new form of tbl_flatten to fix deprecation warnings (#197)
Browse files Browse the repository at this point in the history
The nightly Neovim is warning that tbl_flatten has been deprecated and
should be replaced with what I have put in this commit.
  • Loading branch information
alisonjenkins authored Nov 18, 2024
1 parent aa9b346 commit 5e92a56
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lua/zk/root_pattern_util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ local uv = vim.loop
local M = {}

-- Some path utilities

local function tbl_flatten(...)
if vim.fn.has("nvim-0.10") then
return vim.iter({ ... }):flatten():totable()
else
return vim.tbl_flatten({ ... })
end
end

M.path = (function()
local is_windows = uv.os_uname().version:match("Windows")

Expand Down Expand Up @@ -46,7 +55,7 @@ M.path = (function()
end

local function path_join(...)
return table.concat(vim.tbl_flatten({ ... }), "/")
return table.concat(tbl_flatten({ ... }), "/")
end

-- Iterate the path until we find the rootdir.
Expand Down Expand Up @@ -94,7 +103,7 @@ function M.search_ancestors(startpath, func)
end

function M.root_pattern(...)
local patterns = vim.tbl_flatten({ ... })
local patterns = tbl_flatten({ ... })
local function matcher(path)
for _, pattern in ipairs(patterns) do
for _, p in ipairs(vim.fn.glob(M.path.join(M.path.escape_wildcards(path), pattern), true, true)) do
Expand Down

0 comments on commit 5e92a56

Please sign in to comment.