29
29
--- @param key string
30
30
--- @return vim.api.keyset.keymap ?
31
31
function fallback .get_non_blink_buffer_mapping_for_key (mode , key )
32
- local ret = vim .fn .maparg (key , mode , false , true ) --[[ @as vim.api.keyset.keymap]]
33
- if ret and ret .buffer == 0 then return end
34
- if ret and ret .desc and ret .desc == ' blink.cmp' then return end
35
- return ret .lhs ~= nil and ret or nil
32
+ local normalized_key = vim .api .nvim_replace_termcodes (key , true , true , true )
33
+
34
+ local buffer_mappings = vim .api .nvim_buf_get_keymap (0 , mode )
35
+
36
+ for _ , mapping in ipairs (buffer_mappings ) do
37
+ local mapping_key = vim .api .nvim_replace_termcodes (mapping .lhs , true , true , true )
38
+ if mapping_key == normalized_key and mapping .desc ~= ' blink.cmp' then return mapping end
39
+ end
36
40
end
37
41
38
42
--- Returns a function that will run the first non blink.cmp keymap for the given mode and key
@@ -44,6 +48,7 @@ function fallback.wrap(mode, key)
44
48
return function ()
45
49
local mapping = buffer_mapping or fallback .get_non_blink_global_mapping_for_key (mode , key )
46
50
if mapping then return fallback .run_non_blink_keymap (mapping , key ) end
51
+ return vim .api .nvim_replace_termcodes (key , true , true , true )
47
52
end
48
53
end
49
54
0 commit comments