From 8f834903d91f15b28e9c13149cdf70ec1f98179b Mon Sep 17 00:00:00 2001 From: Eric Haynes Date: Sat, 3 Dec 2022 14:50:25 -0500 Subject: [PATCH 1/5] Fix default for file creation in closed directories --- doc/nvim-tree-lua.txt | 4 ++-- lua/nvim-tree.lua | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index f7eb96f6163..3ac4f3c5746 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -171,7 +171,7 @@ Subsequent calls to setup will replace the previous configuration. > require("nvim-tree").setup { -- BEGIN_DEFAULT_OPTS auto_reload_on_write = true, - create_in_closed_folder = false, + create_in_closed_folder = true, disable_netrw = false, hijack_cursor = false, hijack_netrw = true, @@ -437,7 +437,7 @@ Reloads the explorer every time a buffer is written to. *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` + Type: `boolean`, Default: `true` *nvim-tree.sort_by* Changes how files within the same directory are sorted. diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index 4992de68a53..0ff65442b49 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -447,7 +447,7 @@ end local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS auto_reload_on_write = true, - create_in_closed_folder = false, + create_in_closed_folder = true, disable_netrw = false, hijack_cursor = false, hijack_netrw = true, From 2ae211c07156ef90ad272bca3520c60510169c50 Mon Sep 17 00:00:00 2001 From: Eric Haynes Date: Sat, 3 Dec 2022 14:50:34 -0500 Subject: [PATCH 2/5] Make paste in closed directories consistent with create --- lua/nvim-tree/actions/fs/copy-paste.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/nvim-tree/actions/fs/copy-paste.lua b/lua/nvim-tree/actions/fs/copy-paste.lua index c5cd5e2acd3..554f967d456 100644 --- a/lua/nvim-tree/actions/fs/copy-paste.lua +++ b/lua/nvim-tree/actions/fs/copy-paste.lua @@ -160,10 +160,9 @@ local function do_paste(node, action_type, action_fn) return end local is_dir = stats and stats.type == "directory" - if not is_dir then destination = vim.fn.fnamemodify(destination, ":p:h") - elseif not node.open then + elseif not (M.create_in_closed_folder or node.open) then destination = vim.fn.fnamemodify(destination, ":p:h:h") end @@ -253,6 +252,7 @@ end function M.setup(opts) M.use_system_clipboard = opts.actions.use_system_clipboard M.enable_reload = not opts.filesystem_watchers.enable + M.create_in_closed_folder = opts.create_in_closed_folder end return M From bec9a39c1ddf5f110e03526ef141b05a30230439 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sun, 4 Dec 2022 13:22:10 +1100 Subject: [PATCH 3/5] doc: clarify create_in_closed_folder --- doc/nvim-tree-lua.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 3ac4f3c5746..9e3a4c70f61 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -435,7 +435,7 @@ Reloads the explorer every time a buffer is written to. Type: `boolean`, Default: `true` *nvim-tree.create_in_closed_folder* -Creating a file when the cursor is on a closed folder will set the +Creating or pasting 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: `true` From 342cf6b42cad28431635f7f80b270e164f9e5ef2 Mon Sep 17 00:00:00 2001 From: Eric Haynes Date: Sat, 10 Dec 2022 20:54:19 -0500 Subject: [PATCH 4/5] Remove create_in_closed_folder option --- doc/nvim-tree-lua.txt | 6 ------ lua/nvim-tree.lua | 1 - lua/nvim-tree/actions/fs/copy-paste.lua | 3 --- lua/nvim-tree/actions/fs/create-file.lua | 4 +--- lua/nvim-tree/legacy.lua | 11 +++++------ 5 files changed, 6 insertions(+), 19 deletions(-) diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 9e3a4c70f61..be32bce8885 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -171,7 +171,6 @@ Subsequent calls to setup will replace the previous configuration. > require("nvim-tree").setup { -- BEGIN_DEFAULT_OPTS auto_reload_on_write = true, - create_in_closed_folder = true, disable_netrw = false, hijack_cursor = false, hijack_netrw = true, @@ -434,11 +433,6 @@ in some scenarios (eg using vim startify). Reloads the explorer every time a buffer is written to. Type: `boolean`, Default: `true` -*nvim-tree.create_in_closed_folder* -Creating or pasting 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: `true` - *nvim-tree.sort_by* Changes how files within the same directory are sorted. Can be one of `name`, `case_sensitive`, `modification_time`, `extension` or a diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index 0ff65442b49..efb0fb172e4 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -447,7 +447,6 @@ end local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS auto_reload_on_write = true, - create_in_closed_folder = true, disable_netrw = false, hijack_cursor = false, hijack_netrw = true, diff --git a/lua/nvim-tree/actions/fs/copy-paste.lua b/lua/nvim-tree/actions/fs/copy-paste.lua index 554f967d456..05ef581d9f4 100644 --- a/lua/nvim-tree/actions/fs/copy-paste.lua +++ b/lua/nvim-tree/actions/fs/copy-paste.lua @@ -162,8 +162,6 @@ local function do_paste(node, action_type, action_fn) local is_dir = stats and stats.type == "directory" if not is_dir then destination = vim.fn.fnamemodify(destination, ":p:h") - elseif not (M.create_in_closed_folder or node.open) then - destination = vim.fn.fnamemodify(destination, ":p:h:h") end for _, _node in ipairs(clip) do @@ -252,7 +250,6 @@ end function M.setup(opts) M.use_system_clipboard = opts.actions.use_system_clipboard M.enable_reload = not opts.filesystem_watchers.enable - M.create_in_closed_folder = opts.create_in_closed_folder end return M diff --git a/lua/nvim-tree/actions/fs/create-file.lua b/lua/nvim-tree/actions/fs/create-file.lua index 35ec267d77d..c970eeddab5 100644 --- a/lua/nvim-tree/actions/fs/create-file.lua +++ b/lua/nvim-tree/actions/fs/create-file.lua @@ -42,8 +42,7 @@ local function get_num_nodes(iter) end local function get_containing_folder(node) - local is_open = M.create_in_closed_folder or node.open - if node.nodes ~= nil and is_open then + if node.nodes ~= nil then return utils.path_add_trailing(node.absolute_path) end local node_name_size = #(node.name or "") @@ -113,7 +112,6 @@ function M.fn(node) end function M.setup(opts) - M.create_in_closed_folder = opts.create_in_closed_folder M.enable_reload = not opts.filesystem_watchers.enable end diff --git a/lua/nvim-tree/legacy.lua b/lua/nvim-tree/legacy.lua index caead4d5996..c5a65758fde 100644 --- a/lua/nvim-tree/legacy.lua +++ b/lua/nvim-tree/legacy.lua @@ -268,12 +268,6 @@ local g_migrations = { o.respect_buf_cwd = vim.g.nvim_tree_respect_buf_cwd == 1 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) @@ -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" opts.focus_empty_on_setup = nil end + + if opts.create_in_closed_folder then + notify.warn "create_in_closed_folder has been removed. Please use api.fs.create to add a file under your desired node." + end + opts.create_in_closed_folder = nil end function M.migrate_legacy_options(opts) From 64fce50dcb5446522620163fc561766e2864364d Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sun, 11 Dec 2022 14:33:31 +1100 Subject: [PATCH 5/5] doc: clarify create_in_closed_folder removal message (whoops) --- lua/nvim-tree/legacy.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/nvim-tree/legacy.lua b/lua/nvim-tree/legacy.lua index c5a65758fde..50aef3231a3 100644 --- a/lua/nvim-tree/legacy.lua +++ b/lua/nvim-tree/legacy.lua @@ -305,7 +305,7 @@ local function removed(opts) end if opts.create_in_closed_folder then - notify.warn "create_in_closed_folder has been removed. Please use api.fs.create to add a file under your desired node." + 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