@@ -3,273 +3,6 @@ local notify = require "nvim-tree.notify"
3
3
4
4
local M = {}
5
5
6
- -- TODO update bit.ly/3vIpEOJ when adding a migration
7
-
8
- -- migrate the g: to o if the user has not specified that when calling setup
9
- local g_migrations = {
10
- nvim_tree_disable_netrw = function (o )
11
- if o .disable_netrw == nil then
12
- o .disable_netrw = vim .g .nvim_tree_disable_netrw ~= 0
13
- end
14
- end ,
15
-
16
- nvim_tree_hijack_netrw = function (o )
17
- if o .hijack_netrw == nil then
18
- o .hijack_netrw = vim .g .nvim_tree_hijack_netrw ~= 0
19
- end
20
- end ,
21
-
22
- nvim_tree_auto_open = function (o )
23
- if o .open_on_setup == nil then
24
- o .open_on_setup = vim .g .nvim_tree_auto_open ~= 0
25
- end
26
- end ,
27
-
28
- nvim_tree_tab_open = function (o )
29
- if o .open_on_tab == nil then
30
- o .open_on_tab = vim .g .nvim_tree_tab_open ~= 0
31
- end
32
- end ,
33
-
34
- nvim_tree_update_cwd = function (o )
35
- if o .update_cwd == nil then
36
- o .update_cwd = vim .g .nvim_tree_update_cwd ~= 0
37
- end
38
- end ,
39
-
40
- nvim_tree_hijack_cursor = function (o )
41
- if o .hijack_cursor == nil then
42
- o .hijack_cursor = vim .g .nvim_tree_hijack_cursor ~= 0
43
- end
44
- end ,
45
-
46
- nvim_tree_system_open_command = function (o )
47
- utils .table_create_missing (o , " system_open" )
48
- if o .system_open .cmd == nil then
49
- o .system_open .cmd = vim .g .nvim_tree_system_open_command
50
- end
51
- end ,
52
-
53
- nvim_tree_system_open_command_args = function (o )
54
- utils .table_create_missing (o , " system_open" )
55
- if o .system_open .args == nil then
56
- o .system_open .args = vim .g .nvim_tree_system_open_command_args
57
- end
58
- end ,
59
-
60
- nvim_tree_follow = function (o )
61
- utils .table_create_missing (o , " update_focused_file" )
62
- if o .update_focused_file .enable == nil then
63
- o .update_focused_file .enable = vim .g .nvim_tree_follow ~= 0
64
- end
65
- end ,
66
-
67
- nvim_tree_follow_update_path = function (o )
68
- utils .table_create_missing (o , " update_focused_file" )
69
- if o .update_focused_file .update_cwd == nil then
70
- o .update_focused_file .update_cwd = vim .g .nvim_tree_follow_update_path ~= 0
71
- end
72
- end ,
73
-
74
- nvim_tree_lsp_diagnostics = function (o )
75
- utils .table_create_missing (o , " diagnostics" )
76
- if o .diagnostics .enable == nil then
77
- o .diagnostics .enable = vim .g .nvim_tree_lsp_diagnostics ~= 0
78
- if o .diagnostics .show_on_dirs == nil then
79
- o .diagnostics .show_on_dirs = vim .g .nvim_tree_lsp_diagnostics ~= 0
80
- end
81
- end
82
- end ,
83
-
84
- nvim_tree_auto_resize = function (o )
85
- utils .table_create_missing (o , " actions.open_file" )
86
- if o .actions .open_file .resize_window == nil then
87
- o .actions .open_file .resize_window = vim .g .nvim_tree_auto_resize ~= 0
88
- end
89
- end ,
90
-
91
- nvim_tree_bindings = function (o )
92
- utils .table_create_missing (o , " view.mappings" )
93
- if o .view .mappings .list == nil then
94
- o .view .mappings .list = vim .g .nvim_tree_bindings
95
- end
96
- end ,
97
-
98
- nvim_tree_disable_keybindings = function (o )
99
- utils .table_create_missing (o , " view.mappings" )
100
- if o .view .mappings .custom_only == nil then
101
- if vim .g .nvim_tree_disable_keybindings ~= 0 then
102
- o .view .mappings .custom_only = true
103
- -- specify one mapping so that defaults do not apply
104
- o .view .mappings .list = {
105
- { key = " g?" , action = " " },
106
- }
107
- end
108
- end
109
- end ,
110
-
111
- nvim_tree_disable_default_keybindings = function (o )
112
- utils .table_create_missing (o , " view.mappings" )
113
- if o .view .mappings .custom_only == nil then
114
- o .view .mappings .custom_only = vim .g .nvim_tree_disable_default_keybindings ~= 0
115
- end
116
- end ,
117
-
118
- nvim_tree_hide_dotfiles = function (o )
119
- utils .table_create_missing (o , " filters" )
120
- if o .filters .dotfiles == nil then
121
- o .filters .dotfiles = vim .g .nvim_tree_hide_dotfiles ~= 0
122
- end
123
- end ,
124
-
125
- nvim_tree_ignore = function (o )
126
- utils .table_create_missing (o , " filters" )
127
- if o .filters .custom == nil then
128
- o .filters .custom = vim .g .nvim_tree_ignore
129
- end
130
- end ,
131
-
132
- nvim_tree_gitignore = function (o )
133
- utils .table_create_missing (o , " git" )
134
- if o .git .ignore == nil then
135
- o .git .ignore = vim .g .nvim_tree_gitignore ~= 0
136
- end
137
- end ,
138
-
139
- nvim_tree_disable_window_picker = function (o )
140
- utils .table_create_missing (o , " actions.open_file.window_picker" )
141
- if o .actions .open_file .window_picker .enable == nil then
142
- o .actions .open_file .window_picker .enable = vim .g .nvim_tree_disable_window_picker == 0
143
- end
144
- end ,
145
-
146
- nvim_tree_window_picker_chars = function (o )
147
- utils .table_create_missing (o , " actions.open_file.window_picker" )
148
- if o .actions .open_file .window_picker .chars == nil then
149
- o .actions .open_file .window_picker .chars = vim .g .nvim_tree_window_picker_chars
150
- end
151
- end ,
152
-
153
- nvim_tree_window_picker_exclude = function (o )
154
- utils .table_create_missing (o , " actions.open_file.window_picker" )
155
- if o .actions .open_file .window_picker .exclude == nil then
156
- o .actions .open_file .window_picker .exclude = vim .g .nvim_tree_window_picker_exclude
157
- end
158
- end ,
159
-
160
- nvim_tree_quit_on_open = function (o )
161
- utils .table_create_missing (o , " actions.open_file" )
162
- if o .actions .open_file .quit_on_open == nil then
163
- o .actions .open_file .quit_on_open = vim .g .nvim_tree_quit_on_open == 1
164
- end
165
- end ,
166
-
167
- nvim_tree_change_dir_global = function (o )
168
- utils .table_create_missing (o , " actions.change_dir" )
169
- if o .actions .change_dir .global == nil then
170
- o .actions .change_dir .global = vim .g .nvim_tree_change_dir_global == 1
171
- end
172
- end ,
173
-
174
- nvim_tree_indent_markers = function (o )
175
- utils .table_create_missing (o , " renderer.indent_markers" )
176
- if o .renderer .indent_markers .enable == nil then
177
- o .renderer .indent_markers .enable = vim .g .nvim_tree_indent_markers == 1
178
- end
179
- end ,
180
-
181
- nvim_tree_add_trailing = function (o )
182
- utils .table_create_missing (o , " renderer" )
183
- if o .renderer .add_trailing == nil then
184
- o .renderer .add_trailing = vim .g .nvim_tree_add_trailing == 1
185
- end
186
- end ,
187
-
188
- nvim_tree_highlight_opened_files = function (o )
189
- utils .table_create_missing (o , " renderer" )
190
- if o .renderer .highlight_opened_files == nil then
191
- if vim .g .nvim_tree_highlight_opened_files == 1 then
192
- o .renderer .highlight_opened_files = " icon"
193
- elseif vim .g .nvim_tree_highlight_opened_files == 2 then
194
- o .renderer .highlight_opened_files = " name"
195
- elseif vim .g .nvim_tree_highlight_opened_files == 3 then
196
- o .renderer .highlight_opened_files = " all"
197
- end
198
- end
199
- end ,
200
-
201
- nvim_tree_root_folder_modifier = function (o )
202
- utils .table_create_missing (o , " renderer" )
203
- if o .renderer .root_folder_modifier == nil then
204
- o .renderer .root_folder_modifier = vim .g .nvim_tree_root_folder_modifier
205
- end
206
- end ,
207
-
208
- nvim_tree_special_files = function (o )
209
- utils .table_create_missing (o , " renderer" )
210
- if o .renderer .special_files == nil and type (vim .g .nvim_tree_special_files ) == " table" then
211
- o .renderer .special_files = {}
212
- for k , v in pairs (vim .g .nvim_tree_special_files ) do
213
- if v ~= 0 then
214
- table.insert (o .renderer .special_files , k )
215
- end
216
- end
217
- end
218
- end ,
219
-
220
- nvim_tree_icon_padding = function (o )
221
- utils .table_create_missing (o , " renderer.icons" )
222
- if o .renderer .icons .padding == nil then
223
- o .renderer .icons .padding = vim .g .nvim_tree_icon_padding
224
- end
225
- end ,
226
-
227
- nvim_tree_symlink_arrow = function (o )
228
- utils .table_create_missing (o , " renderer.icons" )
229
- if o .renderer .icons .symlink_arrow == nil then
230
- o .renderer .icons .symlink_arrow = vim .g .nvim_tree_symlink_arrow
231
- end
232
- end ,
233
-
234
- nvim_tree_show_icons = function (o )
235
- utils .table_create_missing (o , " renderer.icons" )
236
- if o .renderer .icons .show == nil and type (vim .g .nvim_tree_show_icons ) == " table" then
237
- o .renderer .icons .show = {}
238
- o .renderer .icons .show .file = vim .g .nvim_tree_show_icons .files == 1
239
- o .renderer .icons .show .folder = vim .g .nvim_tree_show_icons .folders == 1
240
- o .renderer .icons .show .folder_arrow = vim .g .nvim_tree_show_icons .folder_arrows == 1
241
- o .renderer .icons .show .git = vim .g .nvim_tree_show_icons .git == 1
242
- end
243
- end ,
244
-
245
- nvim_tree_icons = function (o )
246
- utils .table_create_missing (o , " renderer.icons" )
247
- if o .renderer .icons .glyphs == nil and type (vim .g .nvim_tree_icons ) == " table" then
248
- o .renderer .icons .glyphs = vim .g .nvim_tree_icons
249
- end
250
- end ,
251
-
252
- nvim_tree_git_hl = function (o )
253
- utils .table_create_missing (o , " renderer" )
254
- if o .renderer .highlight_git == nil then
255
- o .renderer .highlight_git = vim .g .nvim_tree_git_hl == 1
256
- end
257
- end ,
258
-
259
- nvim_tree_group_empty = function (o )
260
- utils .table_create_missing (o , " renderer" )
261
- if o .renderer .group_empty == nil then
262
- o .renderer .group_empty = vim .g .nvim_tree_group_empty == 1
263
- end
264
- end ,
265
-
266
- nvim_tree_respect_buf_cwd = function (o )
267
- if o .respect_buf_cwd == nil then
268
- o .respect_buf_cwd = vim .g .nvim_tree_respect_buf_cwd == 1
269
- end
270
- end ,
271
- }
272
-
273
6
local function refactored (opts )
274
7
-- mapping actions
275
8
if opts .view and opts .view .mappings and opts .view .mappings .list then
@@ -311,18 +44,6 @@ local function removed(opts)
311
44
end
312
45
313
46
function M .migrate_legacy_options (opts )
314
- -- g: options
315
- local msg
316
- for g , m in pairs (g_migrations ) do
317
- if vim .fn .exists (" g:" .. g ) ~= 0 then
318
- m (opts )
319
- msg = (msg and msg .. " , " or " Following options were moved to setup, see bit.ly/3vIpEOJ: " ) .. g
320
- end
321
- end
322
- if msg then
323
- notify .warn (msg )
324
- end
325
-
326
47
-- silently move
327
48
refactored (opts )
328
49
0 commit comments