Skip to content

fix: close completion window on ctrl+c in insert mode #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 9, 2024

Conversation

smjonas
Copy link
Contributor

@smjonas smjonas commented Oct 9, 2024

As a nvim-cmp user, I was used to close the completion window with ctrl+c (it's kind of muscle memory at this point).
So I wanted to add the ability to blink.cmp too. Before this PR, the completion would not be closed as C-c does not trigger the InsertLeave autocommand in Vim/Nvim.

Currently, it looks like this:
image
Notice that my cursor is on line 13, outside of the completion window after I pressed ctrl+c.

For reference, nvim-cmp does something similar here:

https://github.com/hrsh7th/nvim-cmp/blob/ae644feb7b67bf1ce4260c231d1d4300b19c6f30/plugin/cmp.lua#L43-L54

@Saghen
Copy link
Owner

Saghen commented Oct 9, 2024

Would using keymap.hide = '<C-c>' work for your case or am I misunderstanding?

@smjonas
Copy link
Contributor Author

smjonas commented Oct 9, 2024

That's not quite the same as that overrides the default behavior of <C-c> in insert mode (which enters normal mode by default). Whether this is added to keymap.hide or not, I still think the completion window should not remain open if a user presses ctrl+c.

@Saghen
Copy link
Owner

Saghen commented Oct 9, 2024

Ah, that checks out. Minor change, directly call trigger.hide instead of triggering the autocmd

@Saghen Saghen merged commit e695c79 into Saghen:main Oct 9, 2024
@Saghen
Copy link
Owner

Saghen commented Oct 9, 2024

Thanks!

@smjonas smjonas deleted the fix_ctrl_c branch October 9, 2024 17:20
lopi-py pushed a commit to lopi-py/blink.cmp that referenced this pull request Oct 10, 2024
lopi-py pushed a commit to lopi-py/blink.cmp that referenced this pull request Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants