From 29307cb5fa34fa30d698d4ce677152aa7aebee53 Mon Sep 17 00:00:00 2001 From: christianchiarulli Date: Tue, 14 Dec 2021 18:18:28 -0500 Subject: [PATCH] add nvimtree --- init.lua | 1 + lua/user/keymaps.lua | 5 +- lua/user/nvim-tree.lua | 112 +++++++++++++++++++++++++++++++++++++++++ lua/user/plugins.lua | 2 + 4 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 lua/user/nvim-tree.lua diff --git a/init.lua b/init.lua index ba4006d..0669cb2 100644 --- a/init.lua +++ b/init.lua @@ -9,3 +9,4 @@ require "user.treesitter" require "user.autopairs" require "user.comment" require "user.gitsigns" +require "user.nvim-tree" diff --git a/lua/user/keymaps.lua b/lua/user/keymaps.lua index 9534dec..b4d2195 100644 --- a/lua/user/keymaps.lua +++ b/lua/user/keymaps.lua @@ -25,8 +25,6 @@ keymap("n", "", "j", opts) keymap("n", "", "k", opts) keymap("n", "", "l", opts) -keymap("n", "e", ":Lex 30", opts) - -- Resize with arrows keymap("n", "", ":resize -2", opts) keymap("n", "", ":resize +2", opts) @@ -72,3 +70,6 @@ keymap("t", "", "l", term_opts) -- Comment keymap("n", "/", "lua require('Comment').toggle()", opts) keymap("v", "/", ":lua require(\"Comment.api\").gc(vim.fn.visualmode())", opts) + +-- Nvimtree +keymap("n", "e", ":NvimTreeToggle", opts) diff --git a/lua/user/nvim-tree.lua b/lua/user/nvim-tree.lua new file mode 100644 index 0000000..9c5170c --- /dev/null +++ b/lua/user/nvim-tree.lua @@ -0,0 +1,112 @@ +-- following options are the default +-- each of these are documented in `:help nvim-tree.OPTION_NAME` +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 status_ok, nvim_tree = pcall(require, "nvim-tree") +if not status_ok then + return +end + +local config_status_ok, nvim_tree_config = pcall(require, "nvim-tree.config") +if not config_status_ok then + return +end + +local tree_cb = nvim_tree_config.nvim_tree_callback + +nvim_tree.setup { + disable_netrw = true, + hijack_netrw = true, + open_on_setup = false, + ignore_ft_on_setup = { + "startify", + "dashboard", + "alpha", + }, + auto_close = true, + open_on_tab = false, + hijack_cursor = false, + update_cwd = true, + update_to_buf_dir = { + enable = true, + auto_open = true, + }, + diagnostics = { + enable = true, + icons = { + hint = "", + info = "", + warning = "", + error = "", + }, + }, + update_focused_file = { + enable = true, + update_cwd = true, + ignore_list = {}, + }, + system_open = { + cmd = nil, + args = {}, + }, + filters = { + dotfiles = false, + custom = {}, + }, + git = { + enable = true, + ignore = true, + timeout = 500, + }, + view = { + width = 30, + height = 30, + hide_root_folder = false, + side = "left", + auto_resize = true, + mappings = { + custom_only = false, + list = { + { key = { "l", "", "o" }, cb = tree_cb "edit" }, + { key = "h", cb = tree_cb "close_node" }, + { key = "v", cb = tree_cb "vsplit" }, + }, + }, + number = false, + relativenumber = false, + }, + trash = { + cmd = "trash", + require_confirm = true, + }, + quit_on_open = 0, + git_hl = 1, + disable_window_picker = 0, + root_folder_modifier = ":t", + show_icons = { + git = 1, + folders = 1, + files = 1, + folder_arrows = 1, + tree_width = 30, + }, +} diff --git a/lua/user/plugins.lua b/lua/user/plugins.lua index 24678aa..04c0bc9 100644 --- a/lua/user/plugins.lua +++ b/lua/user/plugins.lua @@ -46,6 +46,8 @@ return packer.startup(function(use) use "nvim-lua/plenary.nvim" -- Useful lua functions used ny lots of plugins use "windwp/nvim-autopairs" -- Autopairs, integrates with both cmp and treesitter use "numToStr/Comment.nvim" -- Easily comment stuff + use 'kyazdani42/nvim-web-devicons' + use 'kyazdani42/nvim-tree.lua' -- Colorschemes -- use "lunarvim/colorschemes" -- A bunch of colorschemes you can try out