clean packer config | Breaking change

This commit is contained in:
siduck 2022-01-30 12:51:46 +05:30
parent e8b31c9308
commit 64c32d2e5e
7 changed files with 89 additions and 104 deletions

View File

@ -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

View File

@ -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", "<leader>cc", ":Telescope <CR>")
map("n", "<leader>q", ":q <CR>")
-- 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

7
examples/plugins.lua Normal file
View File

@ -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" },
}

View File

@ -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

View File

@ -107,6 +107,7 @@ M.plugins = {
esc_insertmode_timeout = 300,
},
default_plugin_config_replace = {},
install = nil,
}
-- Don't use a single keymap twice

View File

@ -42,7 +42,7 @@ local default = {
["<Tab>"] = 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("<Plug>luasnip-expand-or-jump", true, true, true), "")
else
fallback()

View File

@ -5,46 +5,41 @@ if not present then
return false
end
local use = packer.use
return packer.startup(function()
local override_req = require("core.utils").override_req
-- this is arranged on the basis of when a plugin starts
local plugins = {
{ "Nvchad/extensions" },
{ "nvim-lua/plenary.nvim" },
{ "lewis6991/impatient.nvim" },
{ "nathom/filetype.nvim" },
-- 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 }