performance: avoid reloading config table #2360 (#2444)

* performance: avoid reloading config (#2360)

* performance: avoid reloading config

* Rm outdated info in readme

---------

Co-authored-by: Sidhanth Rathod <siduck@tutanota.com>

* update nvchad load_config result path

* update branch names

---------

Co-authored-by: georgejean <jeangeorge385@yahoo.fr>
This commit is contained in:
Sidhanth Rathod 2023-10-16 07:24:14 +05:30 committed by GitHub
parent ed18649e94
commit 5748536742
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 12 additions and 14 deletions

View File

@ -18,7 +18,7 @@ M.lazy = function(install_path)
M.echo " Compiling base46 theme to bytecode ..."
local base46_repo = "https://github.com/NvChad/base46"
shell_call { "git", "clone", "--depth", "1", "-b", "v2.0", base46_repo, lazy_path }
shell_call { "git", "clone", "--depth", "1", "-b", "v3.0", base46_repo, lazy_path }
vim.opt.rtp:prepend(lazy_path)
require("base46").compile()

View File

@ -1,12 +1,9 @@
local opt = vim.opt
local g = vim.g
local config = require("core.utils").load_config()
-------------------------------------- globals -----------------------------------------
g.nvchad_theme = config.ui.theme
g.base46_cache = vim.fn.stdpath "data" .. "/nvchad/base46/"
g.toggle_theme_icon = ""
g.transparency = config.ui.transparency
-------------------------------------- options ------------------------------------------
opt.laststatus = 3 -- global statusline
@ -83,11 +80,11 @@ autocmd("BufWritePost", {
local app_name = vim.env.NVIM_APPNAME and vim.env.NVIM_APPNAME or "nvim"
local module = string.gsub(fp, "^.*/" .. app_name .. "/lua/", ""):gsub("/", ".")
require("plenary.reload").reload_module "nvconfig"
require("plenary.reload").reload_module "base46"
require("plenary.reload").reload_module(module)
require("plenary.reload").reload_module "custom.chadrc"
config = require("core.utils").load_config()
local config = require "nvconfig"
vim.g.nvchad_theme = config.ui.theme
vim.g.transparency = config.ui.transparency

View File

@ -7,7 +7,7 @@ M.load_config = function()
if chadrc_path then
local chadrc = dofile(chadrc_path)
config.mappings = M.remove_disabled_keys(chadrc.mappings, config.mappings)
config = merge_tb("force", config, chadrc)
config.mappings.disabled = nil
@ -74,7 +74,7 @@ M.load_mappings = function(section, mapping_opt)
end
end
local mappings = require("core.utils").load_config().mappings
local mappings = require("nvconfig").mappings
if type(section) == "string" then
mappings[section]["plugin"] = nil

2
lua/nvconfig.lua Normal file
View File

@ -0,0 +1,2 @@
-- check default config at core/default_config.lua
return require("core.utils").load_config()

View File

@ -2,7 +2,7 @@ local cmp = require "cmp"
dofile(vim.g.base46_cache .. "cmp")
local cmp_ui = require("core.utils").load_config().ui.cmp
local cmp_ui = require("nvconfig").ui.cmp
local cmp_style = cmp_ui.style
local field_arrangement = {

View File

@ -3,14 +3,13 @@ local M = {}
-- export on_attach & capabilities for custom lspconfigs
M.on_attach = function(client, bufnr)
local utils = require "core.utils"
local conf = utils.load_config().ui.lsp
local conf = require "nvconfig"
-- semanticTokens
if not conf.semantic_tokens and client.supports_method "textDocument/semanticTokens" then
client.server_capabilities.semanticTokensProvider = nil
end
-- signature
if conf.signature and client.server_capabilities.signatureHelpProvider then
require("nvchad.signature").setup(client, bufnr)
end

View File

@ -6,7 +6,7 @@ local default_plugins = {
{
"NvChad/base46",
branch = "v3.0",
branch = "test",
build = function()
require("base46").load_all_highlights()
end,
@ -14,7 +14,7 @@ local default_plugins = {
{
"NvChad/ui",
branch = "v3.0",
branch = "test",
lazy = false,
config = function()
require "nvchad"
@ -258,7 +258,7 @@ local default_plugins = {
},
}
local config = require("core.utils").load_config()
local config = require "nvconfig"
if #config.plugins > 0 then
table.insert(default_plugins, { import = config.plugins })