diff --git a/examples/chadrc.lua b/examples/chadrc.lua index 6967664..a0f135d 100644 --- a/examples/chadrc.lua +++ b/examples/chadrc.lua @@ -9,4 +9,15 @@ M.ui = { theme = "onedark", } +-- Install plugins +local userPlugins = require "custom.plugins" -- path to table + +M.plugins = { + install = userPlugins, +} + +-- NOTE: we heavily suggest using Packer's lazy loading (with the 'event','cmd' fields) +-- see: https://github.com/wbthomason/packer.nvim +-- https://nvchad.github.io/config/walkthrough + return M diff --git a/examples/init.lua b/examples/init.lua index 7d6e529..a6b3d5c 100644 --- a/examples/init.lua +++ b/examples/init.lua @@ -1,30 +1,11 @@ --- This is an example init file , its supposed to be placed in /lua/custom/ - --- This is where your custom modules and plugins go. -- Please check NvChad docs if you're totally new to nvchad + dont know lua!! +-- This is an example init file in /lua/custom/ +-- this init.lua can load stuffs etc too so treat it like your ~/.config/nvim/ -- MAPPINGS local map = require("core.utils").map map("n", "cc", ":Telescope ") map("n", "q", ":q ") --- NOTE: the 4th argument in the map function can be a table i.e options but its most likely un-needed so dont worry about it --- Install plugins -local customPlugins = require "core.customPlugins" - -customPlugins.add(function(use) - use { - "max397574/better-escape.nvim", - event = "InsertEnter", - } - - use { - "user or orgname/reponame", - --further packer options - } -end) - --- NOTE: we heavily suggest using Packer's lazy loading (with the 'event','cmd' fields) --- see: https://github.com/wbthomason/packer.nvim --- https://nvchad.github.io/config/walkthrough +-- NOTE: the 4th argument in the map function is be a table i.e options but its most likely un-needed so dont worry about it diff --git a/examples/plugins.lua b/examples/plugins.lua new file mode 100644 index 0000000..0e0b0c9 --- /dev/null +++ b/examples/plugins.lua @@ -0,0 +1,7 @@ +-- Example plugins file! +-- (suggestion) -> lua/custom/plugins/init.lua or anywhere in custom dir + +return { + { "elkowar/yuck.vim", ft = "yuck" }, + { "ellisonleao/glow.nvim", cmd = "Glow" }, +} diff --git a/lua/core/customPlugins.lua b/lua/core/customPlugins.lua deleted file mode 100644 index c667936..0000000 --- a/lua/core/customPlugins.lua +++ /dev/null @@ -1,15 +0,0 @@ -local M = {} -local plugins = {} - -M.add = function(fn) - table.insert(plugins, fn) -end - --- load custom plugins in packer startup function -M.run = function(args) - for _, hook in pairs(plugins) do - hook(args) - end -end - -return M diff --git a/lua/core/default_config.lua b/lua/core/default_config.lua index 89acc5d..1e43129 100644 --- a/lua/core/default_config.lua +++ b/lua/core/default_config.lua @@ -107,6 +107,7 @@ M.plugins = { esc_insertmode_timeout = 300, }, default_plugin_config_replace = {}, + install = nil, } -- Don't use a single keymap twice diff --git a/lua/plugins/configs/cmp.lua b/lua/plugins/configs/cmp.lua index d01b74a..298ba4d 100644 --- a/lua/plugins/configs/cmp.lua +++ b/lua/plugins/configs/cmp.lua @@ -42,7 +42,7 @@ local default = { [""] = function(fallback) if cmp.visible() then cmp.select_next_item() - elseif snippents_status and require("luasnip").expand_or_jumpable() then + elseif snippets_status and require("luasnip").expand_or_jumpable() then vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-expand-or-jump", true, true, true), "") else fallback() diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index f2f6ff5..371abd9 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -5,46 +5,41 @@ if not present then return false end -local use = packer.use +local override_req = require("core.utils").override_req -return packer.startup(function() - local override_req = require("core.utils").override_req +local plugins = { + { "Nvchad/extensions" }, + { "nvim-lua/plenary.nvim" }, + { "lewis6991/impatient.nvim" }, + { "nathom/filetype.nvim" }, - -- this is arranged on the basis of when a plugin starts - - -- this is the nvchad core repo containing utilities for some features like theme swticher, no need to lazy load - use "Nvchad/extensions" - use "nvim-lua/plenary.nvim" - use "lewis6991/impatient.nvim" - use "nathom/filetype.nvim" - - use { + { "wbthomason/packer.nvim", event = "VimEnter", - } + }, - use { + { "NvChad/nvim-base16.lua", after = "packer.nvim", config = function() require("colors").init() end, - } + }, - use { + { "kyazdani42/nvim-web-devicons", after = "nvim-base16.lua", config = override_req("nvim_web_devicons", "plugins.configs.icons", "setup"), - } + }, - use { + { "feline-nvim/feline.nvim", disable = not plugin_settings.status.feline, after = "nvim-web-devicons", config = override_req("feline", "plugins.configs.statusline", "setup"), - } + }, - use { + { "akinsho/bufferline.nvim", disable = not plugin_settings.status.bufferline, after = "nvim-web-devicons", @@ -52,30 +47,30 @@ return packer.startup(function() setup = function() require("core.mappings").bufferline() end, - } + }, - use { + { "lukas-reineke/indent-blankline.nvim", disable = not plugin_settings.status.blankline, event = "BufRead", config = override_req("indent_blankline", "plugins.configs.others", "blankline"), - } + }, - use { + { "norcalli/nvim-colorizer.lua", disable = not plugin_settings.status.colorizer, event = "BufRead", config = override_req("nvim_colorizer", "plugins.configs.others", "colorizer"), - } + }, - use { + { "nvim-treesitter/nvim-treesitter", event = "BufRead", config = override_req("nvim_treesitter", "plugins.configs.treesitter", "setup"), - } + }, -- git stuff - use { + { "lewis6991/gitsigns.nvim", disable = not plugin_settings.status.gitsigns, opt = true, @@ -83,11 +78,11 @@ return packer.startup(function() setup = function() require("core.utils").packer_lazy_load "gitsigns.nvim" end, - } + }, -- lsp stuff - use { + { "neovim/nvim-lspconfig", module = "lspconfig", opt = true, @@ -99,105 +94,106 @@ return packer.startup(function() end, 0) end, config = override_req("lspconfig", "plugins.configs.lspconfig"), - } + }, - use { + { "ray-x/lsp_signature.nvim", disable = not plugin_settings.status.lspsignature, after = "nvim-lspconfig", config = override_req("signature", "plugins.configs.others", "signature"), - } + }, - use { + { "andymass/vim-matchup", disable = not plugin_settings.status.vim_matchup, opt = true, setup = function() require("core.utils").packer_lazy_load "vim-matchup" end, - } + }, - use { + { "max397574/better-escape.nvim", disable = not plugin_settings.status.better_escape, event = "InsertEnter", config = override_req("better_escape", "plugins.configs.others", "better_escape"), - } + }, -- load luasnips + cmp related in insert mode only - use { + { "rafamadriz/friendly-snippets", module = "cmp_nvim_lsp", disable = not (plugin_settings.status.cmp and plugin_settings.status.snippets), event = "InsertEnter", - } + }, -- cmp by default loads after friendly snippets -- if snippets are disabled -> cmp loads on insertEnter! - use { + { "hrsh7th/nvim-cmp", disable = not plugin_settings.status.cmp, event = not plugin_settings.status.snippets and "InsertEnter", after = plugin_settings.status.snippets and "friendly-snippets", config = override_req("nvim_cmp", "plugins.configs.cmp", "setup"), - } + }, - use { + { "L3MON4D3/LuaSnip", disable = not (plugin_settings.status.cmp and plugin_settings.status.snippets), wants = "friendly-snippets", after = "nvim-cmp", config = override_req("luasnip", "plugins.configs.others", "luasnip"), - } + }, - use { + { "saadparwaiz1/cmp_luasnip", disable = not (plugin_settings.status.cmp and plugin_settings.status.snippets), after = plugin_settings.options.cmp.lazy_load and "LuaSnip", - } + }, - use { + { "hrsh7th/cmp-nvim-lua", disable = not plugin_settings.status.cmp, after = (plugin_settings.status.snippets and "cmp_luasnip") or "nvim-cmp", - } + }, - use { + { "hrsh7th/cmp-nvim-lsp", disable = not plugin_settings.status.cmp, after = "cmp-nvim-lua", - } + }, - use { + { "hrsh7th/cmp-buffer", disable = not plugin_settings.status.cmp, after = "cmp-nvim-lsp", - } + }, - use { + { "hrsh7th/cmp-path", disable = not plugin_settings.status.cmp, after = "cmp-buffer", - } + }, + -- misc plugins - use { + { "windwp/nvim-autopairs", disable = not plugin_settings.status.autopairs, after = plugin_settings.options.autopairs.loadAfter, config = override_req("nvim_autopairs", "plugins.configs.others", "autopairs"), - } + }, - use { + { "glepnir/dashboard-nvim", disable = not plugin_settings.status.dashboard, config = override_req("dashboard", "plugins.configs.dashboard"), setup = function() require("core.mappings").dashboard() end, - } + }, - use { + { "numToStr/Comment.nvim", disable = not plugin_settings.status.comment, module = "Comment", @@ -205,10 +201,10 @@ return packer.startup(function() setup = function() require("core.mappings").comment() end, - } + }, -- file managing , picker etc - use { + { "kyazdani42/nvim-tree.lua", disable = not plugin_settings.status.nvimtree, -- only set "after" if lazy load is disabled and vice versa for "cmd" @@ -218,9 +214,9 @@ return packer.startup(function() setup = function() require("core.mappings").nvimtree() end, - } + }, - use { + { "nvim-telescope/telescope.nvim", module = "telescope", cmd = "Telescope", @@ -228,7 +224,11 @@ return packer.startup(function() setup = function() require("core.mappings").telescope() end, - } - -- load user defined plugins - require("core.customPlugins").run(use) -end) + }, +} + +-- append user plugins to default plugins +local user_Plugins = plugin_settings.install +plugins[#plugins + 1] = user_Plugins + +return packer.startup { plugins }