Raimondi / delimitMate

Vim plugin, provides insert mode auto-completion for quotes, parens, brackets, etc.
http://www.vim.org/scripts/script.php?script_id=2754
1.98k stars 117 forks source link

`langmap=+]` causes Vim to insert "]" on "+" #197

Closed blueyed closed 9 years ago

blueyed commented 9 years ago

I am experimenting with Vim's langmap feature, and noticed that langmap=+] will cause Vim to enter ] instead of + in insert mode (the langmap is not supposed to be applied in insert mode).

This only happens when delimitMate is active.

Any idea where this might come from?

It happens both with Vim and NeoVim, both built fairly recently.

The same applies to *} (mapping * to }), which inserts } on *. It smells like it might be related to some regexp, where * and + are not handled properly maybe?!

Raimondi commented 9 years ago

Not sure what's going on, I can implement the solution on #117 but, since that won't work for those using <C-C> to leave insert mode, I'll try to find out what's going on first. Let me know if you find out anything else.

Raimondi commented 9 years ago

Could you try this code:

set langmap=01
imap 1 <C-R>=2<CR>
call feedkeys('i0')

I think the issue is with using the expression register in the mapping.

Raimondi commented 9 years ago

But matchpairs doesn't rely on <C-R>=. I'll keep looking.

Raimondi commented 9 years ago

OK, it still seems to be related to using expression with imap:

set langmap=01
imap <expr>1 2
call feedkeys('i0')
Raimondi commented 9 years ago

Well,

set langmap=01
imap 1 2
call feedkeys('i0')

also inserts 2 here. Let me know if it also does for you.

blueyed commented 9 years ago

You did not set langnoremap, did you? Using this, it inserts 0 for me with the last two comments/examples.

blueyed commented 9 years ago

Some update:

This triggers it - anything where the rhs is used by delimitMate - but not for the closing pairs ()):

set langmap=a( langnoremap

call feedkeys('ia') inserts a, and not ().

Vim 7.4.542.

blueyed commented 9 years ago

but not for the closing pairs ()):

Well, while langmap=a] inserts a, langmap=+] inserts ] though, which is where I've noticed it.

Also, langmap=ü( does work as expected (inserting ü in insert mode).

blueyed commented 9 years ago

It looks like a bug in Vim: https://groups.google.com/d/msg/vim_dev/Ro4eRg7Nb5w/K-RfngrLLf8J I've submitted a patch there (https://github.com/blueyed/vim/compare/fix-langmap-in-insmode?expand=1).

Raimondi commented 9 years ago

That's great news.