From b5d808b4402ac5f023e6223fb2f512f1fe42af18 Mon Sep 17 00:00:00 2001 From: Rane Brown Date: Sun, 11 Aug 2019 07:13:01 -0600 Subject: [PATCH] Don't use definitions for VimwikiReturn mappings. This is necessary to properly allow the user to remap these since there are different arguments to the command. The documentation regarding this command was also updated to be more clear. --- doc/vimwiki.txt | 24 ++++++++++++++---------- ftplugin/vimwiki.vim | 37 ++++++++++++++++++------------------- 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index 40753cf..46dbda2 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -620,7 +620,6 @@ LIST MAPPINGS, INSERT MODE *vimwiki-list-mappings* useful to end a list, simply press twice. See |vimwiki-lists| for details and for how to configure the behavior. - Remap command: `VimwikiReturn15` *vimwiki_i_* Does not insert a new list item, useful to create @@ -628,7 +627,6 @@ LIST MAPPINGS, INSERT MODE *vimwiki-list-mappings* details and for how to configure the behavior. The default map may not work in all terminals and may need to be remapped. - Remap command: `VimwikiReturn22` *vimwiki_i_* Increase the level of a list item. @@ -1619,20 +1617,26 @@ used. While writing lists, the keys , o and O insert new bullets or numbers as you would expect it. A new bullet/number is inserted if and only if the cursor -is in a list item. To make a list item with more than one line, press -or press and . +is in a list item. If you use hard line wraps within your lists then you will +need to remap `` to `VimwikiReturn 3 5`, use , or press and +. + Note that the mapping is not available in all terminals. Furthermore, and behave differently when the cursor is behind an empty list item. See the table below. -To remap the default behavior: > - :imap e VimwikiReturn15 - :imap r VimwikiReturn22 +To customize the behavior you should use an autocmd or place the mappings in +`~/.vim/after/ftplugin/vimwiki.vim`. This is necessary to avoid an error that +the command `VimwikiReturn` doesn't exist when editing non Vimwiki files.: > -To customize the behavior: > - inoremap :VimwikiReturn 1 1 - inoremap :VimwikiReturn 3 5 + autocmd FileType vimwiki inoremap + \ :VimwikiReturn 3 5 + autocmd FileType vimwiki inoremap + \ :VimwikiReturn 2 2 + +Note: Prefixing the mapping with `` expands iabbrev definitions and +requires Vim > 7.3.489. The first argument of the command :VimwikiReturn is a number that specifies when to insert a new bullet/number and when not, depending on whether the diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim index 6f12577..f2fc48e 100644 --- a/ftplugin/vimwiki.vim +++ b/ftplugin/vimwiki.vim @@ -438,16 +438,6 @@ nnoremap VimwikiListo \ :call vimwiki#lst#kbd_o() nnoremap VimwikiListO \ :call vimwiki#lst#kbd_O() -if has('patch-7.3.489') - " expand iabbrev on enter - inoremap VimwikiReturn15 - \ :VimwikiReturn 1 5 -else - inoremap VimwikiReturn15 - \ :VimwikiReturn 1 5 -endif -inoremap VimwikiReturn22 - \ :VimwikiReturn 2 2 " default lists key mappings if str2nr(vimwiki#vars#get_global('key_mappings').lists) @@ -482,8 +472,19 @@ if str2nr(vimwiki#vars#get_global('key_mappings').lists) call vimwiki#u#map_key('n', 'gL', 'VimwikiRemoveCBInList') call vimwiki#u#map_key('n', 'o', 'VimwikiListo') call vimwiki#u#map_key('n', 'O', 'VimwikiListO') - call vimwiki#u#map_key('i', '', 'VimwikiReturn15') - call vimwiki#u#map_key('i', '', 'VimwikiReturn22') + + " handle case of existing VimwikiReturn mappings outside the definition + if maparg('', 'i') !~# '.*VimwikiReturn*.' + if has('patch-7.3.489') + " expand iabbrev on enter + inoremap :VimwikiReturn 1 5 + else + inoremap :VimwikiReturn 1 5 + endif + endif + if maparg('', 'i') !~# '.*VimwikiReturn*.' + inoremap :VimwikiReturn 2 2 + endif " change symbol for bulleted lists for s:char in vimwiki#vars#get_syntaxlocal('bullet_types') @@ -521,13 +522,11 @@ if str2nr(vimwiki#vars#get_global('key_mappings').lists) endif function! s:CR(normal, just_mrkr) - if str2nr(vimwiki#vars#get_global('key_mappings').table_mappings) - let res = vimwiki#tbl#kbd_cr() - if res != "" - exe "normal! " . res . "\" - startinsert - return - endif + let res = vimwiki#tbl#kbd_cr() + if res != "" + exe "normal! " . res . "\" + startinsert + return endif call vimwiki#lst#kbd_cr(a:normal, a:just_mrkr) endfunction