This commit is contained in:
siduck 2022-01-07 19:58:05 +05:30
parent 799432e99e
commit 4e54ee0081
6 changed files with 26 additions and 49 deletions

View file

@ -1,5 +1,4 @@
-- This is an example chadrc file , its supposed to be placed in /lua/custom dir -- This is an example chadrc file , its supposed to be placed in /lua/custom/
-- lua/custom/chadrc.lua
local M = {} local M = {}
@ -7,7 +6,7 @@ local M = {}
-- example of changing theme: -- example of changing theme:
M.ui = { M.ui = {
theme = "gruvchad", theme = "onedark",
} }
return M return M

View file

@ -1,28 +1,19 @@
-- This is an example init file , its supposed to be placed in /lua/custom dir -- This is an example init file , its supposed to be placed in /lua/custom/
-- lua/custom/init.lua
-- This is where your custom modules and plugins go. -- This is where your custom modules and plugins go.
-- Please check NvChad docs if you're totally new to nvchad + dont know lua!! -- Please check NvChad docs if you're totally new to nvchad + dont know lua!!
local hooks = require "core.hooks"
-- MAPPINGS -- MAPPINGS
-- To add new plugins, use the "setup_mappings" hook, local map = require("core.utils").map
hooks.add("setup_mappings", function(map) map("n", "<leader>cc", ":Telescope <CR>")
map("n", "<leader>cc", ":Telescope <CR>", opt) map("n", "<leader>q", ":q <CR>")
map("n", "<leader>q", ":q <CR>", opt) -- 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
end)
-- NOTE : opt is a variable there (most likely a table if you want multiple options),
-- you can remove it if you dont have any custom options
-- Install plugins -- Install plugins
-- To add new plugins, use the "install_plugins" hook, local customPlugins = require "core.customPlugins"
-- examples below: customPlugins.add(function(use)
hooks.add("install_plugins", function(use)
use { use {
"max397574/better-escape.nvim", "max397574/better-escape.nvim",
event = "InsertEnter", event = "InsertEnter",
@ -34,6 +25,6 @@ hooks.add("install_plugins", function(use)
} }
end) end)
-- NOTE: we heavily suggest using Packer's lazy loading (with the 'event' field) -- NOTE: we heavily suggest using Packer's lazy loading (with the 'event','cmd' fields)
-- see: https://github.com/wbthomason/packer.nvim -- see: https://github.com/wbthomason/packer.nvim
-- https://nvchad.github.io/config/walkthrough -- https://nvchad.github.io/config/walkthrough

View file

@ -0,0 +1,15 @@
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

@ -1,26 +0,0 @@
local hooks, M = {}, {}
local allowed_hooks = {
["install_plugins"] = true,
["setup_mappings"] = true,
}
M.add = function(name, fn)
if not allowed_hooks[name] then
print("Custom lua uses unallowed hook " .. name)
end
if not hooks[name] then
hooks[name] = {}
end
table.insert(hooks[name], fn)
end
M.run = function(name, args)
if hooks[name] then
for _, hook in pairs(hooks[name]) do
hook(args)
end
end
end
return M

View file

@ -1,5 +1,4 @@
local utils = require "core.utils" local utils = require "core.utils"
local hooks = require "core.hooks"
local config = utils.load_config() local config = utils.load_config()
local map = utils.map local map = utils.map
@ -110,7 +109,6 @@ M.misc = function()
non_config_mappings() non_config_mappings()
optional_mappings() optional_mappings()
required_mappings() required_mappings()
hooks.run("setup_mappings", map)
end end
-- below are all plugin related mappings -- below are all plugin related mappings

View file

@ -223,5 +223,5 @@ return packer.startup(function()
end, end,
} }
-- load user defined plugins -- load user defined plugins
require("core.hooks").run("install_plugins", use) require("core.customPlugins").run(use)
end) end)