Skip to content

Commit 2a5d529

Browse files
authored
feat: option to set path destination to parent folder when cursor is on a closed folder while creating files (#628)
1 parent 1edebb7 commit 2a5d529

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ let g:nvim_tree_disable_window_picker = 1 "0 by default, will disable the window
9292
let g:nvim_tree_icon_padding = ' ' "one space by default, used for rendering the space between the icon and the filename. Use with caution, it could break rendering if you set an empty string depending on your font.
9393
let g:nvim_tree_symlink_arrow = ' >> ' " defaults to ' ➛ '. used as a separator between symlinks' source and target.
9494
let g:nvim_tree_respect_buf_cwd = 1 "0 by default, will change cwd of nvim-tree to that of new buffer's when opening nvim-tree.
95+
let g:nvim_tree_create_in_closed_folder = 0 "1 by default, When creating files, sets the path of a file when cursor is on a closed folder to the parent folder when 0, and inside the folder when 1.
9596
let g:nvim_tree_refresh_wait = 500 "1000 by default, control how often the tree can be refreshed, 1000 means the tree can be refresh once per 1000ms.
9697
let g:nvim_tree_window_picker_exclude = {
9798
\ 'filetype': [

doc/nvim-tree-lua.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,12 @@ Defaults to ' ➛ '. Used as a separator between symlinks' source and target.
373373
Can be 0 or 1. 0 by default.
374374
Will change cwd of nvim-tree to that of new buffer's when opening nvim-tree.
375375

376+
|g:nvim_tree_create_in_closed_folder| *g:nvim_tree_create_in_closed_folder*
377+
378+
Can be 0 or 1. 1 by default.
379+
Creating a file when the cursor is on a closed folder will set the
380+
path to be inside the closed folder when 1, and on the parent folder when 0.
381+
376382
==============================================================================
377383
INFORMATIONS *nvim-tree-info*
378384

lua/nvim-tree/fs.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ function M.create(node)
5757
}
5858
end
5959

60+
local node_is_open = vim.g.nvim_tree_create_in_closed_folder == 1 or node.open
61+
6062
local add_into
61-
if node.entries ~= nil then
63+
if node.entries ~= nil and node_is_open then
6264
add_into = utils.path_add_trailing(node.absolute_path)
6365
else
6466
add_into = node.absolute_path:sub(0, -(#node.name + 1))

0 commit comments

Comments
 (0)