diff --git a/examples/init.lua b/examples/init.lua index 721f625..4106717 100644 --- a/examples/init.lua +++ b/examples/init.lua @@ -1,7 +1,7 @@ -- example file i.e lua/custom/init.lua -- MAPPINGS -local map = require("core.utils").map +local map = nvchad.map map("n", "cc", ":Telescope ") map("n", "q", ":q ") diff --git a/init.lua b/init.lua index 96afe05..0bdd69a 100644 --- a/init.lua +++ b/init.lua @@ -5,6 +5,7 @@ if present then end local core_modules = { + "core.utils", "core.options", "core.autocmds", "core.mappings", diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index 5338657..18273d6 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -1,6 +1,4 @@ -local utils = require "core.utils" - -local map = utils.map +local map = nvchad.map local cmd = vim.cmd local user_cmd = vim.api.nvim_create_user_command @@ -40,7 +38,7 @@ map("n", "", "k") map("n", "", "j") map("n", "x", function() - require("core.utils").close_buffer() + nvchad.close_buffer() end) map("n", "", " :%y+ ") -- copy whole file content @@ -92,7 +90,7 @@ cmd "silent! command! NvChadUpdate lua require('nvchad').update_nvchad()" map("n", "uu", " :NvChadUpdate ") -- load overriden misc mappings -require("core.utils").load_config().mappings.misc() +nvchad.load_config().mappings.misc() local M = {} diff --git a/lua/core/options.lua b/lua/core/options.lua index c9346c4..096c2e0 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -84,4 +84,4 @@ vim.schedule(function() end) -- load user options if the file exists -require("core.utils").load_config().options.user() +nvchad.load_config().options.user() diff --git a/lua/core/utils.lua b/lua/core/utils.lua index d978a90..abd51ea 100644 --- a/lua/core/utils.lua +++ b/lua/core/utils.lua @@ -1,6 +1,6 @@ -local M = {} +_G.nvchad = {} -M.close_buffer = function(force) +nvchad.close_buffer = function(force) if vim.bo.buftype == "terminal" then vim.api.nvim_win_hide(0) return @@ -22,7 +22,7 @@ M.close_buffer = function(force) vim.cmd(close_cmd) end -M.load_config = function() +nvchad.load_config = function() local conf = require "core.default_config" -- attempt to load and merge a user config @@ -40,7 +40,7 @@ M.load_config = function() return conf end -M.map = function(mode, keys, command, opt) +nvchad.map = function(mode, keys, command, opt) local options = { silent = true } if opt then @@ -49,7 +49,7 @@ M.map = function(mode, keys, command, opt) if type(keys) == "table" then for _, keymap in ipairs(keys) do - M.map(mode, keymap, command, opt) + nvchad.map(mode, keymap, command, opt) end return end @@ -58,7 +58,7 @@ M.map = function(mode, keys, command, opt) end -- load plugin after entering vim ui -M.packer_lazy_load = function(plugin, timer) +nvchad.packer_lazy_load = function(plugin, timer) if plugin then timer = timer or 0 vim.defer_fn(function() @@ -68,8 +68,8 @@ M.packer_lazy_load = function(plugin, timer) end -- remove plugins defined in chadrc -M.remove_default_plugins = function(plugins) - local removals = require("core.utils").load_config().plugins.remove or {} +nvchad.remove_default_plugins = function(plugins) + local removals = nvchad.load_config().plugins.remove or {} if not vim.tbl_isempty(removals) then for _, plugin in pairs(removals) do plugins[plugin] = nil @@ -79,8 +79,8 @@ M.remove_default_plugins = function(plugins) end -- merge default/user plugin tables -M.plugin_list = function(default_plugins) - local user_plugins = require("core.utils").load_config().plugins.user +nvchad.plugin_list = function(default_plugins) + local user_plugins = nvchad.load_config().plugins.user -- require if string is present local ok @@ -106,8 +106,8 @@ M.plugin_list = function(default_plugins) return final_table end -M.load_override = function(default_table, plugin_name) - local user_table = require("core.utils").load_config().plugins.override[plugin_name] +nvchad.load_override = function(default_table, plugin_name) + local user_table = nvchad.load_config().plugins.override[plugin_name] if type(user_table) == "table" then default_table = vim.tbl_deep_extend("force", default_table, user_table) else @@ -115,5 +115,3 @@ M.load_override = function(default_table, plugin_name) end return default_table end - -return M diff --git a/lua/plugins/configs/alpha.lua b/lua/plugins/configs/alpha.lua index 6a57bd6..840cafd 100644 --- a/lua/plugins/configs/alpha.lua +++ b/lua/plugins/configs/alpha.lua @@ -72,7 +72,7 @@ options.buttons = { }, } -options = require("core.utils").load_override(options, "goolord/alpha-nvim") +options = nvchad.load_override(options, "goolord/alpha-nvim") -- dynamic header padding local fn = vim.fn diff --git a/lua/plugins/configs/bufferline.lua b/lua/plugins/configs/bufferline.lua index 89ff4da..0d3a6f1 100644 --- a/lua/plugins/configs/bufferline.lua +++ b/lua/plugins/configs/bufferline.lua @@ -65,6 +65,6 @@ local options = { } -- check for any override -options = require("core.utils").load_override(options, "akinsho/bufferline.nvim") +options = nvchad.load_override(options, "akinsho/bufferline.nvim") bufferline.setup(options) diff --git a/lua/plugins/configs/cmp.lua b/lua/plugins/configs/cmp.lua index dca01c5..ee03873 100644 --- a/lua/plugins/configs/cmp.lua +++ b/lua/plugins/configs/cmp.lua @@ -93,6 +93,6 @@ local options = { } -- check for any override -options = require("core.utils").load_override(options, "hrsh7th/nvim-cmp") +options = nvchad.load_override(options, "hrsh7th/nvim-cmp") cmp.setup(options) diff --git a/lua/plugins/configs/icons.lua b/lua/plugins/configs/icons.lua index c3f3ba0..7a92dd3 100644 --- a/lua/plugins/configs/icons.lua +++ b/lua/plugins/configs/icons.lua @@ -118,6 +118,6 @@ local options = { } -- check for any override -options = require("core.utils").load_override(options, "kyazdani42/nvim-web-devicons") +options = nvchad.load_override(options, "kyazdani42/nvim-web-devicons") devicons.setup(options) diff --git a/lua/plugins/configs/lsp_installer.lua b/lua/plugins/configs/lsp_installer.lua index 4f56305..112a318 100644 --- a/lua/plugins/configs/lsp_installer.lua +++ b/lua/plugins/configs/lsp_installer.lua @@ -31,6 +31,6 @@ local options = { max_concurrent_installers = 20, } -options = require("core.utils").load_override(options, "williamboman/nvim-lsp-installer") +options = nvchad.load_override(options, "williamboman/nvim-lsp-installer") lsp_installer.setup(options) diff --git a/lua/plugins/configs/lspconfig.lua b/lua/plugins/configs/lspconfig.lua index a676ccf..05e9c67 100644 --- a/lua/plugins/configs/lspconfig.lua +++ b/lua/plugins/configs/lspconfig.lua @@ -54,7 +54,7 @@ lspconfig.sumneko_lua.setup { } -- requires a file containing user's lspconfigs -local addlsp_confs = require("core.utils").load_config().plugins.options.lspconfig.setup_lspconf +local addlsp_confs = nvchad.load_config().plugins.options.lspconfig.setup_lspconf if #addlsp_confs ~= 0 then require(addlsp_confs).setup_lsp(M.on_attach, capabilities) diff --git a/lua/plugins/configs/nvimtree.lua b/lua/plugins/configs/nvimtree.lua index afd334f..ce046a3 100644 --- a/lua/plugins/configs/nvimtree.lua +++ b/lua/plugins/configs/nvimtree.lua @@ -80,6 +80,6 @@ local options = { } -- check for any override -options = require("core.utils").load_override(options, "kyazdani42/nvim-tree.lua") +options = nvchad.load_override(options, "kyazdani42/nvim-tree.lua") nvimtree.setup(options) diff --git a/lua/plugins/configs/nvterm.lua b/lua/plugins/configs/nvterm.lua index 720b6d2..0ca9f4b 100644 --- a/lua/plugins/configs/nvterm.lua +++ b/lua/plugins/configs/nvterm.lua @@ -38,6 +38,6 @@ local options = { enable_new_mappings = true, } -options = require("core.utils").load_override(options, "NvChad/nvterm") +options = nvchad.load_override(options, "NvChad/nvterm") nvterm.setup(options) diff --git a/lua/plugins/configs/others.lua b/lua/plugins/configs/others.lua index 55b2561..433560b 100644 --- a/lua/plugins/configs/others.lua +++ b/lua/plugins/configs/others.lua @@ -32,7 +32,7 @@ M.better_escape = function() keys = "", } - options = require("core.utils").load_override(options, "max397574/better-escape.nvim") + options = nvchad.load_override(options, "max397574/better-escape.nvim") escape.setup(options) end @@ -63,7 +63,7 @@ M.blankline = function() show_first_indent_level = false, } - options = require("core.utils").load_override(options, "lukas-reineke/indent-blankline.nvim") + options = nvchad.load_override(options, "lukas-reineke/indent-blankline.nvim") blankline.setup(options) end @@ -93,7 +93,7 @@ M.colorizer = function() }, } - options = require("core.utils").load_override(options, "NvChad/nvim-colorizer.lua") + options = nvchad.load_override(options, "NvChad/nvim-colorizer.lua") colorizer.setup(options["filetypes"], options["user_default_options"]) vim.cmd "ColorizerReloadAllBuffers" @@ -149,7 +149,7 @@ M.signature = function() padding = "", -- character to pad on left and right of signature can be ' ', or '|' etc } - options = require("core.utils").load_override(options, "ray-x/lsp_signature.nvim") + options = nvchad.load_override(options, "ray-x/lsp_signature.nvim") lsp_signature.setup(options) end diff --git a/lua/plugins/configs/statusline.lua b/lua/plugins/configs/statusline.lua index 706c6db..6efae91 100644 --- a/lua/plugins/configs/statusline.lua +++ b/lua/plugins/configs/statusline.lua @@ -51,8 +51,7 @@ options.icon_styles = { }, } -options.separator_style = - options.icon_styles[require("core.utils").load_config().plugins.options.statusline.separator_style] +options.separator_style = options.icon_styles[nvchad.load_config().plugins.options.statusline.separator_style] options.main_icon = { provider = options.separator_style.main_icon, @@ -345,7 +344,7 @@ options.current_line = { }, } -options = require("core.utils").load_override(options, "feline-nvim/feline.nvim") +options = nvchad.load_override(options, "feline-nvim/feline.nvim") local function add_table(tbl, inject) if inject then diff --git a/lua/plugins/configs/telescope.lua b/lua/plugins/configs/telescope.lua index 5f2e817..5e052f6 100644 --- a/lua/plugins/configs/telescope.lua +++ b/lua/plugins/configs/telescope.lua @@ -57,7 +57,7 @@ local options = { } -- check for any override -options = require("core.utils").load_override(options, "nvim-telescope/telescope.nvim") +options = nvchad.load_override(options, "nvim-telescope/telescope.nvim") telescope.setup(options) -- load extensions diff --git a/lua/plugins/configs/treesitter.lua b/lua/plugins/configs/treesitter.lua index a6e6483..b576b3f 100644 --- a/lua/plugins/configs/treesitter.lua +++ b/lua/plugins/configs/treesitter.lua @@ -16,6 +16,6 @@ local options = { } -- check for any override -options = require("core.utils").load_override(options, "nvim-treesitter/nvim-treesitter") +options = nvchad.load_override(options, "nvim-treesitter/nvim-treesitter") treesitter.setup(options) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 4b9143f..93d441c 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -1,4 +1,4 @@ -local plugin_settings = require("core.utils").load_config().plugins +local plugin_settings = nvchad.load_config().plugins local present, packer = pcall(require, plugin_settings.options.packer.init_file) if not present then @@ -87,7 +87,7 @@ local plugins = { require("plugins.configs.others").gitsigns() end, setup = function() - require("core.utils").packer_lazy_load "gitsigns.nvim" + nvchad.packer_lazy_load "gitsigns.nvim" end, }, @@ -96,7 +96,7 @@ local plugins = { ["williamboman/nvim-lsp-installer"] = { opt = true, setup = function() - require("core.utils").packer_lazy_load "nvim-lsp-installer" + nvchad.packer_lazy_load "nvim-lsp-installer" -- reload the current file so lsp actually starts for it vim.defer_fn(function() vim.cmd 'if &ft == "packer" | echo "" | else | silent! e %' @@ -123,7 +123,7 @@ local plugins = { ["andymass/vim-matchup"] = { opt = true, setup = function() - require("core.utils").packer_lazy_load "vim-matchup" + nvchad.packer_lazy_load "vim-matchup" end, }, @@ -229,9 +229,9 @@ local plugins = { }, } -plugins = require("core.utils").remove_default_plugins(plugins) +plugins = nvchad.remove_default_plugins(plugins) -- merge user plugin table & default plugin table -plugins = require("core.utils").plugin_list(plugins) +plugins = nvchad.plugin_list(plugins) return packer.startup(function(use) for _, v in pairs(plugins) do diff --git a/lua/plugins/packerInit.lua b/lua/plugins/packerInit.lua index 88be509..c763fa1 100644 --- a/lua/plugins/packerInit.lua +++ b/lua/plugins/packerInit.lua @@ -27,7 +27,7 @@ if not present then end end -local user_snapshot = require("core.utils").load_config().snapshot +local user_snapshot = nvchad.load_config().snapshot packer.init { display = {