Skip to content

Commit 942d071

Browse files
committed
refactor(#3256): legacy config consistent parameter naming
1 parent 20416ba commit 942d071

File tree

1 file changed

+46
-46
lines changed

1 file changed

+46
-46
lines changed

lua/nvim-tree/legacy.lua

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -51,110 +51,110 @@ local function move(src, src_path, src_pos, dst, dst_path, dst_pos, remove)
5151
end
5252

5353
-- silently move, please add to help nvim-tree-legacy-config
54-
---@param opts nvim_tree.config user supplied subset of config
55-
local function refactored_config(opts)
54+
---@param u nvim_tree.config user supplied subset of config
55+
local function refactored_config(u)
5656
-- 2022/06/20
57-
move(opts, "update_focused_file", "update_cwd", opts, "update_focused_file", "update_root", true)
58-
move(opts, "", "update_cwd", opts, "", "sync_root_with_cwd", true)
57+
move(u, "update_focused_file", "update_cwd", u, "update_focused_file", "update_root", true)
58+
move(u, "", "update_cwd", u, "", "sync_root_with_cwd", true)
5959

6060
-- 2022/11/07
61-
move(opts, "", "open_on_tab", opts, "tab.sync", "open", false)
62-
move(opts, "", "open_on_tab", opts, "tab.sync", "close", true)
63-
move(opts, "", "ignore_buf_on_tab_change", opts, "tab.sync", "ignore", true)
61+
move(u, "", "open_on_tab", u, "tab.sync", "open", false)
62+
move(u, "", "open_on_tab", u, "tab.sync", "close", true)
63+
move(u, "", "ignore_buf_on_tab_change", u, "tab.sync", "ignore", true)
6464

6565
-- 2022/11/22
66-
move(opts, "renderer", "root_folder_modifier", opts, "renderer", "root_folder_label", true)
66+
move(u, "renderer", "root_folder_modifier", u, "renderer", "root_folder_label", true)
6767

6868
-- 2023/01/01
69-
move(opts, "update_focused_file", "debounce_delay", opts, "view", "debounce_delay", true)
69+
move(u, "update_focused_file", "debounce_delay", u, "view", "debounce_delay", true)
7070

7171
-- 2023/01/08
72-
move(opts, "trash", "require_confirm", opts, "ui.confirm", "trash", true)
72+
move(u, "trash", "require_confirm", u, "ui.confirm", "trash", true)
7373

7474
-- 2023/01/15
75-
if type(opts.view) == "table" and opts.view.adaptive_size ~= nil then
76-
if opts.view.adaptive_size and type(opts.view.width) ~= "table" then
77-
local width = opts.view.width --[[@as nvim_tree.config.view.width.spec]]
78-
opts.view.width = {
75+
if type(u.view) == "table" and u.view.adaptive_size ~= nil then
76+
if u.view.adaptive_size and type(u.view.width) ~= "table" then
77+
local width = u.view.width --[[@as nvim_tree.config.view.width.spec]]
78+
u.view.width = {
7979
min = width,
8080
}
8181
end
82-
opts.view["adaptive_size"] = nil
82+
u.view["adaptive_size"] = nil
8383
end
8484

8585
-- 2023/07/15
86-
move(opts, "", "sort_by", opts, "sort", "sorter", true)
86+
move(u, "", "sort_by", u, "sort", "sorter", true)
8787

8888
-- 2023/07/16
89-
move(opts, "git", "ignore", opts, "filters", "git_ignored", true)
89+
move(u, "git", "ignore", u, "filters", "git_ignored", true)
9090

9191
-- 2023/08/26
92-
move(opts, "renderer.icons", "webdev_colors", opts, "renderer.icons.web_devicons.file", "color", true)
92+
move(u, "renderer.icons", "webdev_colors", u, "renderer.icons.web_devicons.file", "color", true)
9393

9494
-- 2023/10/08
95-
if type(opts.renderer) == "table" and type(opts.renderer.highlight_diagnostics) == "boolean" then
96-
opts.renderer.highlight_diagnostics = opts.renderer.highlight_diagnostics and "name" or "none"
95+
if type(u.renderer) == "table" and type(u.renderer.highlight_diagnostics) == "boolean" then
96+
u.renderer.highlight_diagnostics = u.renderer.highlight_diagnostics and "name" or "none"
9797
end
9898

9999
-- 2023/10/21
100-
if type(opts.renderer) == "table" and type(opts.renderer.highlight_git) == "boolean" then
101-
opts.renderer.highlight_git = opts.renderer.highlight_git and "name" or "none"
100+
if type(u.renderer) == "table" and type(u.renderer.highlight_git) == "boolean" then
101+
u.renderer.highlight_git = u.renderer.highlight_git and "name" or "none"
102102
end
103103

104104
-- 2024/02/15
105-
if type(opts.update_focused_file) == "table" then
106-
if type(opts.update_focused_file.update_root) ~= "table" then
107-
opts.update_focused_file.update_root = { enable = opts.update_focused_file.update_root == true }
105+
if type(u.update_focused_file) == "table" then
106+
if type(u.update_focused_file.update_root) ~= "table" then
107+
u.update_focused_file.update_root = { enable = u.update_focused_file.update_root == true }
108108
end
109109
end
110-
move(opts, "update_focused_file", "ignore_list", opts, "update_focused_file.update_root", "ignore_list", true)
110+
move(u, "update_focused_file", "ignore_list", u, "update_focused_file.update_root", "ignore_list", true)
111111

112112
-- 2025/04/30
113-
if opts.renderer and opts.renderer.icons and type(opts.renderer.icons.padding) == "string" then
114-
local icons_padding = opts.renderer.icons.padding --[[@as string]]
115-
opts.renderer.icons.padding = {}
116-
opts.renderer.icons.padding.icon = icons_padding
113+
if u.renderer and u.renderer.icons and type(u.renderer.icons.padding) == "string" then
114+
local icons_padding = u.renderer.icons.padding --[[@as string]]
115+
u.renderer.icons.padding = {}
116+
u.renderer.icons.padding.icon = icons_padding
117117
end
118118
end
119119

120-
---@param opts nvim_tree.config user supplied subset of config
121-
local function deprecated_config(opts)
122-
if type(opts.view) == "table" and opts.view.hide_root_folder then
120+
---@param u nvim_tree.config user supplied subset of config
121+
local function deprecated_config(u)
122+
if type(u.view) == "table" and u.view.hide_root_folder then
123123
notify.info("view.hide_root_folder is deprecated, please set renderer.root_folder_label = false")
124124
end
125125
end
126126

127-
---@param opts nvim_tree.config user supplied subset of config
128-
local function removed_config(opts)
129-
if opts.auto_close then
127+
---@param u nvim_tree.config user supplied subset of config
128+
local function removed_config(u)
129+
if u.auto_close then
130130
notify.warn("auto close feature has been removed: https://github.com/nvim-tree/nvim-tree.lua/wiki/Auto-Close")
131-
opts["auto_close"] = nil
131+
u["auto_close"] = nil
132132
end
133133

134-
if opts.focus_empty_on_setup then
134+
if u.focus_empty_on_setup then
135135
notify.warn("focus_empty_on_setup has been removed: https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup")
136-
opts["focus_empty_on_setup"] = nil
136+
u["focus_empty_on_setup"] = nil
137137
end
138138

139-
if opts.create_in_closed_folder then
139+
if u.create_in_closed_folder then
140140
notify.warn(
141141
"create_in_closed_folder has been removed and is now the default behaviour. You may use api.fs.create to add a file under your desired node.")
142142
end
143-
opts["create_in_closed_folder"] = nil
143+
u["create_in_closed_folder"] = nil
144144
end
145145

146146
---Migrate legacy config in place.
147147
---Refactored are silently migrated. Deprecated and removed result in a warning.
148-
---@param opts nvim_tree.config user supplied subset of config
149-
function M.migrate_config(opts)
148+
---@param u nvim_tree.config user supplied subset of config
149+
function M.migrate_config(u)
150150
-- silently move
151-
refactored_config(opts)
151+
refactored_config(u)
152152

153153
-- warn
154-
deprecated_config(opts)
154+
deprecated_config(u)
155155

156156
-- warn and delete
157-
removed_config(opts)
157+
removed_config(u)
158158
end
159159

160160
---Silently create new api entries pointing legacy functions to current

0 commit comments

Comments
 (0)