Skip to content

Commit

Permalink
Fix #1102
Browse files Browse the repository at this point in the history
  • Loading branch information
hrsh7th committed Aug 14, 2022
1 parent 983453e commit 8523568
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lua/cmp/config/mapping.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@ local misc = require('cmp.utils.misc')
local feedkeys = require('cmp.utils.feedkeys')
local keymap = require('cmp.utils.keymap')

local function merge_keymaps(base, override)
local normalized_base = {}
for k, v in pairs(base) do
normalized_base[keymap.normalize(k)] = v
end

local normalized_override = {}
for k, v in pairs(override) do
normalized_override[keymap.normalize(k)] = v
end

return misc.merge(normalized_base, normalized_override)
end

local mapping = setmetatable({}, {
__call = function(_, invoke, modes)
if type(invoke) == 'function' then
Expand All @@ -21,7 +35,7 @@ mapping.preset = {}

---Mapping preset insert-mode configuration.
mapping.preset.insert = function(override)
return misc.merge(override or {}, {
return merge_keymaps(override or {}, {
['<Down>'] = {
i = mapping.select_next_item({ behavior = types.cmp.SelectBehavior.Select }),
},
Expand All @@ -45,7 +59,7 @@ end

---Mapping preset cmdline-mode configuration.
mapping.preset.cmdline = function(override)
return misc.merge(override or {}, {
return merge_keymaps(override or {}, {
['<Tab>'] = {
c = function()
local cmp = require('cmp')
Expand Down

0 comments on commit 8523568

Please sign in to comment.