Skip to content

Commit 49b033a

Browse files
committed
feat: default to not showing in snippet
closes #131
1 parent b930285 commit 49b033a

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lua/blink/cmp/config.lua

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
--- @field blocked_trigger_characters? string[]
3838
--- @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
3939
--- @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
40+
--- @field show_in_snippet? boolean When false, will not show the completion window when in a snippet
4041
---
4142
--- @class blink.cmp.SignatureHelpTriggerConfig
4243
--- @field enabled? boolean
@@ -203,6 +204,8 @@ local config = {
203204
show_on_insert_on_trigger_character = true,
204205
-- list of additional trigger characters that won't trigger the completion window when the cursor comes after a trigger character when entering insert mode
205206
show_on_insert_blocked_trigger_characters = { "'", '"' },
207+
-- when false, will not show the completion window when in a snippet
208+
show_in_snippet = false,
206209
},
207210

208211
signature_help = {

lua/blink/cmp/trigger/completion.lua

+10-2
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,25 @@ local trigger = {
1818
},
1919
}
2020

21+
--- TODO: sweet mother of mary, massive refactor needed
2122
function trigger.activate_autocmds()
2223
local last_char = ''
2324
vim.api.nvim_create_autocmd('InsertCharPre', {
24-
callback = function() last_char = vim.v.char end,
25+
callback = function()
26+
if vim.snippet.active() and not config.show_in_snippet and not trigger.context then return end
27+
last_char = vim.v.char
28+
end,
2529
})
2630

2731
-- decide if we should show the completion window
2832
vim.api.nvim_create_autocmd('TextChangedI', {
2933
callback = function()
34+
if vim.snippet.active() and not config.show_in_snippet and not trigger.context then
35+
return
36+
3037
-- we were told to ignore the text changed event, so we update the context
3138
-- but don't send an on_show event upstream
32-
if trigger.ignore_next_text_changed then
39+
elseif trigger.ignore_next_text_changed then
3340
if trigger.context ~= nil then trigger.show({ send_upstream = false }) end
3441
trigger.ignore_next_text_changed = false
3542

@@ -62,6 +69,7 @@ function trigger.activate_autocmds()
6269
vim.api.nvim_create_autocmd({ 'CursorMovedI', 'InsertEnter' }, {
6370
callback = function(ev)
6471
if utils.is_blocked_buffer() then return end
72+
if vim.snippet.active() and not config.show_in_snippet and not trigger.context then return end
6573

6674
-- we were told to ignore the cursor moved event, so we update the context
6775
-- but don't send an on_show event upstream

0 commit comments

Comments
 (0)