@ -66,15 +66,15 @@ end
M.load_mappings = function ( mappings , mapping_opt )
M.load_mappings = function ( mappings , mapping_opt )
-- set mapping function with/without whichkey
-- set mapping function with/without whichkey
local map_func
local set_maps
local whichkey_exists , wk = pcall ( require , " which-key " )
local whichkey_exists , wk = pcall ( require , " which-key " )
if whichkey_exists then
if whichkey_exists then
map_func = function ( keybind , mapping_info , opts )
set_maps = function ( keybind , mapping_info , opts )
wk.register ( { [ keybind ] = mapping_info } , opts )
wk.register ( { [ keybind ] = mapping_info } , opts )
end
end
else
else
map_func = function ( keybind , mapping_info , opts )
set_maps = function ( keybind , mapping_info , opts )
local mode = opts.mode
local mode = opts.mode
opts.mode = nil
opts.mode = nil
vim.keymap . set ( mode , keybind , mapping_info [ 1 ] , opts )
vim.keymap . set ( mode , keybind , mapping_info [ 1 ] , opts )
@ -84,20 +84,15 @@ M.load_mappings = function(mappings, mapping_opt)
mappings = mappings or vim.deepcopy ( M.load_config ( ) . mappings )
mappings = mappings or vim.deepcopy ( M.load_config ( ) . mappings )
mappings.lspconfig = nil
mappings.lspconfig = nil
for _ , section_mappings in pairs ( mappings ) do
for _ , section in pairs ( mappings ) do
-- skip mapping this as its mapppings are loaded in lspconfig
for mode , mode_values in pairs ( section ) do
for mode , mode_mappings in pairs ( section_mappings ) do
for keybind , mapping_info in pairs ( mode_values ) do
for keybind , mapping_info in pairs ( mode_mappings ) do
-- merge default + user opts
-- merge default + user opts
local default_opts = merge_tb ( " force " , { mode = mode } , mapping_opt or { } )
local default_opts = merge_tb ( " force " , { mode = mode } , mapping_opt or { } )
local opts = merge_tb ( " force " , default_opts , mapping_info.opts or { } )
local opts = merge_tb ( " force " , default_opts , mapping_info.opts or { } )
mapping_info.opts = nil
if mapping_info.opts then
set_maps ( keybind , mapping_info , opts )
mapping_info.opts = nil
end
map_func ( keybind , mapping_info , opts )
end
end
end
end
end
end
@ -127,7 +122,6 @@ M.merge_plugins = function(default_plugins)
for key , _ in pairs ( default_plugins ) do
for key , _ in pairs ( default_plugins ) do
default_plugins [ key ] [ 1 ] = key
default_plugins [ key ] [ 1 ] = key
final_table [ # final_table + 1 ] = default_plugins [ key ]
final_table [ # final_table + 1 ] = default_plugins [ key ]
end
end