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

<CR> mapping change #813

Closed
Rich-YoYo opened this issue Jan 28, 2020 · 6 comments
Closed

<CR> mapping change #813

Rich-YoYo opened this issue Jan 28, 2020 · 6 comments

Comments

@Rich-YoYo
Copy link

Rich-YoYo commented Jan 28, 2020

I found that a mapping defined in vimwiki was interfering with use of the popup/completion menu. The following change fixes it for the completion menu, but as I'm not quite sure what it's supposed to do in vimwiki, I can't be sure I've not broken the existing mapping. Anyway, it's at line 570 in ./ftplugin/vimwiki.vim;-

if !hasmapto('VimwikiReturn', 'i')
  if maparg('<CR>', 'i') !~? '<Esc>:VimwikiReturn'
    "inoremap <silent><buffer> <CR> <Esc>:VimwikiReturn 1 5<CR>
    " ### I CHANGED THE ABOVE LINE TO THIS... ####
    " Avoid interfering with popup/completion menu if it's active
    inoremap <expr><silent><buffer> <CR> pumvisible() ? "\<CR>" : "\<Esc>:VimwikiReturn 1 5\<CR>"
  endif
  if maparg('<S-CR>', 'i') !~? '<Esc>:VimwikiReturn'
    inoremap <silent><buffer> <S-CR> <Esc>:VimwikiReturn 2 2<CR>
  endif
endif
@ranebrown
Copy link
Contributor

The VimwikiReturn mappings are used with lists to properly continue the list. If that interferes with some other <CR> mapping you can disable the mappings (only possible on the dev branch right now) or just redefine them as you have done but in your vimrc.

@Rich-YoYo
Copy link
Author

While I understand what you're saying (and it's not my project, so who am I to complain?), the problem I found is interfering with base vim functionality - ie, popup auto-complete menus like spellcheck. It's not that it's clashing with some other plugin or my my own random stuff. As such, it looks to me that the mapping should try and avoid the problem. As it stands, this mapping breaks every single vim instance; not just my particular configuration, so it seems "wrong" to have to define an external mapping to get round the problem, especially as that external mapping would have to be aware of internal vimwiki workings (in order to set the mapping to correctly point to 'VimWikiReturn')

@ranebrown
Copy link
Contributor

I was thinking it was related to another completion plugin. I agree we shouldn't break default vim behavior if possible.

@tinmarino
Copy link
Member

@Rich-YoYo can you make a PR ?

@tinmarino tinmarino added the bug label Aug 5, 2020
@tinmarino tinmarino added this to Needs triage in Bug Triage Deprecated via automation Aug 5, 2020
@tinmarino tinmarino moved this from Needs triage to Low priority in Bug Triage Deprecated Aug 5, 2020
@Rich-YoYo
Copy link
Author

I'm sorry, github (indeed, git) is a bit of a mystery to me; it seems to work counter to any other vcs I've ever used - I'm not even sure what a "pull request" is. I don't think I can contribute anything beyond the suggested patch that I posted (which may or may not be correct?)

tinmarino added a commit to tinmarino/vimwiki that referenced this issue Aug 5, 2020
…vimwiki#813)

Problem: When pum opened, the mapping of <CR> is triggered but user
want the default behaviour: to choose a completion item

Solution: Conditional mapping:
inoremap <expr><silent><buffer> <CR> pumvisible() ? '<CR>' : ':<Esc>:VimwikiReturn 1 5<Cr>'
                         The previous mapping  -----------------^
tinmarino added a commit to tinmarino/vimwiki that referenced this issue Aug 5, 2020
…vimwiki#813)

Problem: When pum opened, the mapping of <CR> is triggered but user
want the default behaviour: to choose a completion item

Solution: Conditional mapping:
inoremap <expr><silent><buffer> <CR> pumvisible() ? '<CR>' : ':<Esc>:VimwikiReturn 1 5<Cr>'
                         The previous mapping  -----------------^
@tinmarino
Copy link
Member

@Rich-YoYo fixed by: e4186ad (or last commit in dev referring this issue)

Thank you for the commented path it worked like charm and I learned the imap <expr> style which is perfect for this case.

Good job !

Bug Triage Deprecated automation moved this from Low priority to Closed Aug 5, 2020
deepredsky pushed a commit to deepredsky/vimwiki that referenced this issue Jan 16, 2021
…vimwiki#813)

Problem: When pum opened, the mapping of <CR> is triggered but user
want the default behaviour: to choose a completion item

Solution: Conditional mapping:
inoremap <expr><silent><buffer> <CR> pumvisible() ? '<CR>' : ':<Esc>:VimwikiReturn 1 5<Cr>'
                         The previous mapping  -----------------^
jls83 pushed a commit to jls83/vimwiki that referenced this issue Jan 17, 2023
…vimwiki#813)

Problem: When pum opened, the mapping of <CR> is triggered but user
want the default behaviour: to choose a completion item

Solution: Conditional mapping:
inoremap <expr><silent><buffer> <CR> pumvisible() ? '<CR>' : ':<Esc>:VimwikiReturn 1 5<Cr>'
                         The previous mapping  -----------------^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

No branches or pull requests

3 participants