diff --git a/lua/blink/cmp/config/keymap.lua b/lua/blink/cmp/config/keymap.lua index 0f4bfe8e..0c09b4a2 100644 --- a/lua/blink/cmp/config/keymap.lua +++ b/lua/blink/cmp/config/keymap.lua @@ -24,7 +24,7 @@ --- | 'scroll_signature_down' Scroll the signature window down --- | 'snippet_forward' Move the cursor forward to the next snippet placeholder --- | 'snippet_backward' Move the cursor backward to the previous snippet placeholder ---- | (fun(cmp: blink.cmp.API): boolean?) Custom function where returning true will prevent the next command from running +--- | (fun(cmp: blink.cmp.API): string? | boolean?) Custom function where returning true will prevent the next command from running. Returning a string will insert the literal characters --- @alias blink.cmp.KeymapPreset --- | 'none' No keymaps diff --git a/lua/blink/cmp/keymap/apply.lua b/lua/blink/cmp/keymap/apply.lua index 9fa32f99..156ef70f 100644 --- a/lua/blink/cmp/keymap/apply.lua +++ b/lua/blink/cmp/keymap/apply.lua @@ -23,7 +23,9 @@ function apply.keymap_to_current_buffer(keys_to_commands) -- run user defined functions elseif type(command) == 'function' then - if command(require('blink.cmp')) then return end + local ret = command(require('blink.cmp')) + if type(ret) == 'string' then return ret end + if ret then return end -- otherwise, run the built-in command elseif require('blink.cmp')[command]() then