1 -- Neovim plugin to manage the file system and other tree like structures.
2 -- https://github.com/nvim-neo-tree/neo-tree.nvim
3 vim.api.nvim_create_autocmd("BufEnter", {
4 group = vim.api.nvim_create_augroup("load_neo_tree", {}),
5 desc = "Loads neo-tree when opening a buffer",
6 callback = function(args)
7 -- ExplanationNote: uncomment to load neo-tree only when opening a directory
8 --local stats = vim.uv.fs_stat(args.file)
9 --if not stats or stats.type ~= "directory" then
23 require("neo-tree").setup({
24 add_blank_line_at_top = false,
25 auto_clean_after_session_restore = false,
26 sort_case_insensitive = true,
27 sort_function = function(a, b)
28 -- ExplanationNote: sort only using the path, not the type.
29 return a.path < b.path
32 follow_current_file = { enabled = true, leave_dirs_open = true },
33 group_empty_dirs = false,
36 -- https://github.com/nvim-neo-tree/neo-tree.nvim/wiki/FAQ#bdelete-makes-the-tree-spans-the-whole-window-how-do-i-prevent-it
37 close_if_last_window = true,
38 default_source = "buffers",
39 enable_cursor_hijack = true,
40 enable_diagnostics = true,
41 enable_git_status = true,
42 enable_modified_markers = true,
43 enable_opened_markers = true,
44 enable_refresh_on_write = true,
46 filtered_items = { visible = true },
47 group_empty_dirs = false,
48 hijack_netrw_behavior = "open_default",
49 use_libuv_file_watcher = true,
51 git_status_async = false,
52 hide_root_node = false,
55 open_files_do_not_replace_types = { "terminal", "Trouble", "qf", "edgy" },
56 open_files_in_last_window = true,
57 retain_hidden_root_indent = false,
62 -- ["i"] = "move_cursor_up",
63 ["I"] = function(state)
64 local tree = state.tree
65 local node = tree:get_node()
66 local siblings = tree:get_nodes(node:get_parent_id())
67 local renderer = require("neo-tree.ui.renderer")
68 renderer.focus_node(state, siblings[1]:get_id())
70 ["K"] = function(state)
71 local tree = state.tree
72 local node = tree:get_node()
73 local siblings = tree:get_nodes(node:get_parent_id())
74 local renderer = require("neo-tree.ui.renderer")
75 renderer.focus_node(state, siblings[#siblings]:get_id())