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
-- lua/custom/chadrc.lua
-- This is an example chadrc file , its supposed to be placed in /lua/custom/
local M = {}
@ -7,7 +6,7 @@ local M = {}
-- example of changing theme:
M.ui = {
theme = "gruvchad",
theme = "onedark",
}
return M

View file

@ -1,28 +1,19 @@
-- This is an example init file , its supposed to be placed in /lua/custom dir
-- lua/custom/init.lua
-- 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!!
local hooks = require "core.hooks"
-- 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>", opt)
map("n", "<leader>q", ":q <CR>", opt)
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
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
-- To add new plugins, use the "install_plugins" hook,
local customPlugins = require "core.customPlugins"
-- examples below:
hooks.add("install_plugins", function(use)
customPlugins.add(function(use)
use {
"max397574/better-escape.nvim",
event = "InsertEnter",
@ -34,6 +25,6 @@ hooks.add("install_plugins", function(use)
}
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
-- 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 hooks = require "core.hooks"
local config = utils.load_config()
local map = utils.map
@ -110,7 +109,6 @@ M.misc = function()
non_config_mappings()
optional_mappings()
required_mappings()
hooks.run("setup_mappings", map)
end
-- below are all plugin related mappings

View file

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