summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/core/nvimtree.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/lua/core/nvimtree.lua')
-rw-r--r--.config/nvim/lua/core/nvimtree.lua175
1 files changed, 0 insertions, 175 deletions
diff --git a/.config/nvim/lua/core/nvimtree.lua b/.config/nvim/lua/core/nvimtree.lua
deleted file mode 100644
index b525351..0000000
--- a/.config/nvim/lua/core/nvimtree.lua
+++ /dev/null
@@ -1,175 +0,0 @@
-local M = {}
-local Log = require "core.log"
-
-function M.config()
- options.builtin.nvimtree = {
- active = true,
- on_config_done = nil,
- setup = {
- disable_netrw = true,
- hijack_netrw = true,
- open_on_setup = false,
- ignore_ft_on_setup = {
- "startify",
- "dashboard",
- "alpha",
- },
- update_to_buf_dir = {
- enable = true,
- auto_open = true,
- },
- auto_close = true,
- open_on_tab = false,
- hijack_cursor = false,
- update_cwd = false,
- diagnostics = {
- enable = true,
- icons = {
- hint = "",
- info = "",
- warning = "",
- error = "",
- },
- },
- update_focused_file = {
- enable = true,
- update_cwd = true,
- ignore_list = {},
- },
- system_open = {
- cmd = nil,
- args = {},
- },
- git = {
- enable = true,
- ignore = true,
- timeout = 200,
- },
- view = {
- width = 30,
- height = 30,
- side = "left",
- auto_resize = true,
- number = false,
- relativenumber = false,
- mappings = {
- custom_only = false,
- list = {},
- },
- },
- filters = {
- dotfiles = true,
- custom = { ".git", "node_modules", ".cache" },
- },
- },
- show_icons = {
- git = 1,
- folders = 1,
- files = 1,
- folder_arrows = 1,
- tree_width = 30,
- },
- quit_on_open = 0,
- git_hl = 1,
- disable_window_picker = 0,
- root_folder_modifier = ":t",
- icons = {
- default = "",
- symlink = "",
- git = {
- unstaged = "",
- staged = "S",
- unmerged = "",
- renamed = "➜",
- deleted = "",
- untracked = "U",
- ignored = "◌",
- },
- folder = {
- default = "",
- open = "",
- empty = "",
- empty_open = "",
- symlink = "",
- },
- },
- }
- options.builtin.which_key.mappings["e"] = { "<cmd>NvimTreeToggle<CR>", "Explorer" }
-end
-
-function M.setup()
- local status_ok, nvim_tree_config = pcall(require, "nvim-tree.config")
- if not status_ok then
- Log:error "Failed to load nvim-tree.config"
- return
- end
- local g = vim.g
-
- for opt, val in pairs(options.builtin.nvimtree) do
- g["nvim_tree_" .. opt] = val
- end
-
- -- Implicitly update nvim-tree when project module is active
- if options.builtin.project.active then
- options.builtin.nvimtree.respect_buf_cwd = 1
- options.builtin.nvimtree.setup.update_cwd = true
- options.builtin.nvimtree.setup.disable_netrw = false
- options.builtin.nvimtree.setup.hijack_netrw = false
- vim.g.netrw_banner = false
- end
-
- local tree_cb = nvim_tree_config.nvim_tree_callback
-
- if not options.builtin.nvimtree.setup.view.mappings.list then
- options.builtin.nvimtree.setup.view.mappings.list = {
- { key = { "l", "<CR>", "o" }, cb = tree_cb "edit" },
- { key = "h", cb = tree_cb "close_node" },
- { key = "v", cb = tree_cb "vsplit" },
- }
- end
-
- local tree_view = require "nvim-tree.view"
-
- -- Add nvim_tree open callback
- local open = tree_view.open
- tree_view.open = function()
- M.on_open()
- open()
- end
-
- vim.cmd "au WinClosed * lua require('core.nvimtree').on_close()"
-
- if options.builtin.nvimtree.on_config_done then
- options.builtin.nvimtree.on_config_done(nvim_tree_config)
- end
- require("nvim-tree").setup(options.builtin.nvimtree.setup)
-end
-
-function M.on_open()
- if
- package.loaded["bufferline.state"]
- and options.builtin.nvimtree.setup.view.side == "left"
- then
- require("bufferline.state").set_offset(
- options.builtin.nvimtree.setup.view.width + 1,
- ""
- )
- end
-end
-
-function M.on_close()
- local buf = tonumber(vim.fn.expand "<abuf>")
- local ft = vim.api.nvim_buf_get_option(buf, "filetype")
- if ft == "NvimTree" and package.loaded["bufferline.state"] then
- require("bufferline.state").set_offset(0)
- end
-end
-
-function M.change_tree_dir(dir)
- local lib_status_ok, lib = pcall(require, "nvim-tree.lib")
- if lib_status_ok then
- lib.change_dir(dir)
- end
-end
-
-return M