Skip to content

Commit 6a2422b

Browse files
authored
Merge branch 'master' into ci-lua-language-server
2 parents a4f282a + 5e4475d commit 6a2422b

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lua/nvim-tree/core.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function M.get_explorer()
2828
end
2929

3030
function M.get_cwd()
31-
return TreeExplorer.absolute_path
31+
return TreeExplorer and TreeExplorer.absolute_path
3232
end
3333

3434
function M.get_nodes_starting_line()

lua/nvim-tree/log.lua

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,26 @@ function M.line(typ, fmt, ...)
6161
end
6262
end
6363

64+
local inspect_opts = {}
65+
66+
--- @param opts table
67+
function M.set_inspect_opts(opts)
68+
inspect_opts = opts
69+
end
70+
71+
--- Write to log file the inspection of a node
72+
--- defaults to the node under cursor if none is provided
73+
--- @param typ string as per log.types config
74+
--- @param node table|nil node to be inspected
75+
--- @param fmt string for string.format
76+
--- @vararg any arguments for string.format
77+
function M.node(typ, node, fmt, ...)
78+
if M.enabled(typ) then
79+
node = node or require("nvim-tree.lib").get_node_at_cursor()
80+
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)), ...)
81+
end
82+
end
83+
6484
--- Logging is enabled for typ or all
6585
--- @param typ string as per log.types config
6686
--- @return boolean

0 commit comments

Comments
 (0)