diff options
author | chaeing <[email protected]> | 2021-07-16 23:42:55 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2021-07-17 02:42:55 -0400 |
commit | 1f5fd93f807e5fd70f29569dd4160ffbd3c282d6 (patch) | |
tree | 21783d51f21938a4889f228107679e80582f39aa | |
parent | 18209ed558ce9495d27114684f76ccfa486cbbd4 (diff) |
[Refactor] nvimtree to be configurable (#970)
* Refactor nvimtree to be configurable
* Correct the location of .stylua.toml in Contrib.md
Co-authored-by: Christian Chiarulli <[email protected]>
-rw-r--r-- | CONTRIBUTING.md | 1 | ||||
-rw-r--r-- | lua/core/nvimtree.lua | 101 | ||||
-rw-r--r-- | lua/default-config.lua | 1 | ||||
-rw-r--r-- | utils/installer/lv-config.example-no-ts.lua | 3 | ||||
-rw-r--r-- | utils/installer/lv-config.example.lua | 3 |
5 files changed, 57 insertions, 52 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 27435781..364ccf54 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,6 +18,7 @@ One of the best ways to begin contributing in a meaningful way is by helping fin ## Setting up development tools 1. Install [stylua](https://github.com/johnnymorganz/stylua#installation) + 2. Copy `utils/.stylua.toml` into the LunarVim root directory ## Some Guidelines diff --git a/lua/core/nvimtree.lua b/lua/core/nvimtree.lua index cb3eacea..e3df9afb 100644 --- a/lua/core/nvimtree.lua +++ b/lua/core/nvimtree.lua @@ -1,74 +1,75 @@ --- --if not package.loaded['nvim-tree.view'] then --- -- return --- --end --- local M = {} local status_ok, nvim_tree_config = pcall(require, "nvim-tree.config") if not status_ok then return end -- +M.config = function() + O.plugin.nvimtree = { + side = "left", + show_icons = { + git = 1, + folders = 1, + files = 1, + folder_arrows = 1, + tree_width = 30, + }, + ignore = { ".git", "node_modules", ".cache" }, + auto_open = 1, + auto_close = 1, + quit_on_open = 0, + follow = 1, + hide_dotfiles = 1, + git_hl = 1, + root_folder_modifier = ":t", + tab_open = 0, + allow_resize = 1, + lsp_diagnostics = 1, + auto_ignore_ft = { "startify", "dashboard" }, + icons = { + default = "", + symlink = "", + git = { + unstaged = "", + staged = "S", + unmerged = "", + renamed = "➜", + deleted = "", + untracked = "U", + ignored = "◌", + }, + folder = { + default = "", + open = "", + empty = "", + empty_open = "", + symlink = "", + }, + }, + } +end +-- M.setup = function() local g = vim.g - vim.o.termguicolors = true - - g.nvim_tree_side = "left" - g.nvim_tree_width = 30 - g.nvim_tree_ignore = { ".git", "node_modules", ".cache" } - g.nvim_tree_auto_open = 1 - g.nvim_tree_auto_close = 1 - g.nvim_tree_quit_on_open = 0 - g.nvim_tree_follow = 1 - g.nvim_tree_indent_markers = 1 - g.nvim_tree_hide_dotfiles = 1 - g.nvim_tree_git_hl = 1 - g.nvim_tree_root_folder_modifier = ":t" - g.nvim_tree_tab_open = 0 - g.nvim_tree_allow_resize = 1 - g.nvim_tree_lsp_diagnostics = 1 - g.nvim_tree_auto_ignore_ft = { "startify", "dashboard" } - - g.nvim_tree_show_icons = { - git = 1, - folders = 1, - files = 1, - folder_arrows = 1, - } + for opt, val in pairs(O.plugin.nvimtree) do + g["nvim_tree_" .. opt] = val + end - vim.g.nvim_tree_icons = { - default = "", - symlink = "", - git = { - unstaged = "", - staged = "S", - unmerged = "", - renamed = "➜", - deleted = "", - untracked = "U", - ignored = "◌", - }, - folder = { - default = "", - open = "", - empty = "", - empty_open = "", - symlink = "", - }, - } local tree_cb = nvim_tree_config.nvim_tree_callback - vim.g.nvim_tree_bindings = { + g.nvim_tree_bindings = { { key = { "l", "<CR>", "o" }, cb = tree_cb "edit" }, { key = "h", cb = tree_cb "close_node" }, { key = "v", cb = tree_cb "vsplit" }, } end - +-- local view_status_ok, view = pcall(require, "nvim-tree.view") if not view_status_ok then return end +-- M.toggle_tree = function() if view.win_open() then require("nvim-tree").close() diff --git a/lua/default-config.lua b/lua/default-config.lua index 3e654938..408ba038 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -159,6 +159,7 @@ require("core.zen").config() require("core.telescope").config() require("core.treesitter").config() require("core.which-key").config() +require("core.nvimtree").config() require("lang.clang").config() require("lang.cmake").config() diff --git a/utils/installer/lv-config.example-no-ts.lua b/utils/installer/lv-config.example-no-ts.lua index f06189cc..4f4cf365 100644 --- a/utils/installer/lv-config.example-no-ts.lua +++ b/utils/installer/lv-config.example-no-ts.lua @@ -14,7 +14,6 @@ O.format_on_save = true O.lint_on_save = true O.completion.autocomplete = true O.colorscheme = "spacegray" -O.auto_close_tree = 0 O.default_options.wrap = true O.default_options.timeoutlen = 100 O.leader_key = " " @@ -25,6 +24,8 @@ O.plugin.dashboard.active = true O.plugin.terminal.active = true O.plugin.zen.active = false O.plugin.zen.window.height = 0.90 +O.plugin.nvimtree.side = "left" +O.plugin.nvimtree.show_icons.git = 0 -- if you don't want all the parsers change this to a table of the ones you want O.treesitter.ensure_installed = {} diff --git a/utils/installer/lv-config.example.lua b/utils/installer/lv-config.example.lua index cbc495e8..b08be95a 100644 --- a/utils/installer/lv-config.example.lua +++ b/utils/installer/lv-config.example.lua @@ -14,7 +14,6 @@ O.format_on_save = true O.lint_on_save = true O.completion.autocomplete = true O.colorscheme = "spacegray" -O.auto_close_tree = 0 O.default_options.wrap = true O.default_options.timeoutlen = 100 O.leader_key = " " @@ -25,6 +24,8 @@ O.plugin.dashboard.active = true O.plugin.terminal.active = true O.plugin.zen.active = false O.plugin.zen.window.height = 0.90 +O.plugin.nvimtree.side = "left" +O.plugin.nvimtree.show_icons.git = 0 -- if you don't want all the parsers change this to a table of the ones you want O.treesitter.ensure_installed = "maintained" |