Skip to content

Commit f7a20fa

Browse files
committed
fix(files): correct refresh() refs that were missed in the refactor from #69
1 parent bdd0bd2 commit f7a20fa

File tree

3 files changed

+131
-22
lines changed

3 files changed

+131
-22
lines changed

lua/neo-tree/defaults.lua

Lines changed: 111 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
local highlights = require("neo-tree.ui.highlights")
2+
13
local config = {
24
-- The default_source is the one used when calling require('neo-tree').show()
35
-- without a source argument.
@@ -41,6 +43,114 @@ local config = {
4143
-- print(args.source, " moved to ", args.destination)
4244
-- end
4345
-- },
44-
--}
46+
--},
47+
filesystem = {
48+
follow_current_file = false, -- This will find and focus the file in the
49+
-- active buffer every time the current file is changed while the tree is open.
50+
use_libuv_file_watcher = false, -- This will use the OS level file watchers
51+
-- to detect changes instead of relying on nvim autocmd events.
52+
window = {
53+
-- see https://github.com/MunifTanjim/nui.nvim/tree/main/lua/nui/popup
54+
-- for possible options. These can also be functions that return these
55+
-- options.
56+
position = "left", -- left, right, float
57+
width = 40, -- applies to left and right positions
58+
-- settings that apply to float position only
59+
popup = {
60+
size = {
61+
height = "80%",
62+
width = "50%",
63+
},
64+
position = "50%", -- 50% means center it
65+
-- you can also specify border here, if you want a different setting from
66+
-- the global popup_border_style.
67+
},
68+
-- Mappings for tree window. See https://github.com/nvim-neo-tree/neo-tree.nvim/blob/main/lua/neo-tree/sources/filesystem/commands.lua
69+
-- for built-in commands. You can also create your own commands by
70+
-- providing a function instead of a string. See the built-in
71+
-- commands for examples.
72+
mappings = {
73+
["<2-LeftMouse>"] = "open",
74+
["<cr>"] = "open",
75+
["S"] = "open_split",
76+
["s"] = "open_vsplit",
77+
["C"] = "close_node",
78+
["z"] = "close_all_nodes",
79+
["<bs>"] = "navigate_up",
80+
["."] = "set_root",
81+
["H"] = "toggle_hidden",
82+
["I"] = "toggle_gitignore",
83+
["R"] = "refresh",
84+
["/"] = "filter_as_you_type",
85+
["f"] = "filter_on_submit",
86+
["<C-x>"] = "clear_filter",
87+
["a"] = "add",
88+
["d"] = "delete",
89+
["r"] = "rename",
90+
["c"] = "copy_to_clipboard",
91+
["x"] = "cut_to_clipboard",
92+
["p"] = "paste_from_clipboard",
93+
},
94+
},
95+
--find_command = "fd",
96+
search_limit = 50, -- max number of search results when using filters
97+
filters = {
98+
show_hidden = false,
99+
respect_gitignore = true,
100+
},
101+
bind_to_cwd = true, -- true creates a 2-way binding between vim's cwd and neo-tree's root
102+
-- This section provides the renderers that will be used to render the tree.
103+
-- The first level is the node type.
104+
-- For each node type, you can specify a list of components to render.
105+
-- Components are rendered in the order they are specified.
106+
-- The first field in each component is the name of the function to call.
107+
-- The rest of the fields are passed to the function as the "config" argument.
108+
renderers = {
109+
directory = {
110+
{
111+
"icon",
112+
folder_closed = "",
113+
folder_open = "",
114+
padding = " ",
115+
},
116+
{ "current_filter" },
117+
{ "name" },
118+
-- {
119+
-- "symlink_target",
120+
-- highlight = highlights.SYMBOLIC_LINK_TARGET,
121+
-- },
122+
{
123+
"clipboard",
124+
highlight = highlights.DIM_TEXT,
125+
},
126+
{ "diagnostics", errors_only = true },
127+
--{ "git_status" },
128+
},
129+
file = {
130+
{
131+
"icon",
132+
default = "*",
133+
padding = " ",
134+
},
135+
{
136+
"name",
137+
use_git_status_colors = true,
138+
},
139+
-- {
140+
-- "symlink_target",
141+
-- highlight = highlights.SYMBOLIC_LINK_TARGET,
142+
-- },
143+
{
144+
"clipboard",
145+
highlight = highlights.DIM_TEXT,
146+
},
147+
{ "diagnostics" },
148+
{
149+
"git_status",
150+
highlight = highlights.DIM_TEXT,
151+
},
152+
},
153+
},
154+
},
45155
}
46156
return config

lua/neo-tree/sources/buffers/commands.lua

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,41 @@ local manager = require("neo-tree.sources.manager")
88

99
local M = {}
1010

11+
local refresh = utils.wrap(manager.refresh, "git_status")
12+
local redraw = utils.wrap(manager.redraw, "git_status")
13+
1114
M.add = function(state)
12-
cc.add(state, M.refresh)
15+
cc.add(state, refresh)
1316
end
1417

1518
M.buffer_delete = function(state)
1619
local node = state.tree:get_node()
1720
if node then
1821
vim.api.nvim_buf_delete(node.extra.bufnr, { force = false, unload = false })
19-
M.refresh()
22+
refresh()
2023
end
2124
end
2225
M.close_node = cc.close_node
2326

2427
---Marks node as copied, so that it can be pasted somewhere else.
2528
M.copy_to_clipboard = function(state)
26-
cc.copy_to_clipboard(state, utils.wrap(manager.redraw, "buffers"))
29+
cc.copy_to_clipboard(state, redraw)
2730
end
2831

2932
---Marks node as cut, so that it can be pasted (moved) somewhere else.
3033
M.cut_to_clipboard = function(state)
31-
cc.cut_to_clipboard(state, utils.wrap(manager.redraw, "buffers"))
34+
cc.cut_to_clipboard(state, redraw)
3235
end
3336

3437
M.show_debug_info = cc.show_debug_info
3538

3639
---Pastes all items from the clipboard to the current directory.
3740
M.paste_from_clipboard = function(state)
38-
cc.paste_from_clipboard(state, M.refresh)
41+
cc.paste_from_clipboard(state, refresh)
3942
end
4043

4144
M.delete = function(state)
42-
cc.delete(state, M.refresh)
45+
cc.delete(state, refresh)
4346
end
4447

4548
---Navigate up one level.
@@ -52,10 +55,10 @@ M.open = cc.open
5255
M.open_split = cc.open_split
5356
M.open_vsplit = cc.open_vsplit
5457

55-
M.refresh = utils.wrap(manager.refresh, "buffers")
58+
M.refresh = refresh
5659

5760
M.rename = function(state)
58-
cc.rename(state, M.refresh)
61+
cc.rename(state, refresh)
5962
end
6063

6164
M.set_root = function(state)

lua/neo-tree/sources/filesystem/commands.lua

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ local filter = require("neo-tree.sources.filesystem.lib.filter")
77
local manager = require("neo-tree.sources.manager")
88

99
local M = {}
10+
local refresh = utils.wrap(manager.refresh, "filesystem")
11+
local redraw = utils.wrap(manager.redraw, "filesystem")
1012

1113
M.add = function(state)
1214
cc.add(state, fs.show_new_children)
@@ -21,12 +23,12 @@ M.close_node = cc.close_node
2123

2224
---Marks node as copied, so that it can be pasted somewhere else.
2325
M.copy_to_clipboard = function(state)
24-
cc.copy_to_clipboard(state, fs.redraw)
26+
cc.copy_to_clipboard(state, redraw)
2527
end
2628

2729
---Marks node as cut, so that it can be pasted (moved) somewhere else.
2830
M.cut_to_clipboard = function(state)
29-
cc.cut_to_clipboard(state, fs.redraw)
31+
cc.cut_to_clipboard(state, redraw)
3032
end
3133

3234
M.show_debug_info = cc.show_debug_info
@@ -37,7 +39,7 @@ M.paste_from_clipboard = function(state)
3739
end
3840

3941
M.delete = function(state)
40-
cc.delete(state, fs.refresh)
42+
cc.delete(state, refresh)
4143
end
4244

4345
---Shows the filter input, which will filter the tree.
@@ -74,16 +76,10 @@ M.open_vsplit = function(state)
7476
cc.open_vsplit(state, fs.toggle_directory)
7577
end
7678

77-
M.refresh = utils.wrap(manager.refresh, "filesystem")
79+
M.refresh = refresh
7880

7981
M.rename = function(state)
80-
cc.rename(state, function(original_path, new_path)
81-
-- This is where you would do something like fix references to the file
82-
-- with an LSP server.
83-
-- <YOUR CODE HERE>
84-
-- Don't forget to call fs.refresh() after you're done.
85-
M.refresh()
86-
end)
82+
cc.rename(state, refresh)
8783
end
8884

8985
M.set_root = function(state)
@@ -100,13 +96,13 @@ end
10096
---Toggles whether hidden files are shown or not.
10197
M.toggle_hidden = function(state)
10298
state.filters.show_hidden = not state.filters.show_hidden
103-
M.refresh()
99+
refresh()
104100
end
105101

106102
---Toggles whether the tree is filtered by gitignore or not.
107103
M.toggle_gitignore = function(state)
108104
state.filters.respect_gitignore = not state.filters.respect_gitignore
109-
M.refresh()
105+
refresh()
110106
end
111107

112108
return M

0 commit comments

Comments
 (0)