Skip to content

Commit

Permalink
feat: restore neo-tree for presentation purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
kmoschcau committed Mar 3, 2025
1 parent e57efcb commit d31e196
Show file tree
Hide file tree
Showing 2 changed files with 318 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lazy-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
"mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" },
"mini.nvim": { "branch": "main", "commit": "307221b90376b68fc7e007e9315836370e9efb8f" },
"muren.nvim": { "branch": "main", "commit": "fa18f2df80a52afd201da062d1af0e80c8d1988e" },
"neo-tree.nvim": { "branch": "v3.x", "commit": "e96fd85bf18bc345dab332b345098fa5460dffac" },
"neoconf.nvim": { "branch": "main", "commit": "de6ee524f90aafd158d15f2f945cf8fbd48fc31a" },
"nui.nvim": { "branch": "main", "commit": "53e907ffe5eedebdca1cd503b00aa8692068ca46" },
"nvim-autopairs": { "branch": "master", "commit": "68f0e5c3dab23261a945272032ee6700af86227a" },
"nvim-cmp": { "branch": "main", "commit": "b555203ce4bd7ff6192e759af3362f9d217e8c89" },
"nvim-config-local": { "branch": "main", "commit": "990f3e35e0fba8fb83012d7e85f9a6a77de7f87f" },
Expand All @@ -57,6 +59,7 @@
"nvim-treesitter-endwise": { "branch": "master", "commit": "cb718aab7fa66e43187674e875713097492a6618" },
"nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" },
"nvim-window-picker": { "branch": "main", "commit": "6382540b2ae5de6c793d4aa2e3fe6dbb518505ec" },
"oil-git-status.nvim": { "branch": "main", "commit": "293021c42f9d725981616c26c05964c7e5a88a08" },
"oil.nvim": { "branch": "master", "commit": "975a77cce3c8cb742bc1b3629f4328f5ca977dad" },
"omnisharp-extended-lsp.nvim": { "branch": "main", "commit": "ec1a2431f8872f650a85ed71c24f0715df2e49c2" },
Expand Down
315 changes: 315 additions & 0 deletions lua/plugin-management/plugins/neo-tree-nvim.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,315 @@
local symbols = require "symbols"

local function map_kinds()
local ret_val = {}

for key, value in pairs(symbols.types) do
ret_val[key] = { icon = value }
end

return ret_val
end

local function index_of(array, value)
for i, v in ipairs(array) do
if v == value then
return i
end
end
return nil
end

local function get_siblings(state, node)
local parent = state.tree:get_node(node:get_parent_id())
local siblings = parent:get_child_ids()
return siblings
end

-- selene: allow(mixed_table)
--- @type LazyPluginSpec
return {
"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
dependencies = {
"MunifTanjim/nui.nvim",
"echasnovski/mini.nvim",
"nvim-lua/plenary.nvim",
{
"s1n7ax/nvim-window-picker",
opts = {
autoselect_one = true,
include_current = true,
filter_rules = {
bo = {
filetype = { "neo-tree", "neo-tree-popup", "notify" },
buftype = { "terminal", "quickfix" },
},
},
},
},
},
keys = {
{
"<C-n>",
"<Cmd>Neotree toggle=true<CR>",
desc = "neo-tree: Toggle the window.",
silent = true,
},
},
opts = {
sources = {
"filesystem",
"buffers",
"git_status",
"document_symbols",
},
popup_border_style = "rounded",
default_component_configs = {
name = {
trailing_slash = true,
highlight_opened_files = true,
},
modified = {
symbol = symbols.files.modified,
},
git_status = {
symbols = vim.tbl_extend("error", symbols.git.lines, symbols.git.files),
},
},
nesting_rules = {
[".NET config"] = {
pattern = "^(.*)%.config$",
files = {
"%1.*.config",
},
},
[".NET appsettings.json"] = {
pattern = "^appsettings%.json$",
files = {
"appsettings.*.json",
},
},
["Angular components"] = {
pattern = "^(.*)%.component%.ts$",
files = {
"%1.component.css",
"%1.component.html",
"%1.component.less",
"%1.component.sass",
"%1.component.scss",
"%1.component.spec.ts",
},
},
["C Sharp"] = {
pattern = "^(.*)%.cs$",
files = {
"%1.Designer.cs",
"%1.designer.cs",
},
},
["Cascading Style Sheets"] = {
pattern = "^(.*)%.css$",
files = {
"%1.css.map",
"%1.min.css",
"%1.min.css.map",
},
},
["eXtensible Application Markup Language"] = {
pattern = "^(.*)%.xaml$",
files = {
"%1.xaml.cs",
},
},
["JavaScript"] = {
pattern = "^(.*)%.js$",
files = {
"%1.js.map",
"%1.min.js",
"%1.min.js.map",
"%1.spec.js",
"%1.test.js",
},
},
["JavaScript esModules"] = {
pattern = "^(.*)%.mjs$",
files = {
"%1.mjs.map",
"%1.min.mjs",
"%1.min.mjs.map",
"%1.spec.mjs",
"%1.test.mjs",
},
},
["Node package manifest"] = {
pattern = "^package%.json$",
files = {
"package-lock.json",
"yarn*",
},
},
["Razor components"] = {
pattern = "^(.*)%.razor$",
files = {
"%1.razor.cs",
"%1.razor.css",
"%1.razor.js",
},
},
["Razor pages"] = {
pattern = "^(.*)%.cshtml$",
files = {
"%1.cshtml.cs",
"%1.cshtml.js",
},
},
["Scalable Vector Graphics"] = {
pattern = "^(.*)%.svg$",
files = {
"%1.min.svg",
},
},
["TypeScript"] = {
pattern = "^(.*)%.ts$",
files = {
"%1.spec.ts",
"%1.test.ts",
},
},
},
window = {
mappings = {
["<C-h>"] = {
desc = "neo-tree: Go to parent",
function(state)
local node = state.tree:get_node()
require("neo-tree.ui.renderer").focus_node(
state,
node:get_parent_id()
)
end,
},
["<C-j>"] = {
desc = "neo-tree: Go to next sibling",
function(state)
local node = state.tree:get_node()
local siblings = get_siblings(state, node)
if not node.is_last_child then
local current_index = index_of(siblings, node.id)
local next_index = siblings[current_index + 1]
require("neo-tree.ui.renderer").focus_node(state, next_index)
end
end,
},
["<C-k>"] = {
desc = "neo-tree: Go to previous sibling",
function(state)
local node = state.tree:get_node()
local siblings = get_siblings(state, node)
local current_index = index_of(siblings, node.id)
if current_index > 1 then
local previous_index = siblings[current_index - 1]
require("neo-tree.ui.renderer").focus_node(state, previous_index)
end
end,
},
["<C-s>"] = "split_with_window_picker",
["<C-t>"] = "open_tabnew",
["<C-v>"] = "vsplit_with_window_picker",
["<CR>"] = "open",
["<Space>"] = { "toggle_node", nowait = true },
["[g"] = "none",
["]g"] = "none",
J = {
desc = "neo-tree: Go to last sibling",
function(state)
local node = state.tree:get_node()
local siblings = get_siblings(state, node)
require("neo-tree.ui.renderer").focus_node(
state,
siblings[#siblings]
)
end,
},
K = {
desc = "neo-tree: Go to first sibling",
function(state)
local node = state.tree:get_node()
local siblings = get_siblings(state, node)
require("neo-tree.ui.renderer").focus_node(state, siblings[1])
end,
},
S = "none",
o = "open_with_window_picker",
oc = "none",
od = "none",
og = "none",
om = "none",
on = "none",
os = "none",
ot = "none",
s = "none",
t = "none",
w = "none",
},
},
filesystem = {
group_empty_dirs = true,
hijack_netrw_behavior = "disabled",
commands = {
toggle_hidden = function(state)
-- might break in the future, as we are using internals
-- https://github.com/nvim-neo-tree/neo-tree.nvim/blob/main/lua/neo-tree/sources/filesystem/commands.lua#L230C8
state.filtered_items.visible = not state.filtered_items.visible
require("neo-tree.sources.filesystem")._navigate_internal(
state,
nil,
nil,
nil,
false
)
end,
},
window = {
mappings = {
["[c"] = "prev_git_modified",
["]c"] = "next_git_modified",
sc = "order_by_created",
sd = "order_by_diagnostics",
sg = "order_by_git_status",
sm = "order_by_modified",
sn = "order_by_name",
ss = "order_by_size",
st = "order_by_type",
},
},
},
buffers = {
window = {
mappings = {
sc = "order_by_created",
sd = "order_by_diagnostics",
sm = "order_by_modified",
sn = "order_by_name",
ss = "order_by_size",
st = "order_by_type",
},
},
},
git_status = {
window = {
mappings = {
sc = "order_by_created",
sd = "order_by_diagnostics",
sm = "order_by_modified",
sn = "order_by_name",
ss = "order_by_size",
st = "order_by_type",
},
},
},
document_symbols = {
kinds = map_kinds(),
},
},
}

0 comments on commit d31e196

Please sign in to comment.