Fix duplicate setup
This commit is contained in:
@@ -74,7 +74,7 @@ end
|
|||||||
core.on_keymap = function(keys, fallback)
|
core.on_keymap = function(keys, fallback)
|
||||||
for key, action in pairs(config.get().mapping) do
|
for key, action in pairs(config.get().mapping) do
|
||||||
if key == keys then
|
if key == keys then
|
||||||
return action(core, fallback)
|
return action.invoke(core, fallback)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -2,22 +2,19 @@ local types = require('cmp.types')
|
|||||||
|
|
||||||
local mapping = {}
|
local mapping = {}
|
||||||
|
|
||||||
mapping.mode = function(modes, action)
|
mapping.mode = function(modes, action_or_invoke)
|
||||||
if type(action) == 'table' then
|
local invoke = action_or_invoke
|
||||||
if type(action.action) == 'function' then
|
if type(action_or_invoke) == 'table' then
|
||||||
action = action.action
|
if type(action_or_invoke.invoke) == 'function' then
|
||||||
|
invoke = action_or_invoke.invoke
|
||||||
else
|
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
|
||||||
end
|
end
|
||||||
return setmetatable({
|
return {
|
||||||
modes = modes,
|
modes = modes,
|
||||||
action = action,
|
invoke = invoke,
|
||||||
}, {
|
}
|
||||||
__call = function(_, ...)
|
|
||||||
action(...)
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
mapping.complete = function()
|
mapping.complete = function()
|
||||||
|
|||||||
Reference in New Issue
Block a user