File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Load Diff This file was deleted.
Original file line number Diff line number Diff line change 66--- This is expensive as there are many cascading requires and is avoided
77--- until after setup has been called, so that the user may require API cheaply.
88
9+ local legacy = require (" nvim-tree.legacy" )
10+
911local actions = require (" nvim-tree.actions" )
1012local help = require (" nvim-tree.help" )
1113local keymap = require (" nvim-tree.keymap" )
@@ -256,7 +258,7 @@ function M.hydrate(api)
256258 api .map .keymap .current = keymap .get_keymap
257259
258260 -- (Re)hydrate any legacy by mapping to concrete set above
259- require ( " nvim-tree.api.impl. legacy" ). hydrate (api )
261+ legacy . map_api (api )
260262end
261263
262264return M
Original file line number Diff line number Diff line change 99--
1010-- Everything must be as lazily loaded as possible: the user must be able to require api cheaply.
1111
12+ local legacy = require (" nvim-tree.legacy" )
13+
1214local commands = require (" nvim-tree.commands" ) -- already required by plugin.lua
1315local events = require (" nvim-tree.events" ) -- needed for event registration pre-setup
1416local keymap = require (" nvim-tree.keymap" ) -- needed for default on attach
@@ -40,7 +42,6 @@ function M.hydrate(api)
4042 hydrate_error (api )
4143
4244 -- eager functions
43- api .events .Event = events .Event
4445 api .events .subscribe = events .subscribe
4546 api .map .on_attach .default = keymap .on_attach_default
4647 api .commands .get = commands .get
@@ -51,9 +52,10 @@ function M.hydrate(api)
5152
5253 -- classes
5354 api .Decorator = Decorator :extend ()
55+ api .events .Event = events .Event
5456
5557 -- Hydrate any legacy by mapping to concrete set above
56- require ( " nvim-tree.api.impl. legacy" ). hydrate (api )
58+ legacy . map_api (api )
5759end
5860
5961return M
Original file line number Diff line number Diff line change @@ -151,4 +151,32 @@ function M.migrate_legacy_options(opts)
151151 removed (opts )
152152end
153153
154+ --- Silently create new api entries pointing legacy functions to current
155+ --- @param api table not properly typed to prevent LSP from referencing implementations
156+ function M .map_api (api )
157+ api .config = api .config or {}
158+ api .config .mappings = api .config .mappings or {}
159+ api .config .mappings .get_keymap = api .map .keymap .current
160+ api .config .mappings .get_keymap_default = api .map .keymap .default
161+ api .config .mappings .default_on_attach = api .map .on_attach .default
162+
163+ api .live_filter = api .live_filter or {}
164+ api .live_filter .start = api .filter .live .start
165+ api .live_filter .clear = api .filter .live .clear
166+
167+ api .tree = api .tree or {}
168+ api .tree .toggle_enable_filters = api .filter .toggle
169+ api .tree .toggle_gitignore_filter = api .filter .git .ignored .toggle
170+ api .tree .toggle_git_clean_filter = api .filter .git .clean .toggle
171+ api .tree .toggle_no_buffer_filter = api .filter .no_buffer .toggle
172+ api .tree .toggle_custom_filter = api .filter .custom .toggle
173+ api .tree .toggle_hidden_filter = api .filter .dotfiles .toggle
174+ api .tree .toggle_no_bookmark_filter = api .filter .no_bookmark .toggle
175+
176+ api .diagnostics = api .diagnostics or {}
177+ api .diagnostics .hi_test = api .health .hi_test
178+
179+ api .decorator .UserDecorator = api .Decorator
180+ end
181+
154182return M
Original file line number Diff line number Diff line change 11local Decorator = require (" nvim-tree.renderer.decorator" )
22
3- --- Builtin decorator interface.
3+ --- Abstract builtin decorator
44--- Overrides all methods to use a Node instead of nvim_tree.api.Node as we don't have generics.
55---
66--- @class (exact ) BuiltinDecorator : Decorator
Original file line number Diff line number Diff line change 1+ local DecoratorInterface = require (" nvim-tree._meta.api.decorator" )
2+
13---
2- --- Abstract decorator implementation
4+ --- Abstract decorator
35---
46--- @class (exact ) Decorator : nvim_tree.api.Decorator
5- local Decorator = require ( " nvim-tree._meta.api.decorator " ) :extend ()
7+ local Decorator = DecoratorInterface :extend ()
68
79--- Maybe highlight groups for icon and name
810--- @param node nvim_tree.api.Node
You can’t perform that action at this time.
0 commit comments