From 4e23587ca3ea157589b14a9d9444aa07be2a5830 Mon Sep 17 00:00:00 2001 From: siduck76 Date: Fri, 25 Jun 2021 23:06:17 +0530 Subject: [PATCH] lazy loading : nvimtree and autopairs --- init.lua | 2 - lua/mappings.lua | 11 +++ lua/nvimTree.lua | 163 ++++++++++++++++++++++----------------------- lua/pluginList.lua | 19 +++++- 4 files changed, 106 insertions(+), 89 deletions(-) diff --git a/init.lua b/init.lua index 747f9f3..0564ef8 100644 --- a/init.lua +++ b/init.lua @@ -39,12 +39,10 @@ g.indent_blankline_show_first_indent_level = false require "mappings" require "telescope-nvim" -require "nvimTree" -- file tree stuff require "file-icons" -- git signs , lsp symbols etc require "gitsigns-nvim" -require("nvim-autopairs").setup() require("lspkind").init() -- hide line numbers , statusline in specific buffers! diff --git a/lua/mappings.lua b/lua/mappings.lua index 433a06a..9309a68 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -91,3 +91,14 @@ map("s", "", "v:lua.tab_complete()", {expr = true}) map("i", "", "v:lua.s_tab_complete()", {expr = true}) map("s", "", "v:lua.s_tab_complete()", {expr = true}) map("i", "", "v:lua.completions()", {expr = true}) + +-- Mappings for nvimtree +vim.api.nvim_set_keymap( + "n", + "", + ":NvimTreeToggle", + { + noremap = true, + silent = true + } +) diff --git a/lua/nvimTree.lua b/lua/nvimTree.lua index 47f72ff..5479b86 100644 --- a/lua/nvimTree.lua +++ b/lua/nvimTree.lua @@ -1,93 +1,88 @@ -local g = vim.g +local M = {} -vim.o.termguicolors = true +M.config = function() + local g = vim.g -g.nvim_tree_side = "left" -g.nvim_tree_width = 25 -g.nvim_tree_ignore = {".git", "node_modules", ".cache"} -g.nvim_tree_auto_open = 0 -g.nvim_tree_auto_close = 0 -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 + vim.o.termguicolors = true -g.nvim_tree_show_icons = { - git = 1, - folders = 1, - files = 1 -} + g.nvim_tree_side = "left" + g.nvim_tree_width = 25 + g.nvim_tree_ignore = {".git", "node_modules", ".cache"} + g.nvim_tree_auto_open = 0 + g.nvim_tree_auto_close = 0 + 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_icons = { - default = "", - symlink = "", - git = { - unstaged = "✗", - staged = "✓", - unmerged = "", - renamed = "➜", - untracked = "★", - deleted = "", - ignored = "◌" - }, - folder = { - default = "", - open = "", - symlink = "", - empty = "", - empty_open = "", - symlink_open = "" + g.nvim_tree_show_icons = { + git = 1, + folders = 1, + files = 1 } -} --- Mappings for nvimtree -vim.api.nvim_set_keymap( - "n", - "", - ":NvimTreeToggle", - { - noremap = true, - silent = true + g.nvim_tree_icons = { + default = "", + symlink = "", + git = { + unstaged = "✗", + staged = "✓", + unmerged = "", + renamed = "➜", + untracked = "★", + deleted = "", + ignored = "◌" + }, + folder = { + default = "", + open = "", + symlink = "", + empty = "", + empty_open = "", + symlink_open = "" + } } -) -local tree_cb = require "nvim-tree.config".nvim_tree_callback + local tree_cb = require "nvim-tree.config".nvim_tree_callback -g.nvim_tree_bindings = { - ["u"] = ":lua require'some_module'.some_function()", - -- default mappings - [""] = tree_cb("edit"), - ["o"] = tree_cb("edit"), - ["<2-LeftMouse>"] = tree_cb("edit"), - ["<2-RightMouse>"] = tree_cb("cd"), - [""] = tree_cb("cd"), - [""] = tree_cb("vsplit"), - [""] = tree_cb("split"), - [""] = tree_cb("tabnew"), - ["<"] = tree_cb("prev_sibling"), - [">"] = tree_cb("next_sibling"), - [""] = tree_cb("close_node"), - [""] = tree_cb("close_node"), - [""] = tree_cb("preview"), - ["I"] = tree_cb("toggle_ignored"), - ["H"] = tree_cb("toggle_dotfiles"), - ["R"] = tree_cb("refresh"), - ["a"] = tree_cb("create"), - ["d"] = tree_cb("remove"), - ["r"] = tree_cb("rename"), - [""] = tree_cb("full_rename"), - ["x"] = tree_cb("cut"), - ["c"] = tree_cb("copy"), - ["p"] = tree_cb("paste"), - ["y"] = tree_cb("copy_name"), - ["Y"] = tree_cb("copy_path"), - ["gy"] = tree_cb("copy_absolute_path"), - ["[c"] = tree_cb("prev_git_item"), - ["]c"] = tree_cb("next_git_item"), - ["-"] = tree_cb("dir_up"), - ["q"] = tree_cb("close") -} + g.nvim_tree_bindings = { + ["u"] = ":lua require'some_module'.some_function()", + -- default mappings + [""] = tree_cb("edit"), + ["o"] = tree_cb("edit"), + ["<2-LeftMouse>"] = tree_cb("edit"), + ["<2-RightMouse>"] = tree_cb("cd"), + [""] = tree_cb("cd"), + [""] = tree_cb("vsplit"), + [""] = tree_cb("split"), + [""] = tree_cb("tabnew"), + ["<"] = tree_cb("prev_sibling"), + [">"] = tree_cb("next_sibling"), + [""] = tree_cb("close_node"), + [""] = tree_cb("close_node"), + [""] = tree_cb("preview"), + ["I"] = tree_cb("toggle_ignored"), + ["H"] = tree_cb("toggle_dotfiles"), + ["R"] = tree_cb("refresh"), + ["a"] = tree_cb("create"), + ["d"] = tree_cb("remove"), + ["r"] = tree_cb("rename"), + [""] = tree_cb("full_rename"), + ["x"] = tree_cb("cut"), + ["c"] = tree_cb("copy"), + ["p"] = tree_cb("paste"), + ["y"] = tree_cb("copy_name"), + ["Y"] = tree_cb("copy_path"), + ["gy"] = tree_cb("copy_absolute_path"), + ["[c"] = tree_cb("prev_git_item"), + ["]c"] = tree_cb("next_git_item"), + ["-"] = tree_cb("dir_up"), + ["q"] = tree_cb("close") + } +end + +return M diff --git a/lua/pluginList.lua b/lua/pluginList.lua index 2b63744..28000eb 100644 --- a/lua/pluginList.lua +++ b/lua/pluginList.lua @@ -38,10 +38,16 @@ return packer.startup( use "lewis6991/gitsigns.nvim" use "akinsho/nvim-bufferline.lua" use "glepnir/galaxyline.nvim" - use "windwp/nvim-autopairs" + + use { + "windwp/nvim-autopairs", + event = "InsertEnter", + config = function() + require("nvim-autopairs").setup() + end + } -- use "alvan/vim-closetag" -- for html - -- Comment use "terrortylor/nvim-comment" -- snippet support -- snippet @@ -52,7 +58,14 @@ return packer.startup( use "rafamadriz/friendly-snippets" -- file managing , picker etc - use "kyazdani42/nvim-tree.lua" + use { + "kyazdani42/nvim-tree.lua", + cmd = "NvimTreeToggle", + config = function() + require("nvimTree").config() + end + } + use "kyazdani42/nvim-web-devicons" use "nvim-telescope/telescope.nvim" use "nvim-telescope/telescope-media-files.nvim"