Skip to content

Commit a73b92c

Browse files
authored
feat(buffers): add terminals_first option (#1162)
1 parent f71df9f commit a73b92c

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

lua/neo-tree/defaults.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ local config = {
538538
group_empty_dirs = true, -- when true, empty directories will be grouped together
539539
show_unloaded = false, -- When working with sessions, for example, restored but unfocused buffers
540540
-- are mark as "unloaded". Turn this on to view these unloaded buffer.
541+
terminals_first = false, -- when true, terminals will be listed before file buffers
541542
window = {
542543
mappings = {
543544
["<bs>"] = "navigate_up",

lua/neo-tree/sources/buffers/lib/items.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,11 @@ M.get_opened_buffers = function(state)
9494
search_pattern = state.search_pattern,
9595
}
9696
context.folders["Terminals"] = terminal_root
97-
root_folders[2] = terminal_root
97+
if state.terminals_first then
98+
table.insert(root_folders, 1, terminal_root)
99+
else
100+
table.insert(root_folders, terminal_root)
101+
end
98102
end
99103
state.default_expanded_nodes = {}
100104
for id, _ in pairs(context.folders) do

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,9 @@ M.icon = function(config, node, state)
279279
end
280280
elseif node.type == "file" or node.type == "terminal" then
281281
local success, web_devicons = pcall(require, "nvim-web-devicons")
282+
local name = node.type == "terminal" and "terminal" or node.name
282283
if success then
283-
local devicon, hl = web_devicons.get_icon(node.name)
284+
local devicon, hl = web_devicons.get_icon(name)
284285
icon = devicon or icon
285286
highlight = hl or highlight
286287
end

0 commit comments

Comments
 (0)