Skip to content

Commit

Permalink
Hope this works now lol
Browse files Browse the repository at this point in the history
  • Loading branch information
quantumfate committed Apr 29, 2024
1 parent 0008671 commit 46df245
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions lua/qvim/log/log.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
local fn_t = require("qvim.utils.fn_t")
local utils = require("qvim.utils")

---@class StructlogImpl
Expand All @@ -25,6 +24,18 @@ StructlogImpl.levels = {
}
vim.tbl_add_reverse_lookup(StructlogImpl.levels)

---@param t any
---@param predicate fun(entry: any):boolean
---@return boolean
local function any(t, predicate)
for _, entry in pairs(t) do
if predicate(entry) then
return true
end
end
return false
end

---Setup Structlog with its channels and mutates the log table to index the log functions
---@param self StructlogImpl
---@param channels table<string, table>
Expand All @@ -51,7 +62,7 @@ function StructlogImpl:setup(channels, log)
---@return function
__index = function(tbl, key)
if
fn_t.any(vim.tbl_keys(channels), function(entry)
any(vim.tbl_keys(channels), function(entry)
return key == entry
end)
then
Expand Down
2 changes: 1 addition & 1 deletion lua/qvim/utils/fn_t.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ end

---Checks if any entry in a table satisfies a predicate
---@param t any
---@param predicate any
---@param predicate fun(entry: any):boolean
---@return boolean
function Table.any(t, predicate)
for _, entry in pairs(t) do
Expand Down

0 comments on commit 46df245

Please sign in to comment.