init.lua 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. --[[ "
  2. --let g:nvim_tree_auto_ignore_ft = 'startify' "empty by default, don't auto open tree on specific filetypes.
  3. let g:nvim_tree_hide_dotfiles = 1 "0 by default, this option hides files and folders starting with a dot `.`
  4. let g:nvim_tree_git_hl = 1 "0 by default, will enable file highlight for git attributes (can be used without the icons).
  5. " let g:nvim_tree_tab_open = 1 "0 by default, will open the tree when entering a new tab and the tree was previously open
  6. " let g:nvim_tree_width_allow_resize = 1 "0 by default, will not resize the tree when opening a file
  7. let g:nvim_tree_show_icons = {
  8. \ 'git': 1,
  9. \ 'folders': 1,
  10. \ 'files': 1,
  11. \ }
  12. "If 0, do not show the icons for one of 'git' 'folder' and 'files'
  13. "1 by default, notice that if 'files' is 1, it will only display
  14. "if nvim-web-devicons is installed and on your runtimepath ]] -- vim.g.nvim_tree_ignore = [ '.git', 'node_modules', '.cache' ] "empty by default
  15. vim.g.nvim_tree_disable_netrw = 1 -- moved to lv-globals
  16. vim.g.nvim_tree_hijack_netrw = 1 --"1 by default, prevents netrw from automatically opening when opening directories (but lets you keep its other utilities)
  17. vim.g.nvim_tree_hide_dotfiles = 1 -- 0 by default, this option hides files and folders starting with a dot `.`
  18. vim.g.nvim_tree_indent_markers = 1 -- "0 by default, this option shows indent markers when folders are open
  19. vim.g.nvim_tree_follow = 1 -- "0 by default, this option allows the cursor to be updated when entering a buffer
  20. vim.g.nvim_tree_auto_close = O.auto_close_tree -- 0 by default, closes the tree when it's the last window
  21. vim.g.nvim_tree_auto_ignore_ft = 'startify' --empty by default, don't auto open tree on specific filetypes.
  22. vim.g.nvim_tree_quit_on_open = 0 -- this doesn't play well with barbar
  23. local tree_cb = require'nvim-tree.config'.nvim_tree_callback
  24. vim.g.nvim_tree_bindings = {
  25. -- ["<CR>"] = ":YourVimFunction()<cr>",
  26. -- ["u"] = ":lua require'some_module'.some_function()<cr>",
  27. -- default mappings
  28. ["<CR>"] = tree_cb("edit"),
  29. ["o"] = tree_cb("edit"),
  30. ["l"] = tree_cb("edit"),
  31. ["<2-LeftMouse>"] = tree_cb("edit"),
  32. ["<2-RightMouse>"] = tree_cb("cd"),
  33. ["<C-]>"] = tree_cb("cd"),
  34. ["v"] = tree_cb("vsplit"),
  35. ["s"] = tree_cb("split"),
  36. ["<C-t>"] = tree_cb("tabnew"),
  37. ["<"] = tree_cb("prev_sibling"),
  38. [">"] = tree_cb("next_sibling"),
  39. ["<BS>"] = tree_cb("close_node"),
  40. ["h"] = tree_cb("close_node"),
  41. ["<S-CR>"] = tree_cb("close_node"),
  42. ["<Tab>"] = tree_cb("preview"),
  43. ["I"] = tree_cb("toggle_ignored"),
  44. ["H"] = tree_cb("toggle_dotfiles"),
  45. ["R"] = tree_cb("refresh"),
  46. ["a"] = tree_cb("create"),
  47. ["d"] = tree_cb("remove"),
  48. ["r"] = tree_cb("rename"),
  49. ["<C-r>"] = tree_cb("full_rename"),
  50. ["x"] = tree_cb("cut"),
  51. ["c"] = tree_cb("copy"),
  52. ["p"] = tree_cb("paste"),
  53. ["[c"] = tree_cb("prev_git_item"),
  54. ["]c"] = tree_cb("next_git_item"),
  55. ["-"] = tree_cb("dir_up"),
  56. ["q"] = tree_cb("close"),
  57. }
  58. -- vim.g.nvim_tree_show_icons = {git = 1, folders = 1, files = 1}
  59. vim.g.nvim_tree_icons = {
  60. default = '',
  61. symlink = '',
  62. git = {unstaged = "", staged = "✓", unmerged = "", renamed = "➜", untracked = ""},
  63. folder = {default = "", open = "", empty = "", empty_open = "", symlink = ""}
  64. }
  65. local view = require'nvim-tree.view'
  66. local _M = {}
  67. _M.toggle_tree = function()
  68. if view.win_open() then
  69. require'nvim-tree'.close()
  70. require'bufferline.state'.set_offset(0)
  71. else
  72. require'bufferline.state'.set_offset(31, 'File Explorer')
  73. require'nvim-tree'.find_file(true)
  74. end
  75. end
  76. return _M