Skip to content

Commit 876707f

Browse files
committed
feat: customizable undo point
1 parent 4e9d7ca commit 876707f

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ For LazyVim/distro users, you can disable nvim-cmp via:
110110
},
111111

112112
accept = {
113+
create_undo_point = true,
113114
auto_brackets = {
114115
enabled = false,
115116
default_brackets = { '(', ')' },

lua/blink/cmp/config.lua

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
--- @field snippet_backward string | string[]
1212

1313
--- @class blink.cmp.AcceptConfig
14+
--- @field create_undo_point boolean Create an undo point when accepting a completion item
1415
--- @field auto_brackets blink.cmp.AutoBracketsConfig
1516

1617
--- @class blink.cmp.AutoBracketsConfig
@@ -33,6 +34,7 @@
3334
--- @field keyword_regex string
3435
--- @field blocked_trigger_characters string[]
3536
--- @field show_on_insert_on_trigger_character boolean When true, will show the completion window when the cursor comes after a trigger character when entering insert mode
37+
--- @field show_on_insert_blocked_trigger_characters string[] List of additional trigger characters that won't trigger the completion window when the cursor comes after a trigger character when entering insert mode
3638
---
3739
--- @class blink.cmp.SignatureHelpTriggerConfig
3840
--- @field enabled boolean
@@ -142,6 +144,7 @@ local config = {
142144
},
143145

144146
accept = {
147+
create_undo_point = true,
145148
auto_brackets = {
146149
enabled = false,
147150
default_brackets = { '(', ')' },
@@ -172,6 +175,8 @@ local config = {
172175
blocked_trigger_characters = { ' ', '\n', '\t' },
173176
-- when true, will show the completion window when the cursor comes after a trigger character when entering insert mode
174177
show_on_insert_on_trigger_character = true,
178+
-- list of additional trigger characters that won't trigger the completion window when the cursor comes after a trigger character when entering insert mode
179+
show_on_insert_blocked_trigger_characters = { "'", '"' },
175180
},
176181

177182
signature_help = {
@@ -201,7 +206,7 @@ local config = {
201206
{
202207
{ 'blink.cmp.sources.lsp' },
203208
{ 'blink.cmp.sources.path' },
204-
{ 'blink.cmp.sources.snippets', score_offset = -3 },
209+
{ 'blink.cmp.sources.snippets', score_offset = -2 },
205210
},
206211
{ { 'blink.cmp.sources.buffer' } },
207212
},

lua/blink/cmp/init.lua

+3-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ cmp.accept = function()
136136
if item == nil then return end
137137

138138
-- create an undo point
139-
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<C-g>u', true, true, true), 'n', true)
139+
if require('blink.cmp.config').accept.create_undo_point then
140+
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<C-g>u', true, true, true), 'n', true)
141+
end
140142

141143
vim.schedule(function() require('blink.cmp.accept')(item) end)
142144
return true

0 commit comments

Comments
 (0)