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 <alex@courtis.org>
This commit is contained in:
Eric Haynes 2022-12-10 22:40:38 -05:00 committed by GitHub
parent b9aaf805a1
commit 7177d95ac0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 19 deletions

View File

@ -171,7 +171,6 @@ Subsequent calls to setup will replace the previous configuration.
> >
require("nvim-tree").setup { -- BEGIN_DEFAULT_OPTS require("nvim-tree").setup { -- BEGIN_DEFAULT_OPTS
auto_reload_on_write = true, auto_reload_on_write = true,
create_in_closed_folder = false,
disable_netrw = false, disable_netrw = false,
hijack_cursor = false, hijack_cursor = false,
hijack_netrw = true, hijack_netrw = true,
@ -436,11 +435,6 @@ in some scenarios (eg using vim startify).
Reloads the explorer every time a buffer is written to. Reloads the explorer every time a buffer is written to.
Type: `boolean`, Default: `true` Type: `boolean`, Default: `true`
*nvim-tree.create_in_closed_folder*
Creating a file when the cursor is on a closed folder will set the
path to be inside the closed folder, otherwise the parent folder.
Type: `boolean`, Default: `false`
*nvim-tree.sort_by* *nvim-tree.sort_by*
Changes how files within the same directory are sorted. Changes how files within the same directory are sorted.
Can be one of `name`, `case_sensitive`, `modification_time`, `extension` or a Can be one of `name`, `case_sensitive`, `modification_time`, `extension` or a

View File

@ -464,7 +464,6 @@ end
local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
auto_reload_on_write = true, auto_reload_on_write = true,
create_in_closed_folder = false,
disable_netrw = false, disable_netrw = false,
hijack_cursor = false, hijack_cursor = false,
hijack_netrw = true, hijack_netrw = true,

View File

@ -161,11 +161,8 @@ local function do_paste(node, action_type, action_fn)
return return
end end
local is_dir = stats and stats.type == "directory" local is_dir = stats and stats.type == "directory"
if not is_dir then if not is_dir then
destination = vim.fn.fnamemodify(destination, ":p:h") destination = vim.fn.fnamemodify(destination, ":p:h")
elseif not node.open then
destination = vim.fn.fnamemodify(destination, ":p:h:h")
end end
for _, _node in ipairs(clip) do for _, _node in ipairs(clip) do

View File

@ -42,8 +42,7 @@ local function get_num_nodes(iter)
end end
local function get_containing_folder(node) local function get_containing_folder(node)
local is_open = M.create_in_closed_folder or node.open if node.nodes ~= nil then
if node.nodes ~= nil and is_open then
return utils.path_add_trailing(node.absolute_path) return utils.path_add_trailing(node.absolute_path)
end end
local node_name_size = #(node.name or "") local node_name_size = #(node.name or "")
@ -113,7 +112,6 @@ function M.fn(node)
end end
function M.setup(opts) function M.setup(opts)
M.create_in_closed_folder = opts.create_in_closed_folder
M.enable_reload = not opts.filesystem_watchers.enable M.enable_reload = not opts.filesystem_watchers.enable
end end

View File

@ -268,12 +268,6 @@ local g_migrations = {
o.respect_buf_cwd = vim.g.nvim_tree_respect_buf_cwd == 1 o.respect_buf_cwd = vim.g.nvim_tree_respect_buf_cwd == 1
end end
end, end,
nvim_tree_create_in_closed_folder = function(o)
if o.create_in_closed_folder == nil then
o.create_in_closed_folder = vim.g.nvim_tree_create_in_closed_folder == 1
end
end,
} }
local function refactored(opts) local function refactored(opts)
@ -309,6 +303,11 @@ local function removed(opts)
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" 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"
opts.focus_empty_on_setup = nil opts.focus_empty_on_setup = nil
end end
if opts.create_in_closed_folder then
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."
end
opts.create_in_closed_folder = nil
end end
function M.migrate_legacy_options(opts) function M.migrate_legacy_options(opts)