clean load_config function

based on @ii14 's comment https://github.com/NvChad/NvChad/pull/1704#discussion_r1040655958
This commit is contained in:
Sidhanth Rathod 2022-12-17 16:55:30 +05:30
parent 78b2cc3106
commit bdd142dbd6

View File

@ -4,18 +4,13 @@ local merge_tb = vim.tbl_deep_extend
M.load_config = function() M.load_config = function()
local config = require "core.default_config" local config = require "core.default_config"
-- nvim_get_runtime_file always uses forward slashes regardless of platform local chadrc_path = vim.api.nvim_get_runtime_file("lua/custom/chadrc.lua", false)[1]
local chadrc_exists = vim.api.nvim_get_runtime_file('lua/custom/chadrc.lua', false)[1]
if chadrc_exists then if chadrc_path then
local chadrc = require "custom.chadrc" local chadrc = dofile(chadrc_path)
-- merge user config if it exists and is a table; otherwise display an error
if type(chadrc) == "table" then config.mappings = M.remove_disabled_keys(chadrc.mappings, config.mappings)
config.mappings = M.remove_disabled_keys(chadrc.mappings, config.mappings) config = merge_tb("force", config, chadrc)
config = merge_tb("force", config, chadrc) or {}
else
error "chadrc must return a table!"
end
end end
config.mappings.disabled = nil config.mappings.disabled = nil