Skip to content
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

Way to prevent autocomplete if Esc is pressed? #152

Open
sainttttt opened this issue Mar 1, 2024 · 2 comments
Open

Way to prevent autocomplete if Esc is pressed? #152

sainttttt opened this issue Mar 1, 2024 · 2 comments

Comments

@sainttttt
Copy link

sainttttt commented Mar 1, 2024

Hi! I'd like it so that if I press Esc (leaving insert mode) without entering another subsequent character, the autocomplete won't trigger. So for example just entering (<Esc> would end up with ( or ('<Esc> would give me (', but entering ('h<Esc> would give me ('h'). Would this be possible at all? I sort of have this functionality with some basic vim mappings as follows:

imap [<esc> <c-v>[<esc>
imap ['<esc> <c-v>[<c-v>'<esc>
imap ["<esc> <c-v>[<c-v>"<esc>
imap ']<esc> <c-v>'<c-v>]<esc>
imap "]<esc> <c-v>"<c-v>]<esc>

imap {<esc> <c-v>{<esc>
imap {'<esc> <c-v>{<c-v>'<esc>
imap {"<esc> <c-v>{<c-v>"<esc>
imap '}<esc> <c-v>'<c-v>}<esc>
imap "}<esc> <c-v>"<c-v>}<esc>

imap (<esc> <c-v>(<esc>
imap ('<esc> <c-v>(<c-v>'<esc>
imap ("<esc> <c-v>(<c-v>"<esc>
imap ')<esc> <c-v>'<c-v>)<esc>
imap ")<esc> <c-v>"<c-v>)<esc>

imap '<esc> <c-v>'<esc>
imap "<esc> <c-v>"<esc>

imap "" <c-v>"<c-v>"

But the main issue being is that for multiple char imappings, it doesn't show all the characters on the screen as you type, but just one at a time, which is a bit jarring. Any help would be appreciated.

Thanks!

@sainttttt sainttttt changed the title Is there a way to prevent autocomplete if Esc is pressed? Way to prevent autocomplete if Esc is pressed? Mar 1, 2024
@cohama
Copy link
Owner

cohama commented Apr 1, 2024

I'm sorry for slow response. I was on vacation.

Do you mean the followings?

| char  | buffer |
------------------
| (     | (      |
| h     | (h     |
| <Esc> | (h)    |

In other words, if <Esc> pressed, close parens will be inserted?

@sainttttt
Copy link
Author

| char  | buffer |
------------------
| (     | (      |
| h     | (h)    |
| char  | buffer |
------------------
| (     | (      |
| <Esc> | (      |

I mean something like this. So that if I enter another character it will trigger the autoclose, but if I just hit escape before entering another character, the autoclose doesn't happen. This is useful if I want to just insert a single ( or other autoclose character on a line.

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

No branches or pull requests

2 participants