From b3215b670e7eb49eb298cb27707b9c908901719e Mon Sep 17 00:00:00 2001 From: Liam Dyer Date: Wed, 18 Dec 2024 11:51:19 -0500 Subject: [PATCH] docs: add note about hack for luasnip on accept --- lua/blink/cmp/completion/accept/init.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lua/blink/cmp/completion/accept/init.lua b/lua/blink/cmp/completion/accept/init.lua index 0c6b74a4..6c4df605 100644 --- a/lua/blink/cmp/completion/accept/init.lua +++ b/lua/blink/cmp/completion/accept/init.lua @@ -30,9 +30,12 @@ local function accept(ctx, item, callback) -- Create an undo point, if it's not a snippet, since the snippet engine should handle undo if ctx.mode == 'default' + and require('blink.cmp.config').completion.accept.create_undo_point and item.insertTextFormat ~= vim.lsp.protocol.InsertTextFormat.Snippet + -- HACK: We check the kind here because the Luasnip source returns PlainText and handles + -- expansion itself. Otherwise, Luasnip will fail to enter select mode + -- https://github.com/Saghen/blink.cmp/commit/284dd37f9bbc632f8281d6361e877db5b45e6ff0#r150498482 and item.kind ~= require('blink.cmp.types').CompletionItemKind.Snippet - and require('blink.cmp.config').completion.accept.create_undo_point then vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('u', true, true, true), 'n', true) end