From af1d45c353544d7448cbbb794556ed256c0fe969 Mon Sep 17 00:00:00 2001 From: Huy Le Date: Wed, 4 Jan 2023 11:10:14 -0700 Subject: [PATCH 1/5] adding support for '- [ ]: ' checkboxes --- plugin/bullets.vim | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/plugin/bullets.vim b/plugin/bullets.vim index f54116f..279410f 100644 --- a/plugin/bullets.vim +++ b/plugin/bullets.vim @@ -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) @@ -256,8 +256,9 @@ 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', @@ -265,7 +266,7 @@ fun! s:match_checkbox_bullet_item(input_text) \ '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 \ } @@ -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) From a1a54079ccb90e2acb6e5b173c346f2f20fb6b88 Mon Sep 17 00:00:00 2001 From: alohaia Date: Sat, 23 Mar 2024 19:00:39 +0800 Subject: [PATCH 2/5] =?UTF-8?q?feat:=20add=20support=20for=20fullwidth=20c?= =?UTF-8?q?olon=20"=EF=BC=9A"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/bullets.vim | 3 ++- spec/nested_bullets_spec.rb | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/plugin/bullets.vim b/plugin/bullets.vim index 4be95d6..84908c6 100644 --- a/plugin/bullets.vim +++ b/plugin/bullets.vim @@ -585,7 +585,8 @@ command! InsertNewBullet call insert_new_bullet() " Helper for Colon Indent " returns 1 if current line ends in a colon, else 0 fun! s:line_ends_in_colon(lnum) - return getline(a:lnum)[strlen(getline(a:lnum))-1:] ==# ':' + let l:last_char_nr = strgetchar(getline(a:lnum), strcharlen(getline(a:lnum))-1) + return l:last_char_nr == 65306 || l:last_char_nr == 58 endfun " --------------------------------------------------------- }}} diff --git a/spec/nested_bullets_spec.rb b/spec/nested_bullets_spec.rb index a20b44e..7cdc97a 100644 --- a/spec/nested_bullets_spec.rb +++ b/spec/nested_bullets_spec.rb @@ -593,6 +593,33 @@ \ti. this bullet is indented \tii. this bullet is also indented TEXT + + write_file(filename, <<-TEXT) + # Hello there + a. this is the first bullet + TEXT + + vim.command 'let g:bullets_auto_indent_after_colon = 1' + vim.edit filename + vim.feedkeys '\' + vim.type 'GA' + vim.feedkeys '\' + vim.type 'this is the second bullet that ends with fullwidth colon:' + vim.feedkeys '\' + vim.type 'this bullet is indented' + vim.feedkeys '\' + vim.type 'this bullet is also indented' + vim.write + + file_contents = IO.read(filename) + + expect(file_contents.strip).to eq normalize_string_indent(<<-TEXT) + # Hello there + a. this is the first bullet + b. this is the second bullet that ends with fullwidth colon: + \ti. this bullet is indented + \tii. this bullet is also indented + TEXT end end end From fa9c2d519b1b320534b355534848b5855baec9ab Mon Sep 17 00:00:00 2001 From: Harshad Vedartham Date: Sun, 21 Apr 2024 09:30:31 -0700 Subject: [PATCH 3/5] Used fallback to support old vim --- plugin/bullets.vim | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugin/bullets.vim b/plugin/bullets.vim index 84908c6..e90578b 100644 --- a/plugin/bullets.vim +++ b/plugin/bullets.vim @@ -585,8 +585,14 @@ command! InsertNewBullet call insert_new_bullet() " Helper for Colon Indent " returns 1 if current line ends in a colon, else 0 fun! s:line_ends_in_colon(lnum) - let l:last_char_nr = strgetchar(getline(a:lnum), strcharlen(getline(a:lnum))-1) - return l:last_char_nr == 65306 || l:last_char_nr == 58 + let l:line = getline(a:lnum) + # Older versions of vim do not support strchar* + if exists("*strcharlen") && exists("*strcharget") + let l:last_char_nr = strgetchar(l:line, strcharlen(l:line)-1) + return l:last_char_nr == 65306 || l:last_char_nr == 58 + else + return l:line[strlen(l:line)-1:] ==# ':' + endif endfun " --------------------------------------------------------- }}} From 1167951ad1c7f22c1e69e95275941eec2a5c808b Mon Sep 17 00:00:00 2001 From: Harshad Vedartham Date: Sun, 21 Apr 2024 09:39:23 -0700 Subject: [PATCH 4/5] Bad comment format --- plugin/bullets.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/bullets.vim b/plugin/bullets.vim index e90578b..6e1860b 100644 --- a/plugin/bullets.vim +++ b/plugin/bullets.vim @@ -586,11 +586,11 @@ command! InsertNewBullet call insert_new_bullet() " returns 1 if current line ends in a colon, else 0 fun! s:line_ends_in_colon(lnum) let l:line = getline(a:lnum) - # Older versions of vim do not support strchar* if exists("*strcharlen") && exists("*strcharget") let l:last_char_nr = strgetchar(l:line, strcharlen(l:line)-1) return l:last_char_nr == 65306 || l:last_char_nr == 58 else + " Older versions of vim do not support strchar* return l:line[strlen(l:line)-1:] ==# ':' endif endfun From 9f50afc4d5c44d8faba505f4b33f80e759cc36f0 Mon Sep 17 00:00:00 2001 From: Harshad Vedartham Date: Sun, 21 Apr 2024 10:05:30 -0700 Subject: [PATCH 5/5] Wrong function --- plugin/bullets.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/bullets.vim b/plugin/bullets.vim index 6e1860b..9f9512f 100644 --- a/plugin/bullets.vim +++ b/plugin/bullets.vim @@ -586,7 +586,7 @@ command! InsertNewBullet call insert_new_bullet() " returns 1 if current line ends in a colon, else 0 fun! s:line_ends_in_colon(lnum) let l:line = getline(a:lnum) - if exists("*strcharlen") && exists("*strcharget") + if exists("*strcharlen") && exists("*strgetchar") let l:last_char_nr = strgetchar(l:line, strcharlen(l:line)-1) return l:last_char_nr == 65306 || l:last_char_nr == 58 else