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

Allow overwriting insert mode maps #1030

Merged
merged 1 commit into from
Oct 20, 2020
Merged

Conversation

davidsierradz
Copy link
Contributor

According to :h hasmapto() if we don't pass the mode as an argument then only normal, visual and operator-pending modes are checked.

Lets pass the mode explicitly to allow overwriting insert mode mappings.

I think this will fix: #1021

Original PR that introduced vimwiki#u#map_key(): #686

With this minimal .vimrc | init.vim:

call plug#begin('~/.config/nvim/plugged')
Plug 'vimwiki/vimwiki', { 'branch': 'dev' }
call plug#end()
let g:vimwiki_list = [
      \ {'path': '~/notes/',
      \ 'syntax': 'markdown', 'ext': '.md'}]
imap <F13> <Plug>VimwikiIncreaseLvlSingleItem
inoremap <C-T> <Esc>

Notice I want to remap <C-T> in insert mode. We should only need to remap <Plug>VimwikiIncreaseLvlSingleItem to another key (<F13> in this case) and vimwiki should not apply this: call vimwiki#u#map_key('i', '<C-T>', '<Plug>VimwikiIncreaseLvlSingleItem') from ftplugin/vimwiki.vim.

Without this patch this is not happening, :verbose imap <C-T>:

image

With the patch:

image

I searched all vimwiki codebase and noticed all vimwiki#u#map_key calls always have the mode as first argument, so I think this is a safe fix. Writing a test is above my knowledge/time.

Steps for submitting a pull request:

  • ALL pull requests should be made against the dev branch!
  • Take a look at CONTRIBUTING.MD
  • Reference any related issues.
  • Provide a description of the proposed changes.
  • PRs must pass Vint tests and add new Vader tests as applicable.
  • Make sure to update the documentation in doc/vimwiki.txt if applicable,
    including the Changelog and Contributors sections.

According to `:h hasmapto()` if we don't pass the mode as an argument
then only normal, visual and operator-pending modes are checked.

Lets pass the mode explicitly to allow overwriting insert mode mappings.
@tinmarino
Copy link
Member

Wonderfull!! => this will actually remove many bugs <= no plugin should overwrite the other without user consentment: ticket statistic is demonstrating that.

This does not "fix" #1021 because #1021 is a desired behavior. See my comment there.

Thank you!

amitbeka pushed a commit to amitbeka/vimwiki that referenced this pull request Nov 9, 2020
Mapping `<Tab>` and `<S-Tab>` at insert mode sometimes collide with
other plugins which utilize these for completions (e.g. coc example
mapping).

Since for many users the case for completion is more frequent than table
editing, this patch enables changing these mappings using the options
`g:vimwiki_tbl_next_cell` and `g:vimwiki_tbl_prev_cell`.

This patch makes it easier of those using multiple plugins and have no
desire or knowledge in debugging the collision.
It complements vimwiki#1030 by providing a more direct and documented method
for setting custom keymappings.

Signed-off-by: Amit Beka <--->
amitbeka pushed a commit to amitbeka/vimwiki that referenced this pull request Nov 15, 2020
Mapping `<Tab>` and `<S-Tab>` at insert mode sometimes collide with
other plugins which utilize these for completions (e.g. coc example
mapping).

Since for many users the case for completion is more frequent than table
editing, this patch enables changing these mappings using the options
`<Plug>VimwikiTableNextCell` and `<Plug>VimwikiTablePrevCell`.

This patch makes it easier of those using multiple plugins and have no
desire or knowledge in debugging the collision.
It complements vimwiki#1030 by providing a more direct and documented method
for setting custom keymappings.

Signed-off-by: Amit Beka <--->
amitbeka pushed a commit to amitbeka/vimwiki that referenced this pull request Nov 18, 2020
Mapping `<Tab>` and `<S-Tab>` at insert mode sometimes collide with
other plugins which utilize these for completions (e.g. coc example
mapping).

Since for many users the case for completion is more frequent than table
editing, this patch enables changing these mappings using the options
`<Plug>VimwikiTableNextCell` and `<Plug>VimwikiTablePrevCell`.

This patch makes it easier of those using multiple plugins and have no
desire or knowledge in debugging the collision.
It complements vimwiki#1030 by providing a more direct and documented method
for setting custom keymappings.

Signed-off-by: Amit Beka <--->
tinmarino pushed a commit that referenced this pull request Nov 19, 2020
Mapping `<Tab>` and `<S-Tab>` at insert mode sometimes collide with
other plugins which utilize these for completions (e.g. coc example
mapping).

Since for many users the case for completion is more frequent than table
editing, this patch enables changing these mappings using the options
`<Plug>VimwikiTableNextCell` and `<Plug>VimwikiTablePrevCell`.

This patch makes it easier of those using multiple plugins and have no
desire or knowledge in debugging the collision.
It complements #1030 by providing a more direct and documented method
for setting custom keymappings.

Signed-off-by: Amit Beka <--->

Co-authored-by: Amit Beka <--->
deepredsky pushed a commit to deepredsky/vimwiki that referenced this pull request Jan 16, 2021
According to `:h hasmapto()` if we don't pass the mode as an argument
then only normal, visual and operator-pending modes are checked.

Lets pass the mode explicitly to allow overwriting insert mode mappings.
jls83 pushed a commit to jls83/vimwiki that referenced this pull request Jan 17, 2023
According to `:h hasmapto()` if we don't pass the mode as an argument
then only normal, visual and operator-pending modes are checked.

Lets pass the mode explicitly to allow overwriting insert mode mappings.
jls83 pushed a commit to jls83/vimwiki that referenced this pull request Jan 17, 2023
Mapping `<Tab>` and `<S-Tab>` at insert mode sometimes collide with
other plugins which utilize these for completions (e.g. coc example
mapping).

Since for many users the case for completion is more frequent than table
editing, this patch enables changing these mappings using the options
`<Plug>VimwikiTableNextCell` and `<Plug>VimwikiTablePrevCell`.

This patch makes it easier of those using multiple plugins and have no
desire or knowledge in debugging the collision.
It complements vimwiki#1030 by providing a more direct and documented method
for setting custom keymappings.

Signed-off-by: Amit Beka <--->

Co-authored-by: Amit Beka <--->
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.

None yet

2 participants