feat(log): add node inspection function (#2541)
* feat: add `api.tree.inspect_node_under_cursor` * Add documentation * Revert "feat: add `api.tree.inspect_node_under_cursor`" This reverts commit784ee91cc6. * Revert "Add documentation" This reverts commit6dc396d0a5. * feat(log): add node inspection function --------- Co-authored-by: Alexander Courtis <alex@courtis.org>
This commit is contained in:
@@ -61,6 +61,26 @@ function M.line(typ, fmt, ...)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local inspect_opts = {}
|
||||||
|
|
||||||
|
--- @param opts table
|
||||||
|
function M.set_inspect_opts(opts)
|
||||||
|
inspect_opts = opts
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Write to log file the inspection of a node
|
||||||
|
--- defaults to the node under cursor if none is provided
|
||||||
|
--- @param typ string as per log.types config
|
||||||
|
--- @param node table|nil node to be inspected
|
||||||
|
--- @param fmt string for string.format
|
||||||
|
--- @vararg any arguments for string.format
|
||||||
|
function M.node(typ, node, fmt, ...)
|
||||||
|
if M.enabled(typ) then
|
||||||
|
node = node or require("nvim-tree.lib").get_node_at_cursor()
|
||||||
|
M.raw(typ, string.format("[%s] [%s] %s\n%s\n", os.date "%Y-%m-%d %H:%M:%S", typ, (fmt or "???"), vim.inspect(node, inspect_opts)), ...)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- Logging is enabled for typ or all
|
--- Logging is enabled for typ or all
|
||||||
--- @param typ string as per log.types config
|
--- @param typ string as per log.types config
|
||||||
--- @return boolean
|
--- @return boolean
|
||||||
|
|||||||
Reference in New Issue
Block a user