Skip to content

Commit 28e0b5a

Browse files
committed
feat: show completion window after accept if on trigger character
closes #198
1 parent 4de7b7e commit 28e0b5a

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lua/blink/cmp/accept/init.lua

+2
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ local function accept(item)
4343
-- todo: since we apply the additional text edits after, auto imported functions will not
4444
-- get auto brackets. If we apply them before, we have to modify the textEdit to compensate
4545
brackets_lib.add_brackets_via_semantic_token(vim.bo.filetype, item, function()
46+
require('blink.cmp.trigger.completion').show_if_on_trigger_character()
4647
require('blink.cmp.trigger.signature').show_if_on_trigger_character()
4748
text_edits_lib.apply_additional_text_edits(item)
4849
end)
4950
else
51+
require('blink.cmp.trigger.completion').show_if_on_trigger_character()
5052
require('blink.cmp.trigger.signature').show_if_on_trigger_character()
5153
text_edits_lib.apply_additional_text_edits(item)
5254
end

lua/blink/cmp/trigger/completion.lua

+8
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,14 @@ function trigger.suppress_events_for_callback(cb)
152152
and is_insert_mode
153153
end
154154

155+
function trigger.show_if_on_trigger_character()
156+
local cursor_col = vim.api.nvim_win_get_cursor(0)[2]
157+
local char_under_cursor = vim.api.nvim_get_current_line():sub(cursor_col, cursor_col)
158+
local is_on_trigger = vim.tbl_contains(sources.get_trigger_characters(), char_under_cursor)
159+
if is_on_trigger then trigger.show({ trigger_character = char_under_cursor }) end
160+
return is_on_trigger
161+
end
162+
155163
--- @param opts { trigger_character?: string, send_upstream?: boolean, force?: boolean } | nil
156164
function trigger.show(opts)
157165
opts = opts or {}

0 commit comments

Comments
 (0)