Skip to content

Commit 9929ed0

Browse files
feat: add tabnew command for opening via a new tab. (#233)
1 parent 4f3feb4 commit 9929ed0

File tree

7 files changed

+19
-2
lines changed

7 files changed

+19
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ use {
128128
["<cr>"] = "open",
129129
["S"] = "open_split",
130130
["s"] = "open_vsplit",
131+
["t"] = "open_tabnew",
131132
["C"] = "close_node",
132133
["<bs>"] = "navigate_up",
133134
["."] = "set_root",

doc/neo-tree.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ Note: The "selected" item is the line the cursor is currently on.
156156

157157
S = open_split: Same as open, but opens in a new horizontal split.
158158

159-
s = open_vsplit: Same as open, but opens in a vertical split
159+
s = open_vsplit: Same as open, but opens in a vertical split.
160+
161+
t = open_tabnew: Same as open, but opens in a new tab.
160162

161163
<bs> = navigate_up: Moves the root directory up one level.
162164

@@ -743,7 +745,7 @@ Fired after a file (or folder) has been moved. The arg is a table containing
743745
Fired just before a file is opened. The arg is a table containing the `state`
744746
of the source being used, the `path` of the file to be opened, and `open_cmd`,
745747
which is the open command that was requested. `open_cmd` will be either |edit|,
746-
|split|, or |vsplit|. This function should return a table with a property called
748+
|split|, |vsplit|, |tabnew|. This function should return a table with a property called
747749
`handled` which is true if the file open operation was handled, or false if it
748750
was not. If `{ handled = true }` is not returned, the file will be opened using
749751
the built-in logic.

lua/neo-tree/defaults.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ local config = {
180180
["<cr>"] = "open",
181181
["S"] = "open_split",
182182
["s"] = "open_vsplit",
183+
["t"] = "open_tabnew",
183184
["C"] = "close_node",
184185
["z"] = "close_all_nodes",
185186
["R"] = "refresh",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ end
6969
M.open = cc.open
7070
M.open_split = cc.open_split
7171
M.open_vsplit = cc.open_vsplit
72+
M.open_tabnew = cc.open_tabnew
7273

7374
M.refresh = refresh
7475

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,14 @@ M.open_vsplit = function(state, toggle_directory)
235235
open_with_cmd(state, "vsplit", toggle_directory)
236236
end
237237

238+
---Open file or directory in a new tab
239+
---@param state table The state of the source
240+
---@param toggle_directory function The function to call to toggle a directory
241+
---open/closed
242+
M.open_tabnew = function (state, toggle_directory)
243+
open_with_cmd(state, "tabnew", toggle_directory)
244+
end
245+
238246
M.rename = function(state, callback)
239247
local tree = state.tree
240248
local node = tree:get_node()

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ end
9494
M.open_vsplit = function(state)
9595
cc.open_vsplit(state, utils.wrap(fs.toggle_directory, state))
9696
end
97+
M.open_tabnew = function (state)
98+
cc.open_tabnew(state, utils.wrap(fs.toggle_directory, state))
99+
end
97100

98101
M.refresh = refresh
99102

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ end
134134
M.open = cc.open
135135
M.open_split = cc.open_split
136136
M.open_vsplit = cc.open_vsplit
137+
M.open_tabnew = cc.open_tabnew
137138

138139
M.refresh = refresh
139140

0 commit comments

Comments
 (0)