Skip to content

Commit b1eb870

Browse files
committed
refactor(#2875): multi instance renderer
1 parent e332271 commit b1eb870

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

lua/nvim-tree/explorer/init.lua

+5-4
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,16 @@ function Explorer:new(path)
5151
return
5252
end
5353

54-
---@type Explorer
55-
local o = setmetatable({
54+
local o = {
5655
opts = config,
5756
absolute_path = path,
5857
nodes = {},
5958
open = true,
6059
sorters = Sorters:new(config),
61-
}, Explorer)
62-
setmetatable(o, { __index = self })
60+
}
61+
62+
setmetatable(o, self)
63+
self.__index = self
6364

6465
o.watcher = watch.create_watcher(o)
6566
o.renderer = Renderer:new(config, o)

lua/nvim-tree/renderer/builder.lua

+3-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ local PICTURE_MAP = {
3434
---@field col_end number
3535

3636
---@class (exact) Builder
37+
---@field private __index? table
3738
---@field lines string[] includes icons etc.
3839
---@field hl_args AddHighlightArgs[] line highlights
3940
---@field signs string[] line signs
@@ -79,7 +80,8 @@ function Builder:new(opts, explorer)
7980
hidden_display = Builder:setup_hidden_display_function(opts),
8081
}
8182

82-
setmetatable(o, { __index = self })
83+
setmetatable(o, self)
84+
self.__index = self
8385

8486
return o
8587
end

lua/nvim-tree/renderer/decorator/init.lua

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ local HL_POSITION = require("nvim-tree.enum").HL_POSITION
22
local ICON_PLACEMENT = require("nvim-tree.enum").ICON_PLACEMENT
33

44
---@class (exact) Decorator
5+
---@field private __index? table
56
---@field protected explorer Explorer
67
---@field protected enabled boolean
78
---@field protected hl_pos HL_POSITION
@@ -13,7 +14,8 @@ local Decorator = {}
1314
function Decorator:new(o)
1415
o = o or {}
1516

16-
setmetatable(o, { __index = self })
17+
setmetatable(o, self)
18+
self.__index = self
1719

1820
return o
1921
end

lua/nvim-tree/renderer/init.lua

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ local namespace_extmarks_id = vim.api.nvim_create_namespace "NvimTreeExtmarks"
1313
local namespace_virtual_lines_id = vim.api.nvim_create_namespace "NvimTreeVirtualLines"
1414

1515
---@class (exact) Renderer
16+
---@field private __index? table
1617
---@field private opts table user options
1718
---@field private explorer Explorer
1819
---@field private builder Builder
@@ -29,7 +30,8 @@ function Renderer:new(opts, explorer)
2930
builder = Builder:new(opts, explorer),
3031
}
3132

32-
setmetatable(o, { __index = self })
33+
setmetatable(o, self)
34+
self.__index = self
3335

3436
return o
3537
end

0 commit comments

Comments
 (0)