Skip to content

Commit f917e9d

Browse files
committed
perf(#3257): remove appearance and log setup
1 parent 0042f7d commit f917e9d

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

lua/nvim-tree.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,14 +281,14 @@ function M.setup(config_user)
281281

282282
manage_netrw()
283283

284-
require("nvim-tree.log").setup(config.g)
284+
require("nvim-tree.log").start()
285285

286286
if log.enabled("config") then
287287
log.line("config", "default config + user")
288288
log.raw("config", "%s\n", vim.inspect(config.g))
289289
end
290290

291-
require("nvim-tree.appearance").setup()
291+
require("nvim-tree.appearance").define_hi()
292292

293293
require("nvim-tree.view-state").initialize()
294294

lua/nvim-tree/appearance/init.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ M.LEGACY_LINKS = {
182182
NvimTreeDiagnosticHintFolderHL = "NvimTreeLspDiagnosticsHintFolderText",
183183
}
184184

185-
function M.setup()
185+
---Create all highlight groups and links. Idempotent.
186+
function M.define_hi()
186187
-- non-linked
187188
for _, g in ipairs(M.HIGHLIGHT_GROUPS) do
188189
if g.def then

lua/nvim-tree/explorer/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function Explorer:create_autocmds()
8888
vim.api.nvim_create_autocmd("ColorScheme", {
8989
group = self.augroup_id,
9090
callback = function()
91-
appearance.setup()
91+
appearance.define_hi()
9292
view.reset_winhl()
9393
self.renderer:draw()
9494
end,

lua/nvim-tree/log.lua

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
local config = require("nvim-tree.config")
2+
13
---@alias LogTypes "all" | "config" | "copy_paste" | "dev" | "diagnostics" | "git" | "profile" | "watcher"
24

35
---@type table<LogTypes, boolean>
@@ -110,11 +112,12 @@ function M.enabled(typ)
110112
return file_path ~= nil and (types[typ] or types.all)
111113
end
112114

113-
function M.setup(opts)
114-
if opts.log and opts.log.enable and opts.log.types then
115-
types = opts.log.types
115+
--- Create the log file and enable logging, if globally configured
116+
function M.start()
117+
if config.g.log and config.g.log.enable and config.g.log.types then
118+
types = config.g.log.types
116119
file_path = string.format("%s/nvim-tree.log", vim.fn.stdpath("log"), os.date("%H:%M:%S"), vim.env.USER)
117-
if opts.log.truncate then
120+
if config.g.log.truncate then
118121
os.remove(file_path)
119122
end
120123
require("nvim-tree.notify").debug("nvim-tree.lua logging to " .. file_path)

0 commit comments

Comments
 (0)