You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

205 lines
8.2 KiB

  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. -- If you want icons for diagnostic errors, you'll need to define them somewhere:
  4. vim.fn.sign_define("DiagnosticSignError",
  5. {text = "", texthl = "DiagnosticSignError"})
  6. vim.fn.sign_define("DiagnosticSignWarn",
  7. {text = "", texthl = "DiagnosticSignWarn"})
  8. vim.fn.sign_define("DiagnosticSignInfo",
  9. {text = "", texthl = "DiagnosticSignInfo"})
  10. vim.fn.sign_define("DiagnosticSignHint",
  11. {text = "", texthl = "DiagnosticSignHint"})
  12. -- NOTE: this is changed from v1.x, which used the old style of highlight groups
  13. -- in the form "LspDiagnosticsSignWarning"
  14. require("neo-tree").setup({
  15. close_if_last_window = false, -- Close Neo-tree if it is the last window left in the tab
  16. popup_border_style = "rounded",
  17. enable_git_status = true,
  18. enable_diagnostics = true,
  19. sort_case_insensitive = false, -- used when sorting files and directories in the tree
  20. sort_function = nil , -- use a custom function for sorting files and directories in the tree
  21. -- sort_function = function (a,b)
  22. -- if a.type == b.type then
  23. -- return a.path > b.path
  24. -- else
  25. -- return a.type > b.type
  26. -- end
  27. -- end , -- this sorts files and directories descendantly
  28. default_component_configs = {
  29. container = {
  30. enable_character_fade = true
  31. },
  32. indent = {
  33. indent_size = 2,
  34. padding = 1, -- extra padding on left hand side
  35. -- indent guides
  36. with_markers = true,
  37. indent_marker = "",
  38. last_indent_marker = "",
  39. highlight = "NeoTreeIndentMarker",
  40. -- expander config, needed for nesting files
  41. with_expanders = nil, -- if nil and file nesting is enabled, will enable expanders
  42. expander_collapsed = "",
  43. expander_expanded = "",
  44. expander_highlight = "NeoTreeExpander",
  45. },
  46. icon = {
  47. folder_closed = "",
  48. folder_open = "",
  49. folder_empty = "",
  50. -- The next two settings are only a fallback, if you use nvim-web-devicons and configure default icons there
  51. -- then these will never be used.
  52. default = "*",
  53. highlight = "NeoTreeFileIcon"
  54. },
  55. modified = {
  56. symbol = "[+]",
  57. highlight = "NeoTreeModified",
  58. },
  59. name = {
  60. trailing_slash = false,
  61. use_git_status_colors = true,
  62. highlight = "NeoTreeFileName",
  63. },
  64. git_status = {
  65. symbols = {
  66. -- Change type
  67. added = "", -- or "✚", but this is redundant info if you use git_status_colors on the name
  68. modified = "", -- or "", but this is redundant info if you use git_status_colors on the name
  69. deleted = "",-- this can only be used in the git_status source
  70. renamed = "",-- this can only be used in the git_status source
  71. -- Status type
  72. untracked = "",
  73. ignored = "",
  74. unstaged = "",
  75. staged = "",
  76. conflict = "",
  77. }
  78. },
  79. },
  80. window = {
  81. position = "left",
  82. width = 40,
  83. mapping_options = {
  84. noremap = true,
  85. nowait = true,
  86. },
  87. mappings = {
  88. ["<space>"] = {
  89. "toggle_node",
  90. nowait = false, -- disable `nowait` if you have existing combos starting with this char that you want to use
  91. },
  92. ["<2-LeftMouse>"] = "open",
  93. ["<cr>"] = "open",
  94. ["S"] = "open_split",
  95. ["s"] = "open_vsplit",
  96. -- ["S"] = "split_with_window_picker",
  97. -- ["s"] = "vsplit_with_window_picker",
  98. ["t"] = "open_tabnew",
  99. ["w"] = "open_with_window_picker",
  100. ["C"] = "close_node",
  101. ["z"] = "close_all_nodes",
  102. --["Z"] = "expand_all_nodes",
  103. ["a"] = {
  104. "add",
  105. -- some commands may take optional config options, see `:h neo-tree-mappings` for details
  106. config = {
  107. show_path = "none" -- "none", "relative", "absolute"
  108. }
  109. },
  110. ["A"] = "add_directory", -- also accepts the optional config.show_path option like "add".
  111. ["d"] = "delete",
  112. ["r"] = "rename",
  113. ["y"] = "copy_to_clipboard",
  114. ["x"] = "cut_to_clipboard",
  115. ["p"] = "paste_from_clipboard",
  116. ["c"] = "copy", -- takes text input for destination, also accepts the optional config.show_path option like "add":
  117. -- ["c"] = {
  118. -- "copy",
  119. -- config = {
  120. -- show_path = "none" -- "none", "relative", "absolute"
  121. -- }
  122. --}
  123. ["m"] = "move", -- takes text input for destination, also accepts the optional config.show_path option like "add".
  124. ["q"] = "close_window",
  125. ["R"] = "refresh",
  126. ["?"] = "show_help",
  127. ["<"] = "prev_source",
  128. [">"] = "next_source",
  129. }
  130. },
  131. nesting_rules = {},
  132. filesystem = {
  133. filtered_items = {
  134. visible = false, -- when true, they will just be displayed differently than normal items
  135. hide_dotfiles = true,
  136. hide_gitignored = true,
  137. hide_hidden = true, -- only works on Windows for hidden files/directories
  138. hide_by_name = {
  139. --"node_modules"
  140. },
  141. hide_by_pattern = { -- uses glob style patterns
  142. --"*.meta"
  143. },
  144. never_show = { -- remains hidden even if visible is toggled to true
  145. --".DS_Store",
  146. --"thumbs.db"
  147. },
  148. },
  149. follow_current_file = true, -- This will find and focus the file in the active buffer every
  150. -- time the current file is changed while the tree is open.
  151. group_empty_dirs = false, -- when true, empty folders will be grouped together
  152. hijack_netrw_behavior = "open_default", -- netrw disabled, opening a directory opens neo-tree
  153. -- in whatever position is specified in window.position
  154. -- "open_current", -- netrw disabled, opening a directory opens within the
  155. -- window like netrw would, regardless of window.position
  156. -- "disabled", -- netrw left alone, neo-tree does not handle opening dirs
  157. use_libuv_file_watcher = false, -- This will use the OS level file watchers to detect changes
  158. -- instead of relying on nvim autocmd events.
  159. window = {
  160. mappings = {
  161. ["<bs>"] = "navigate_up",
  162. ["."] = "set_root",
  163. ["H"] = "toggle_hidden",
  164. ["/"] = "fuzzy_finder",
  165. ["D"] = "fuzzy_finder_directory",
  166. ["f"] = "filter_on_submit",
  167. ["<c-x>"] = "clear_filter",
  168. ["[g"] = "prev_git_modified",
  169. ["]g"] = "next_git_modified",
  170. }
  171. }
  172. },
  173. buffers = {
  174. follow_current_file = true, -- This will find and focus the file in the active buffer every
  175. -- time the current file is changed while the tree is open.
  176. group_empty_dirs = true, -- when true, empty folders will be grouped together
  177. show_unloaded = true,
  178. window = {
  179. mappings = {
  180. ["bd"] = "buffer_delete",
  181. ["<bs>"] = "navigate_up",
  182. ["."] = "set_root",
  183. }
  184. },
  185. },
  186. git_status = {
  187. window = {
  188. position = "float",
  189. mappings = {
  190. ["A"] = "git_add_all",
  191. ["gu"] = "git_unstage_file",
  192. ["ga"] = "git_add_file",
  193. ["gr"] = "git_revert_file",
  194. ["gc"] = "git_commit",
  195. ["gp"] = "git_push",
  196. ["gg"] = "git_commit_and_push",
  197. }
  198. }
  199. }
  200. })
  201. vim.api.nvim_set_keymap('n', '<C-q>', '<Cmd>Neotree toggle<CR>', { noremap = true })