Skip to content

Commit 11870a6

Browse files
committed
feat: add same_level config option
1 parent d9cec26 commit 11870a6

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lua/neo-tree/defaults.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ local config = {
296296
-- you can also specify border here, if you want a different setting from
297297
-- the global popup_border_style.
298298
},
299+
same_level = false, -- Create and paste/move files/directories on the same level as the directory under cursor (as opposed to within the directory under cursor).
299300
-- Mappings for tree window. See `:h neo-tree-mappings` for a list of built-in commands.
300301
-- You can also create your own commands by providing a function instead of a string.
301302
mapping_options = {

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ local function get_folder_node(tree, node)
1919
if not node then
2020
node = tree:get_node()
2121
end
22+
local use_parent = require("neo-tree").config.window.same_level
23+
if use_parent then
24+
return tree:get_node(node:get_parent_id())
25+
end
26+
2227
if node.type == "directory" then
2328
return node
2429
end
@@ -367,8 +372,9 @@ M.paste_from_clipboard = function(state, callback)
367372

368373
paste_complete = function(source, destination)
369374
if callback then
375+
local same_level = require("neo-tree").config.window.same_level
370376
-- open the folder so the user can see the new files
371-
local node = state.tree:get_node(folder)
377+
local node = same_level and state.tree:get_node() or state.tree:get_node(folder)
372378
if not node then
373379
log.warn("Could not find node for " .. folder)
374380
end

0 commit comments

Comments
 (0)