Skip to content

Commit 7177d95

Browse files
feat: paste and create always target closed folder, remove create_in_closed_folder (#1802)
* Fix default for file creation in closed directories * Make paste in closed directories consistent with create * doc: clarify create_in_closed_folder * Remove create_in_closed_folder option * doc: clarify create_in_closed_folder removal message (whoops) Co-authored-by: Alexander Courtis <[email protected]>
1 parent b9aaf80 commit 7177d95

File tree

5 files changed

+6
-19
lines changed

5 files changed

+6
-19
lines changed

doc/nvim-tree-lua.txt

-6
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ Subsequent calls to setup will replace the previous configuration.
171171
>
172172
require("nvim-tree").setup { -- BEGIN_DEFAULT_OPTS
173173
auto_reload_on_write = true,
174-
create_in_closed_folder = false,
175174
disable_netrw = false,
176175
hijack_cursor = false,
177176
hijack_netrw = true,
@@ -436,11 +435,6 @@ in some scenarios (eg using vim startify).
436435
Reloads the explorer every time a buffer is written to.
437436
Type: `boolean`, Default: `true`
438437

439-
*nvim-tree.create_in_closed_folder*
440-
Creating a file when the cursor is on a closed folder will set the
441-
path to be inside the closed folder, otherwise the parent folder.
442-
Type: `boolean`, Default: `false`
443-
444438
*nvim-tree.sort_by*
445439
Changes how files within the same directory are sorted.
446440
Can be one of `name`, `case_sensitive`, `modification_time`, `extension` or a

lua/nvim-tree.lua

-1
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,6 @@ end
464464

465465
local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
466466
auto_reload_on_write = true,
467-
create_in_closed_folder = false,
468467
disable_netrw = false,
469468
hijack_cursor = false,
470469
hijack_netrw = true,

lua/nvim-tree/actions/fs/copy-paste.lua

-3
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,8 @@ local function do_paste(node, action_type, action_fn)
161161
return
162162
end
163163
local is_dir = stats and stats.type == "directory"
164-
165164
if not is_dir then
166165
destination = vim.fn.fnamemodify(destination, ":p:h")
167-
elseif not node.open then
168-
destination = vim.fn.fnamemodify(destination, ":p:h:h")
169166
end
170167

171168
for _, _node in ipairs(clip) do

lua/nvim-tree/actions/fs/create-file.lua

+1-3
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ local function get_num_nodes(iter)
4242
end
4343

4444
local function get_containing_folder(node)
45-
local is_open = M.create_in_closed_folder or node.open
46-
if node.nodes ~= nil and is_open then
45+
if node.nodes ~= nil then
4746
return utils.path_add_trailing(node.absolute_path)
4847
end
4948
local node_name_size = #(node.name or "")
@@ -113,7 +112,6 @@ function M.fn(node)
113112
end
114113

115114
function M.setup(opts)
116-
M.create_in_closed_folder = opts.create_in_closed_folder
117115
M.enable_reload = not opts.filesystem_watchers.enable
118116
end
119117

lua/nvim-tree/legacy.lua

+5-6
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,6 @@ local g_migrations = {
268268
o.respect_buf_cwd = vim.g.nvim_tree_respect_buf_cwd == 1
269269
end
270270
end,
271-
272-
nvim_tree_create_in_closed_folder = function(o)
273-
if o.create_in_closed_folder == nil then
274-
o.create_in_closed_folder = vim.g.nvim_tree_create_in_closed_folder == 1
275-
end
276-
end,
277271
}
278272

279273
local function refactored(opts)
@@ -309,6 +303,11 @@ local function removed(opts)
309303
notify.warn "focus_empty_on_setup has been removed and will be replaced by a new startup configuration. Please remove this option. See https://bit.ly/3yJch2T"
310304
opts.focus_empty_on_setup = nil
311305
end
306+
307+
if opts.create_in_closed_folder then
308+
notify.warn "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."
309+
end
310+
opts.create_in_closed_folder = nil
312311
end
313312

314313
function M.migrate_legacy_options(opts)

0 commit comments

Comments
 (0)