jiangmiao / auto-pairs

Vim plugin, insert or delete brackets, parens, quotes in pair
http://www.vim.org/scripts/script.php?script_id=3599
4.1k stars 373 forks source link

Fast wrap not working in Windows Subsystem for Linux 2 (wsl2) #331

Closed comiluv closed 3 years ago

comiluv commented 3 years ago

Environment: Windows 10 [Version 10.0.19043.1110] WSL2 kernel version 5.10.16.3 Ubuntu 20.04 VIM version 8.1.2269 https://github.com/junegunn/vim-plug

I had to add below lines in .vimrc to map alt key combination to M- modifier, as described in this stackoverflow answer

if has('unix')
    map <Esc>e <M-e>
    map <Esc>p <M-p>
    map <Esc>n <M-n>
    map <Esc>b <M-b>
    map <Esc>j <M-j>
    map <Esc>k <M-k>
endif

Fast wrapping doesn't work in above environment, as shown in screenshot below. inubuntu

Pressing alt key combination works in Ubuntu in wsl in Windows 10, as pressing Alt-p works to disable/enable auto-pairs, and shown in below screenshot for pressing Alt-e:

화면 캡처 2021-08-07 004822

Plugin works in other environments, such as in gVim: ingvim

and in Powershell using vim for windows that comes with gVim: inpwsh

LunarWatcher commented 3 years ago

Pressing alt key combination works in Ubuntu in wsl in Windows 10, as pressing Alt-p works to disable/enable auto-pairs, and shown in below screenshot for pressing Alt-e:

Sooo what's the problem if everything works?

Don't forget verbose imap <M-e>

comiluv commented 3 years ago

Pressing alt key combination works in Ubuntu in wsl in Windows 10, as pressing Alt-p works to disable/enable auto-pairs, and shown in below screenshot for pressing Alt-e:

Sooo what's the problem if everything works?

Don't forget verbose imap <M-e>

I can see I'm pressing Alt-e in console using sed -n l, but plugin won't run fast wrap 😢 verbose imap <M-e> shows me:

i  <M-e>       *@<C-R>=AutoPairsFastWrap()<CR>
        Last set from ~/.vim/plugged/auto-pairs/plugin/auto-pairs.vim line 562
comiluv commented 3 years ago

Updated Vim version in Ubuntu to 8.2.2815 to no avail. Installed neovim version 0.6.0 and it works with neovim in Ubuntu. inneovim

LunarWatcher commented 3 years ago

Sounds like a Vim bug then. Open an issue there instead

comiluv commented 3 years ago

Probably a bug in Vim. See https://github.com/vim/vim/issues/8726

chrisbra commented 3 years ago

please describe exactly what the vim bug should be

LunarWatcher commented 3 years ago

If it works in Neovim, but not in Vim, in the same terminal, in the same Linux subsystem, it's reasonable to assume it's something preventing Vim from properly handling the input. Especially when considering it's status-norepro seemingly everywhere but Vim (and not Neovim) in WSL. I'm on a Linux machine though, so I can't verify.

comiluv commented 3 years ago

The problem is solved by using different remapping method which you can read in https://github.com/vim/vim/issues/8726, which I think is a work-around, as I could pass Alt key combinations to execute other commands successfully even with my original remappings. Nonetheless, the problem at hand is solved.