Fix duplicate setup

This commit is contained in:
hrsh7th
2021-08-17 23:28:10 +09:00
parent 38612b4aa4
commit 24158a72b2
2 changed files with 10 additions and 13 deletions

View File

@@ -74,7 +74,7 @@ end
core.on_keymap = function(keys, fallback)
for key, action in pairs(config.get().mapping) do
if key == keys then
return action(core, fallback)
return action.invoke(core, fallback)
end
end

View File

@@ -2,22 +2,19 @@ local types = require('cmp.types')
local mapping = {}
mapping.mode = function(modes, action)
if type(action) == 'table' then
if type(action.action) == 'function' then
action = action.action
mapping.mode = function(modes, action_or_invoke)
local invoke = action_or_invoke
if type(action_or_invoke) == 'table' then
if type(action_or_invoke.invoke) == 'function' then
invoke = action_or_invoke.invoke
else
error('`action` must be function or result of `cmp.mapping.mode`.')
error('`invoke` must be function or result of `cmp.mapping.mode`.')
end
end
return setmetatable({
return {
modes = modes,
action = action,
}, {
__call = function(_, ...)
action(...)
end,
})
invoke = invoke,
}
end
mapping.complete = function()