Skip to content

Commit

Permalink
adding support for '- [ ]: ' checkboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
huynle committed Jan 4, 2023
1 parent 746f92a commit af1d45c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions plugin/bullets.vim
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ fun! s:match_checkbox_bullet_item(input_text)
" match any symbols listed in g:bullets_checkbox_markers as well as the
" default ' ', 'x', and 'X'
let l:checkbox_bullet_regex =
\ '\v(^(\s*)([-\*] \[(['
\ '\v(^(\s*)([+-\*] \[(['
\ . g:bullets_checkbox_markers
\ . ' xX])?\])(\s+))(.*)'
\ . ' xX])?\])(:?)(\s+))(.*)'
let l:matches = matchlist(a:input_text, l:checkbox_bullet_regex)

if empty(l:matches)
Expand All @@ -256,16 +256,17 @@ fun! s:match_checkbox_bullet_item(input_text)
let l:leading_space = l:matches[2]
let l:bullet = l:matches[3]
let l:checkbox_marker = l:matches[4]
let l:trailing_space = l:matches[5]
let l:text_after_bullet = l:matches[6]
let l:trailing_char = l:matches[5]
let l:trailing_space = l:matches[6]
let l:text_after_bullet = l:matches[7]

return {
\ 'bullet_type': 'chk',
\ 'bullet_length': l:bullet_length,
\ 'leading_space': l:leading_space,
\ 'bullet': l:bullet,
\ 'checkbox_marker': l:checkbox_marker,
\ 'closure': '',
\ 'closure': l:trailing_char,
\ 'trailing_space': l:trailing_space,
\ 'text_after_bullet': l:text_after_bullet
\ }
Expand Down Expand Up @@ -544,7 +545,7 @@ endfun
" Checkboxes ---------------------------------------------- {{{
fun! s:find_checkbox_position(lnum)
let l:line_text = getline(a:lnum)
return matchend(l:line_text, '\v\s*(\*|-) \[')
return matchend(l:line_text, '\v\s*(\*|-|\+) \[')
endfun

fun! s:select_checkbox(inner)
Expand Down

0 comments on commit af1d45c

Please sign in to comment.