Skip to content

Commit de4c01a

Browse files
committed
feat: adding neotree
1 parent d891f4a commit de4c01a

File tree

2 files changed

+306
-1
lines changed

2 files changed

+306
-1
lines changed

init.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ require('lazy').setup({
7474
-- Detect tabstop and shiftwidth automatically
7575
'tpope/vim-sleuth',
7676

77+
-- Snippets
78+
'SirVer/ultisnips',
79+
'honza/vim-snippets',
80+
'natebosch/dartlang-snippets',
81+
7782
-- NOTE: This is where your plugins related to LSP can be installed.
7883
-- The configuration is done below. Search for lspconfig to find it below.
7984
{
@@ -221,7 +226,7 @@ require('lazy').setup({
221226
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
222227
--
223228
-- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins
224-
-- { import = 'custom.plugins' },
229+
{ import = 'custom.plugins' },
225230
}, {})
226231

227232
-- [[ Setting options ]]

lua/custom/plugins/filetree.lua

Lines changed: 300 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,300 @@
1+
-- Unless you are still migrating, remove the deprecated commands from v1.x
2+
vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]])
3+
4+
return {
5+
"nvim-neo-tree/neo-tree.nvim",
6+
version = "*",
7+
dependencies = {
8+
"nvim-lua/plenary.nvim",
9+
"nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
10+
"MunifTanjim/nui.nvim",
11+
{
12+
's1n7ax/nvim-window-picker',
13+
version = '2.*',
14+
config = function()
15+
require 'window-picker'.setup({
16+
filter_rules = {
17+
include_current_win = false,
18+
autoselect_one = true,
19+
-- filter using buffer options
20+
bo = {
21+
-- if the file type is one of following, the window will be ignored
22+
filetype = { 'neo-tree', "neo-tree-popup", "notify" },
23+
-- if the buffer type is one of following, the window will be ignored
24+
buftype = { 'terminal', "quickfix" },
25+
},
26+
},
27+
})
28+
end,
29+
},
30+
},
31+
config = function ()
32+
require('neo-tree').setup {
33+
close_if_last_window = false, -- Close Neo-tree if it is the last window left in the tab
34+
popup_border_style = "rounded",
35+
enable_git_status = true,
36+
enable_diagnostics = true,
37+
enable_normal_mode_for_inputs = false, -- Enable normal mode for input dialogs.
38+
open_files_do_not_replace_types = { "terminal", "trouble", "qf" }, -- when opening files, do not use windows containing these filetypes or buftypes
39+
sort_case_insensitive = false, -- used when sorting files and directories in the tree
40+
sort_function = nil , -- use a custom function for sorting files and directories in the tree
41+
-- sort_function = function (a,b)
42+
-- if a.type == b.type then
43+
-- return a.path > b.path
44+
-- else
45+
-- return a.type > b.type
46+
-- end
47+
-- end , -- this sorts files and directories descendantly
48+
default_component_configs = {
49+
container = {
50+
enable_character_fade = true
51+
},
52+
indent = {
53+
indent_size = 2,
54+
padding = 1, -- extra padding on left hand side
55+
-- indent guides
56+
with_markers = true,
57+
indent_marker = "",
58+
last_indent_marker = "",
59+
highlight = "NeoTreeIndentMarker",
60+
-- expander config, needed for nesting files
61+
with_expanders = nil, -- if nil and file nesting is enabled, will enable expanders
62+
expander_collapsed = "",
63+
expander_expanded = "",
64+
expander_highlight = "NeoTreeExpander",
65+
},
66+
icon = {
67+
folder_closed = "",
68+
folder_open = "",
69+
folder_empty = "󰜌",
70+
-- The next two settings are only a fallback, if you use nvim-web-devicons and configure default icons there
71+
-- then these will never be used.
72+
default = "*",
73+
highlight = "NeoTreeFileIcon"
74+
},
75+
modified = {
76+
symbol = "[+]",
77+
highlight = "NeoTreeModified",
78+
},
79+
name = {
80+
trailing_slash = false,
81+
use_git_status_colors = true,
82+
highlight = "NeoTreeFileName",
83+
},
84+
git_status = {
85+
symbols = {
86+
-- Change type
87+
added = "", -- or "✚", but this is redundant info if you use git_status_colors on the name
88+
modified = "", -- or "", but this is redundant info if you use git_status_colors on the name
89+
deleted = "",-- this can only be used in the git_status source
90+
renamed = "󰁕",-- this can only be used in the git_status source
91+
-- Status type
92+
untracked = "",
93+
ignored = "",
94+
unstaged = "󰄱",
95+
staged = "",
96+
conflict = "",
97+
}
98+
},
99+
-- If you don't want to use these columns, you can set `enabled = false` for each of them individually
100+
file_size = {
101+
enabled = true,
102+
required_width = 64, -- min width of window required to show this column
103+
},
104+
type = {
105+
enabled = true,
106+
required_width = 122, -- min width of window required to show this column
107+
},
108+
last_modified = {
109+
enabled = true,
110+
required_width = 88, -- min width of window required to show this column
111+
},
112+
created = {
113+
enabled = true,
114+
required_width = 110, -- min width of window required to show this column
115+
},
116+
symlink_target = {
117+
enabled = false,
118+
},
119+
},
120+
-- A list of functions, each representing a global custom command
121+
-- that will be available in all sources (if not overridden in `opts[source_name].commands`)
122+
-- see `:h neo-tree-custom-commands-global`
123+
commands = {},
124+
window = {
125+
position = "left",
126+
width = 40,
127+
mapping_options = {
128+
noremap = true,
129+
nowait = true,
130+
},
131+
mappings = {
132+
["<space>"] = {
133+
"toggle_node",
134+
nowait = false, -- disable `nowait` if you have existing combos starting with this char that you want to use
135+
},
136+
["<2-LeftMouse>"] = "open",
137+
["<cr>"] = "open",
138+
["<esc>"] = "cancel", -- close preview or floating neo-tree window
139+
["P"] = { "toggle_preview", config = { use_float = true } },
140+
["l"] = "focus_preview",
141+
["S"] = "open_split",
142+
["s"] = "open_vsplit",
143+
-- ["S"] = "split_with_window_picker",
144+
-- ["s"] = "vsplit_with_window_picker",
145+
["t"] = "open_tabnew",
146+
-- ["<cr>"] = "open_drop",
147+
-- ["t"] = "open_tab_drop",
148+
["w"] = "open_with_window_picker",
149+
--["P"] = "toggle_preview", -- enter preview mode, which shows the current node without focusing
150+
["C"] = "close_node",
151+
-- ['C'] = 'close_all_subnodes',
152+
["z"] = "close_all_nodes",
153+
--["Z"] = "expand_all_nodes",
154+
["a"] = {
155+
"add",
156+
-- this command supports BASH style brace expansion ("x{a,b,c}" -> xa,xb,xc). see `:h neo-tree-file-actions` for details
157+
-- some commands may take optional config options, see `:h neo-tree-mappings` for details
158+
config = {
159+
show_path = "none" -- "none", "relative", "absolute"
160+
}
161+
},
162+
["A"] = "add_directory", -- also accepts the optional config.show_path option like "add". this also supports BASH style brace expansion.
163+
["d"] = "delete",
164+
["r"] = "rename",
165+
["y"] = "copy_to_clipboard",
166+
["x"] = "cut_to_clipboard",
167+
["p"] = "paste_from_clipboard",
168+
["c"] = "copy", -- takes text input for destination, also accepts the optional config.show_path option like "add":
169+
-- ["c"] = {
170+
-- "copy",
171+
-- config = {
172+
-- show_path = "none" -- "none", "relative", "absolute"
173+
-- }
174+
--}
175+
["m"] = "move", -- takes text input for destination, also accepts the optional config.show_path option like "add".
176+
["q"] = "close_window",
177+
["R"] = "refresh",
178+
["?"] = "show_help",
179+
["<"] = "prev_source",
180+
[">"] = "next_source",
181+
["i"] = "show_file_details",
182+
}
183+
},
184+
nesting_rules = {},
185+
filesystem = {
186+
filtered_items = {
187+
visible = false, -- when true, they will just be displayed differently than normal items
188+
hide_dotfiles = true,
189+
hide_gitignored = true,
190+
hide_hidden = true, -- only works on Windows for hidden files/directories
191+
hide_by_name = {
192+
--"node_modules"
193+
},
194+
hide_by_pattern = { -- uses glob style patterns
195+
--"*.meta",
196+
--"*/src/*/tsconfig.json",
197+
},
198+
always_show = { -- remains visible even if other settings would normally hide it
199+
--".gitignored",
200+
},
201+
never_show = { -- remains hidden even if visible is toggled to true, this overrides always_show
202+
--".DS_Store",
203+
--"thumbs.db"
204+
},
205+
never_show_by_pattern = { -- uses glob style patterns
206+
--".null-ls_*",
207+
},
208+
},
209+
follow_current_file = {
210+
enabled = false, -- This will find and focus the file in the active buffer every time
211+
-- -- the current file is changed while the tree is open.
212+
leave_dirs_open = false, -- `false` closes auto expanded dirs, such as with `:Neotree reveal`
213+
},
214+
group_empty_dirs = false, -- when true, empty folders will be grouped together
215+
hijack_netrw_behavior = "open_default", -- netrw disabled, opening a directory opens neo-tree
216+
-- in whatever position is specified in window.position
217+
-- "open_current", -- netrw disabled, opening a directory opens within the
218+
-- window like netrw would, regardless of window.position
219+
-- "disabled", -- netrw left alone, neo-tree does not handle opening dirs
220+
use_libuv_file_watcher = false, -- This will use the OS level file watchers to detect changes
221+
-- instead of relying on nvim autocmd events.
222+
window = {
223+
mappings = {
224+
["<bs>"] = "navigate_up",
225+
["."] = "set_root",
226+
["H"] = "toggle_hidden",
227+
["/"] = "fuzzy_finder",
228+
["D"] = "fuzzy_finder_directory",
229+
["#"] = "fuzzy_sorter", -- fuzzy sorting using the fzy algorithm
230+
-- ["D"] = "fuzzy_sorter_directory",
231+
["f"] = "filter_on_submit",
232+
["<c-x>"] = "clear_filter",
233+
["[g"] = "prev_git_modified",
234+
["]g"] = "next_git_modified",
235+
["o"] = { "show_help", nowait=false, config = { title = "Order by", prefix_key = "o" }},
236+
["oc"] = { "order_by_created", nowait = false },
237+
["od"] = { "order_by_diagnostics", nowait = false },
238+
["og"] = { "order_by_git_status", nowait = false },
239+
["om"] = { "order_by_modified", nowait = false },
240+
["on"] = { "order_by_name", nowait = false },
241+
["os"] = { "order_by_size", nowait = false },
242+
["ot"] = { "order_by_type", nowait = false },
243+
},
244+
fuzzy_finder_mappings = { -- define keymaps for filter popup window in fuzzy_finder_mode
245+
["<down>"] = "move_cursor_down",
246+
["<C-n>"] = "move_cursor_down",
247+
["<up>"] = "move_cursor_up",
248+
["<C-p>"] = "move_cursor_up",
249+
},
250+
},
251+
252+
commands = {} -- Add a custom command or override a global one using the same function name
253+
},
254+
buffers = {
255+
follow_current_file = {
256+
enabled = true, -- This will find and focus the file in the active buffer every time
257+
-- -- the current file is changed while the tree is open.
258+
leave_dirs_open = false, -- `false` closes auto expanded dirs, such as with `:Neotree reveal`
259+
},
260+
group_empty_dirs = true, -- when true, empty folders will be grouped together
261+
show_unloaded = true,
262+
window = {
263+
mappings = {
264+
["bd"] = "buffer_delete",
265+
["<bs>"] = "navigate_up",
266+
["."] = "set_root",
267+
["o"] = { "show_help", nowait=false, config = { title = "Order by", prefix_key = "o" }},
268+
["oc"] = { "order_by_created", nowait = false },
269+
["od"] = { "order_by_diagnostics", nowait = false },
270+
["om"] = { "order_by_modified", nowait = false },
271+
["on"] = { "order_by_name", nowait = false },
272+
["os"] = { "order_by_size", nowait = false },
273+
["ot"] = { "order_by_type", nowait = false },
274+
}
275+
},
276+
},
277+
git_status = {
278+
window = {
279+
position = "float",
280+
mappings = {
281+
["A"] = "git_add_all",
282+
["gu"] = "git_unstage_file",
283+
["ga"] = "git_add_file",
284+
["gr"] = "git_revert_file",
285+
["gc"] = "git_commit",
286+
["gp"] = "git_push",
287+
["gg"] = "git_commit_and_push",
288+
["o"] = { "show_help", nowait=false, config = { title = "Order by", prefix_key = "o" }},
289+
["oc"] = { "order_by_created", nowait = false },
290+
["od"] = { "order_by_diagnostics", nowait = false },
291+
["om"] = { "order_by_modified", nowait = false },
292+
["on"] = { "order_by_name", nowait = false },
293+
["os"] = { "order_by_size", nowait = false },
294+
["ot"] = { "order_by_type", nowait = false },
295+
}
296+
}
297+
}
298+
}
299+
end,
300+
}

0 commit comments

Comments
 (0)