fix: fixed invalid index referencing in table due to user-specified invalid mapping configuration
This commit is contained in:
parent
d3d9aa251a
commit
96d83ab549
|
@ -0,0 +1,20 @@
|
|||
---@type ChadrcConfig
|
||||
local M = {}
|
||||
|
||||
-- Path to overriding theme and highlights files
|
||||
local highlights = require "custom.highlights"
|
||||
|
||||
M.ui = {
|
||||
theme = "jellybeans",
|
||||
-- theme_toggle = { "onedark", "one_light" },
|
||||
|
||||
hl_override = highlights.override,
|
||||
hl_add = highlights.add,
|
||||
}
|
||||
|
||||
M.plugins = "custom.plugins"
|
||||
|
||||
-- check core.mappings for table structure
|
||||
M.mappings = require "custom.mappings"
|
||||
|
||||
return M
|
|
@ -53,6 +53,7 @@ end
|
|||
|
||||
M.load_mappings = function(section, mapping_opt)
|
||||
vim.schedule(function()
|
||||
local function sec_section_map_func()
|
||||
local function set_section_map(section_values)
|
||||
if section_values.plugin then
|
||||
return
|
||||
|
@ -76,6 +77,7 @@ M.load_mappings = function(section, mapping_opt)
|
|||
|
||||
local mappings = require("core.utils").load_config().mappings
|
||||
|
||||
|
||||
if type(section) == "string" then
|
||||
mappings[section]["plugin"] = nil
|
||||
mappings = { mappings[section] }
|
||||
|
@ -84,7 +86,15 @@ M.load_mappings = function(section, mapping_opt)
|
|||
for _, sect in pairs(mappings) do
|
||||
set_section_map(sect)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local ok, err = pcall(sec_section_map_func)
|
||||
if ok == false then
|
||||
local chadrc_path = vim.api.nvim_get_runtime_file("lua/custom/chadrc.lua", false)[1]
|
||||
error(string.format("check mappings in %s => %s", chadrc_path, err))
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
M.lazy_load = function(plugin)
|
||||
|
|
Loading…
Reference in New Issue