Skip to content

Commit e289495

Browse files
committed
Add defaults and descriptions
1 parent 608cdfb commit e289495

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

lua/neo-tree/defaults.lua

+8-4
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,9 @@ local config = {
299299
-- the global popup_border_style.
300300
},
301301
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).
302+
insert_as = "child", -- Affects how nodes get inserted into the tree during creation/pasting/moving of files if the node under the cursor is a directory:
303+
-- "child": Insert nodes as children of the directory under cursor.
304+
-- "sibling": Insert nodes as siblings of the directory under cursor.
302305
-- Mappings for tree window. See `:h neo-tree-mappings` for a list of built-in commands.
303306
-- You can also create your own commands by providing a function instead of a string.
304307
mapping_options = {
@@ -330,17 +333,18 @@ local config = {
330333
"add",
331334
-- some commands may take optional config options, see `:h neo-tree-mappings` for details
332335
config = {
333-
show_path = "none" -- "none", "relative", "absolute"
336+
show_path = "none", -- "none", "relative", "absolute"
337+
insert_as = "child" -- "child", "sibling" - Overrides the global `insert_as` config.
334338
}
335339
},
336-
["A"] = "add_directory", -- also accepts the config.show_path option.
340+
["A"] = "add_directory", -- also accepts the config.show_path and config.insert_as options.
337341
["d"] = "delete",
338342
["r"] = "rename",
339343
["y"] = "copy_to_clipboard",
340344
["x"] = "cut_to_clipboard",
341345
["p"] = "paste_from_clipboard",
342-
["c"] = "copy", -- takes text input for destination, also accepts the config.show_path option
343-
["m"] = "move", -- takes text input for destination, also accepts the config.show_path option
346+
["c"] = "copy", -- takes text input for destination, also accepts the config.show_path and config.insert_as options
347+
["m"] = "move", -- takes text input for destination, also accepts the config.show_path and config.insert_as options
344348
["e"] = "toggle_auto_expand_width",
345349
["q"] = "close_window",
346350
["?"] = "show_help",

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ local function get_folder_node(state, node)
2323
local use_parent_local = state.config.same_level
2424
local use_parent_global = require("neo-tree").config.window.same_level
2525
local use_parent
26+
local is_open_dir = node.type == "directory" and (node:is_expanded() or node.empty_expanded)
2627
if not use_parent_global then
2728
use_parent = use_parent_local
2829
else
2930
use_parent = use_parent_local ~= false
3031
end
31-
if use_parent then
32+
if use_parent and not is_open_dir then
3233
return tree:get_node(node:get_parent_id())
3334
end
3435

0 commit comments

Comments
 (0)