committed by
GitHub
parent
2e1f82d8c0
commit
070a57a195
@@ -147,6 +147,20 @@ local function merge_mappings(user_mappings)
|
|||||||
return vim.fn.extend(mappings, user_mappings)
|
return vim.fn.extend(mappings, user_mappings)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function copy_mappings(user_mappings)
|
||||||
|
if #user_mappings == 0 then
|
||||||
|
return M.mappings
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, map in pairs(user_mappings) do
|
||||||
|
if map.action and type(map.action_cb) == "function" then
|
||||||
|
M.custom_keypress_funcs[map.action] = map.action_cb
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return user_mappings
|
||||||
|
end
|
||||||
|
|
||||||
local DEFAULT_MAPPING_CONFIG = {
|
local DEFAULT_MAPPING_CONFIG = {
|
||||||
custom_only = false,
|
custom_only = false,
|
||||||
list = {}
|
list = {}
|
||||||
@@ -161,7 +175,7 @@ function M.setup(opts)
|
|||||||
local user_map_config = (opts.view or {}).mappings or {}
|
local user_map_config = (opts.view or {}).mappings or {}
|
||||||
local options = vim.tbl_deep_extend('force', DEFAULT_MAPPING_CONFIG, user_map_config)
|
local options = vim.tbl_deep_extend('force', DEFAULT_MAPPING_CONFIG, user_map_config)
|
||||||
if options.custom_only then
|
if options.custom_only then
|
||||||
M.mappings = options.list
|
M.mappings = copy_mappings(options.list)
|
||||||
else
|
else
|
||||||
M.mappings = merge_mappings(options.list)
|
M.mappings = merge_mappings(options.list)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user