@@ -39,11 +39,10 @@ function keymap.setup(opts)
39
39
end
40
40
end
41
41
42
- -- apply keymaps
43
42
-- we set on the buffer directly to avoid buffer-local keymaps (such as from autopairs)
44
- -- from overriding our mappings
45
- keymap . apply_keymap_to_current_buffer ( insert_keys_to_commands , snippet_keys_to_commands ) -- apply immediately since the plugin starts asynchronously
46
- vim .api .nvim_create_autocmd (' BufEnter ' , {
43
+ -- from overriding our mappings. We also use InsertEnter to avoid conflicts with keymaps
44
+ -- applied on other autocmds, such as LspAttach used by nvim-lspconfig and most configs
45
+ vim .api .nvim_create_autocmd (' InsertEnter ' , {
47
46
callback = function () keymap .apply_keymap_to_current_buffer (insert_keys_to_commands , snippet_keys_to_commands ) end ,
48
47
})
49
48
end
52
51
--- @param insert_keys_to_commands table<string , string[]>
53
52
--- @param snippet_keys_to_commands table<string , string[]>
54
53
function keymap .apply_keymap_to_current_buffer (insert_keys_to_commands , snippet_keys_to_commands )
54
+ -- skip if we've already applied the keymaps
55
+ for _ , mapping in ipairs (vim .api .nvim_buf_get_keymap (0 , ' i' )) do
56
+ if mapping .desc == ' blink.cmp' then return end
57
+ end
58
+
55
59
-- insert mode: uses both snippet and insert commands
56
60
for _ , key in ipairs (utils .union_keys (insert_keys_to_commands , snippet_keys_to_commands )) do
57
61
keymap .set (' i' , key , function ()
0 commit comments