Don't insert marker character with o or O within a code block.
Previously if a code block was part of a list and o or O was used a new list marker would be inserted. Also moved the is_codeblock check function to utils file for use elsewhere.
This commit is contained in:
parent
1f85a3c855
commit
a42cd58636
@ -1471,10 +1471,12 @@ function! vimwiki#lst#kbd_o()
|
|||||||
"inserting and deleting the x is necessary
|
"inserting and deleting the x is necessary
|
||||||
"because otherwise the indent is lost
|
"because otherwise the indent is lost
|
||||||
exe 'normal!' "ox\<C-H>"
|
exe 'normal!' "ox\<C-H>"
|
||||||
if parent.type != 0
|
if !vimwiki#u#is_codeblock(lnum)
|
||||||
call s:clone_marker_from_to(parent.lnum, cur_item.lnum+1)
|
if parent.type != 0
|
||||||
else
|
call s:clone_marker_from_to(parent.lnum, cur_item.lnum+1)
|
||||||
call s:indent_multiline(cur_item, cur_item.lnum+1)
|
else
|
||||||
|
call s:indent_multiline(cur_item, cur_item.lnum+1)
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
startinsert!
|
startinsert!
|
||||||
endfunction
|
endfunction
|
||||||
@ -1483,10 +1485,12 @@ endfunction
|
|||||||
function! vimwiki#lst#kbd_O()
|
function! vimwiki#lst#kbd_O()
|
||||||
exe 'normal!' "Ox\<C-H>"
|
exe 'normal!' "Ox\<C-H>"
|
||||||
let cur_ln = line('.')
|
let cur_ln = line('.')
|
||||||
if getline(cur_ln+1) !~# '^\s*$'
|
if !vimwiki#u#is_codeblock(cur_ln)
|
||||||
call s:clone_marker_from_to(cur_ln+1, cur_ln)
|
if getline(cur_ln+1) !~# '^\s*$'
|
||||||
else
|
call s:clone_marker_from_to(cur_ln+1, cur_ln)
|
||||||
call s:clone_marker_from_to(cur_ln-1, cur_ln)
|
else
|
||||||
|
call s:clone_marker_from_to(cur_ln-1, cur_ln)
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
startinsert!
|
startinsert!
|
||||||
endfunction
|
endfunction
|
||||||
@ -1548,15 +1552,6 @@ function! s:cr_on_empty_list_item(lnum, behavior)
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:is_codeblock(lnum)
|
|
||||||
let syn_g = synIDattr(synID(a:lnum,1,1),'name')
|
|
||||||
if syn_g =~# 'textSnip*' || syn_g =~# 'VimwikiPre*'
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
return 0
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:cr_on_empty_line(lnum, behavior)
|
function! s:cr_on_empty_line(lnum, behavior)
|
||||||
let lst = s:get_corresponding_item(a:lnum)
|
let lst = s:get_corresponding_item(a:lnum)
|
||||||
|
|
||||||
@ -1565,7 +1560,7 @@ function! s:cr_on_empty_line(lnum, behavior)
|
|||||||
exe 'normal!' "gi\<CR>x\<C-H>\<ESC>"
|
exe 'normal!' "gi\<CR>x\<C-H>\<ESC>"
|
||||||
|
|
||||||
if a:behavior == 2 || a:behavior == 3
|
if a:behavior == 2 || a:behavior == 3
|
||||||
if lst.type == 0 || s:is_codeblock(a:lnum)
|
if lst.type == 0 || vimwiki#u#is_codeblock(a:lnum)
|
||||||
" don't insert new bullet if not part of a list
|
" don't insert new bullet if not part of a list
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
|
@ -93,3 +93,13 @@ function vimwiki#u#map_key(mode, key, plug, ...)
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! vimwiki#u#is_codeblock(lnum)
|
||||||
|
let syn_g = synIDattr(synID(a:lnum,1,1),'name')
|
||||||
|
if syn_g =~# 'textSnip.*' || syn_g =~# 'VimwikiPre.*' || syn_g =~# '.*Comment'
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
Loading…
Reference in New Issue
Block a user