Skip to content

Commit 78d2616

Browse files
authored
feat!: remove deprecated user commands (#1055)
BREAKING CHANGE: All `NeoTree*` commands have been removed, use `Neotree <args>` instead.
1 parent e9f3266 commit 78d2616

File tree

4 files changed

+3
-461
lines changed

4 files changed

+3
-461
lines changed

README.md

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ so we can fix it.
4545

4646
#### Minimal Example for Packer:
4747
```lua
48-
-- Unless you are still migrating, remove the deprecated commands from v1.x
49-
vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]])
50-
5148
use {
5249
"nvim-neo-tree/neo-tree.nvim",
5350
branch = "v2.x",
@@ -103,9 +100,6 @@ use {
103100
}
104101
},
105102
config = function ()
106-
-- Unless you are still migrating, remove the deprecated commands from v1.x
107-
vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]])
108-
109103
-- If you want icons for diagnostic errors, you'll need to define them somewhere:
110104
vim.fn.sign_define("DiagnosticSignError",
111105
{text = "", texthl = "DiagnosticSignError"})
@@ -364,56 +358,6 @@ into a buffer after installing Neo-tree by running:
364358
:lua require("neo-tree").paste_default_config()
365359
```
366360

367-
#### Configuration for Nerd Fonts v3 Users
368-
369-
The following configuration should fix broken icons if you are using Nerd Fonts v3:
370-
371-
```lua
372-
require("neo-tree").setup({
373-
default_component_configs = {
374-
icon = {
375-
folder_empty = "󰜌",
376-
folder_empty_open = "󰜌",
377-
},
378-
git_status = {
379-
symbols = {
380-
renamed = "󰁕",
381-
unstaged = "󰄱",
382-
},
383-
},
384-
},
385-
document_symbols = {
386-
kinds = {
387-
File = { icon = "󰈙", hl = "Tag" },
388-
Namespace = { icon = "󰌗", hl = "Include" },
389-
Package = { icon = "󰏖", hl = "Label" },
390-
Class = { icon = "󰌗", hl = "Include" },
391-
Property = { icon = "󰆧", hl = "@property" },
392-
Enum = { icon = "󰒻", hl = "@number" },
393-
Function = { icon = "󰊕", hl = "Function" },
394-
String = { icon = "󰀬", hl = "String" },
395-
Number = { icon = "󰎠", hl = "Number" },
396-
Array = { icon = "󰅪", hl = "Type" },
397-
Object = { icon = "󰅩", hl = "Type" },
398-
Key = { icon = "󰌋", hl = "" },
399-
Struct = { icon = "󰌗", hl = "Type" },
400-
Operator = { icon = "󰆕", hl = "Operator" },
401-
TypeParameter = { icon = "󰊄", hl = "Type" },
402-
StaticMethod = { icon = '󰠄 ', hl = 'Function' },
403-
}
404-
},
405-
-- Add this section only if you've configured source selector.
406-
source_selector = {
407-
sources = {
408-
{ source = "filesystem", display_name = " 󰉓 Files " },
409-
{ source = "buffers", display_name = " 󰈚 Buffers " },
410-
{ source = "git_status", display_name = " 󰊢 Git " },
411-
},
412-
},
413-
-- Other options ...
414-
})
415-
```
416-
417361
## The `:Neotree` Command
418362

419363
The single `:Neotree` command accepts a range of arguments that give you full
@@ -745,7 +689,7 @@ add any features you can think of through existing hooks in the setup function.
745689

746690
As of v1.30, a breaking change is defined as anything that _changes_ existing:
747691

748-
- vim commands (`:NeoTreeShow`, `:NeoTreeReveal`, etc)
692+
- vim commands (`:Neotree`)
749693
- configuration options that are passed into the `setup()` function
750694
- `NeoTree*` highlight groups
751695
- lua functions exported in the following modules that are not prefixed with `_`:

lua/neo-tree.lua

Lines changed: 0 additions & 176 deletions
Original file line numberDiff line numberDiff line change
@@ -1,165 +1,14 @@
11
local vim = vim
22
local utils = require("neo-tree.utils")
3-
local renderer = require("neo-tree.ui.renderer")
43
local log = require("neo-tree.log")
5-
local manager = require("neo-tree.sources.manager")
6-
local setup = require("neo-tree.setup")
7-
8-
-- If you add a new source, you need to add it to the sources table.
9-
-- Each source should have a defaults module that contains the default values
10-
-- for the source config, and a setup function that takes that config.
11-
local sources = {
12-
"filesystem",
13-
"buffers",
14-
"git_status",
15-
}
16-
174
local M = {}
185

19-
local check_source = function(source_name)
20-
if not utils.truthy(source_name) then
21-
source_name = M.config.default_source
22-
end
23-
local success, result = pcall(require, "neo-tree.sources." .. source_name)
24-
if not success then
25-
error("Source " .. source_name .. " could not be loaded: ", result)
26-
end
27-
return source_name
28-
end
29-
30-
local get_position = function(source_name)
31-
local pos = utils.get_value(M, "config." .. source_name .. ".window.position", "left", false)
32-
return pos
33-
end
34-
356
M.ensure_config = function()
367
if not M.config then
378
M.setup({ log_to_file = false }, true)
389
end
3910
end
4011

41-
--DEPRECATED in v2.x
42-
M.close_all_except = function(source_name)
43-
-- this entire function is faulty now that position can be overriden at runtime
44-
source_name = check_source(source_name)
45-
local target_pos = get_position(source_name)
46-
for _, name in ipairs(sources) do
47-
if name ~= source_name then
48-
local pos = utils.get_value(M, "config." .. name .. ".window.position", "left", false)
49-
if pos == target_pos then
50-
manager.close(name)
51-
end
52-
end
53-
end
54-
renderer.close_all_floating_windows()
55-
end
56-
57-
--DEPRECATED in v2.x
58-
M.close = manager.close
59-
60-
--DEPRECATED in v2.x, use manager.close_all()
61-
M.close_all = function(at_position)
62-
renderer.close_all_floating_windows()
63-
if type(at_position) == "string" and at_position > "" then
64-
for _, name in ipairs(sources) do
65-
local pos = get_position(name)
66-
if pos == at_position then
67-
manager.close(name)
68-
end
69-
end
70-
else
71-
for _, name in ipairs(sources) do
72-
manager.close(name)
73-
end
74-
end
75-
end
76-
77-
--DEPRECATED in v2.x, use commands.execute()
78-
M.float = function(source_name, toggle_if_open)
79-
M.ensure_config()
80-
source_name = check_source(source_name)
81-
if toggle_if_open then
82-
if renderer.close_floating_window(source_name) then
83-
-- It was open, and now it's not.
84-
return
85-
end
86-
end
87-
renderer.close_all_floating_windows()
88-
manager.close(source_name) -- in case this source is open in a sidebar
89-
manager.float(source_name)
90-
end
91-
92-
--DEPRECATED in v2.x, use commands.execute()
93-
M.focus = function(source_name, close_others, toggle_if_open)
94-
M.ensure_config()
95-
source_name = check_source(source_name)
96-
if get_position(source_name) == "current" then
97-
M.show_in_split(source_name, toggle_if_open)
98-
return
99-
end
100-
101-
if toggle_if_open then
102-
if manager.close(source_name) then
103-
-- It was open, and now it's not.
104-
return
105-
end
106-
end
107-
if close_others == nil then
108-
close_others = true
109-
end
110-
if close_others then
111-
M.close_all_except(source_name)
112-
end
113-
manager.focus(source_name)
114-
end
115-
116-
--DEPRECATED in v2.x, use commands.execute()
117-
M.reveal_current_file = function(source_name, toggle_if_open, force_cwd)
118-
M.ensure_config()
119-
source_name = check_source(source_name)
120-
if get_position(source_name) == "current" then
121-
M.reveal_in_split(source_name, toggle_if_open)
122-
return
123-
end
124-
if toggle_if_open then
125-
if manager.close(source_name) then
126-
-- It was open, and now it's not.
127-
return
128-
end
129-
end
130-
manager.reveal_current_file(source_name, nil, force_cwd)
131-
end
132-
133-
--DEPRECATED in v2.x, use commands.execute()
134-
M.reveal_in_split = function(source_name, toggle_if_open)
135-
M.ensure_config()
136-
source_name = check_source(source_name)
137-
if toggle_if_open then
138-
local state = manager.get_state(source_name, nil, vim.api.nvim_get_current_win())
139-
if renderer.close(state) then
140-
-- It was open, and now it's not.
141-
return
142-
end
143-
end
144-
--TODO: if we are currently in a sidebar, don't replace it with a split style
145-
manager.reveal_in_split(source_name)
146-
end
147-
148-
--DEPRECATED in v2.x, use commands.execute()
149-
M.show_in_split = function(source_name, toggle_if_open)
150-
M.ensure_config()
151-
source_name = check_source(source_name)
152-
if toggle_if_open then
153-
local state = manager.get_state(source_name, nil, vim.api.nvim_get_current_win())
154-
if renderer.close(state) then
155-
-- It was open, and now it's not.
156-
return
157-
end
158-
end
159-
--TODO: if we are currently in a sidebar, don't replace it with a split style
160-
manager.show_in_split(source_name)
161-
end
162-
16312
M.get_prior_window = function(ignore_filetypes)
16413
ignore_filetypes = ignore_filetypes or {}
16514
local ignore = utils.list_to_dict(ignore_filetypes)
@@ -212,31 +61,6 @@ M.paste_default_config = function()
21261
end)
21362
end
21463

215-
M.buffer_enter_event = setup.buffer_enter_event
216-
M.win_enter_event = setup.win_enter_event
217-
218-
--DEPRECATED in v2.x
219-
--BREAKING CHANGE: Removed the do_not_focus and close_others options in 2.0
220-
--M.show = function(source_name, do_not_focus, close_others, toggle_if_open)
221-
M.show = function(source_name, toggle_if_open)
222-
M.ensure_config()
223-
source_name = check_source(source_name)
224-
if get_position(source_name) == "current" then
225-
M.show_in_split(source_name, toggle_if_open)
226-
return
227-
end
228-
229-
if toggle_if_open then
230-
if manager.close(source_name) then
231-
-- It was open, and now it's not.
232-
return
233-
end
234-
end
235-
236-
M.close_all_except(source_name)
237-
manager.show(source_name)
238-
end
239-
24064
M.set_log_level = function(level)
24165
log.set_level(level)
24266
end

plugin/neo-tree.vim

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,8 @@
11
if exists('g:loaded_neo_tree')
22
finish
33
endif
4-
let g:loaded_neo_tree = 1
5-
6-
if !exists('g:neo_tree_remove_legacy_commands')
7-
command! -nargs=? NeoTreeClose lua require("neo-tree").close_all("<args>")
8-
command! -nargs=? NeoTreeFloat lua require("neo-tree").float("<args>")
9-
command! -nargs=? NeoTreeFocus lua require("neo-tree").focus("<args>")
10-
command! -nargs=? NeoTreeShow lua require("neo-tree").show("<args>", true)
11-
command! -bang NeoTreeReveal lua require("neo-tree").reveal_current_file("filesystem", false, "<bang>" == "!")
12-
command! NeoTreeRevealInSplit lua require("neo-tree").reveal_in_split("filesystem", false)
13-
command! NeoTreeShowInSplit lua require("neo-tree").show_in_split("filesystem", false)
14-
15-
command! -nargs=? NeoTreeFloatToggle lua require("neo-tree").float("<args>", true)
16-
command! -nargs=? NeoTreeFocusToggle lua require("neo-tree").focus("<args>", true, true)
17-
command! -nargs=? NeoTreeShowToggle lua require("neo-tree").show("<args>", true, true, true)
18-
command! -bang NeoTreeRevealToggle lua require("neo-tree").reveal_current_file("filesystem", true, "<bang>" == "!")
19-
command! NeoTreeRevealInSplitToggle lua require("neo-tree").reveal_in_split("filesystem", true)
20-
command! NeoTreeShowInSplitToggle lua require("neo-tree").show_in_split("filesystem", true)
21-
22-
command! NeoTreePasteConfig lua require("neo-tree").paste_default_config()
23-
command! -nargs=? NeoTreeSetLogLevel lua require("neo-tree").set_log_level("<args>")
24-
command! NeoTreeLogs lua require("neo-tree").show_logs()
25-
endif
264

275
command! -nargs=* -complete=custom,v:lua.require'neo-tree.command'.complete_args
286
\ Neotree lua require("neo-tree.command")._command(<f-args>)
7+
8+
let g:loaded_neo_tree = 1

0 commit comments

Comments
 (0)