commit 84928f7ace53f4370b93a6ef637e2b0e99a502fc
parent dbe332a0958762f3423a320a5e7b4398c6473e06
Author: yuuy <weiyushuai666@gmail.com>
Date: Sat, 19 Dec 2020 11:12:06 +0800
feat(vimwiki_key_mappings):add a flag lists_return
Diffstat:
2 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/autoload/vimwiki/vars.vim b/autoload/vimwiki/vars.vim
@@ -166,8 +166,8 @@ function! s:get_default_global() abort
\ 'key_mappings': {'type': type({}), 'default':
\ {
\ 'all_maps': 1, 'global': 1, 'headers': 1, 'text_objs': 1,
- \ 'table_format': 1, 'table_mappings': 1, 'lists': 1, 'links': 1,
- \ 'html': 1, 'mouse': 0,
+ \ 'table_format': 1, 'table_mappings': 1, 'lists': 1, 'lists_return': 1,
+ \ 'links': 1, 'html': 1, 'mouse': 0,
\ }},
\ 'links_header': {'type': type(''), 'default': 'Generated Links', 'min_length': 1},
\ 'links_header_level': {'type': type(0), 'default': 1, 'min': 1, 'max': 6},
diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim
@@ -535,20 +535,23 @@ if str2nr(vimwiki#vars#get_global('key_mappings').lists)
call vimwiki#u#map_key('n', 'o', '<Plug>VimwikiListo')
call vimwiki#u#map_key('n', 'O', '<Plug>VimwikiListO')
- " Handle case of existing VimwikiReturn mappings outside the <Plug> definition
- " Note: Avoid interfering with popup/completion menu if it's active (#813)
- if maparg('<CR>', 'i') !~# '.*VimwikiReturn*.'
- if has('patch-7.3.489')
- " expand iabbrev on enter
- inoremap <expr><silent><buffer> <CR> pumvisible() ? '<CR>' : '<C-]><Esc>:VimwikiReturn 1 5<CR>'
- else
- inoremap <expr><silent><buffer> <CR> pumvisible() ? '<CR>' : '<Esc>:VimwikiReturn 1 5<CR>'
+ " Set lists_return to 0, if you don't want <CR> mapped to VimwikiReturn
+ if str2nr(vimwiki#vars#get_global('key_mappings').lists_return)
+ " Handle case of existing VimwikiReturn mappings outside the <Plug> definition
+ " Note: Avoid interfering with popup/completion menu if it's active (#813)
+ if maparg('<CR>', 'i') !~# '.*VimwikiReturn*.'
+ if has('patch-7.3.489')
+ " expand iabbrev on enter
+ inoremap <expr><silent><buffer> <CR> pumvisible() ? '<CR>' : '<C-]><Esc>:VimwikiReturn 1 5<CR>'
+ else
+ inoremap <expr><silent><buffer> <CR> pumvisible() ? '<CR>' : '<Esc>:VimwikiReturn 1 5<CR>'
+ endif
+ endif
+ if maparg('<S-CR>', 'i') !~# '.*VimwikiReturn*.'
+ inoremap <expr><silent><buffer> <S-CR> pumvisible() ? '<CR>' : '<Esc>:VimwikiReturn 2 2<CR>'
endif
endif
- if maparg('<S-CR>', 'i') !~# '.*VimwikiReturn*.'
- inoremap <expr><silent><buffer> <S-CR> pumvisible() ? '<CR>' : '<Esc>:VimwikiReturn 2 2<CR>'
- endif
-
+
" change symbol for bulleted lists
for s:char in vimwiki#vars#get_syntaxlocal('bullet_types')
if !hasmapto(':VimwikiChangeSymbolTo '.s:char.'<CR>')