From 57f289e2ebf7bb52a4e3a50ec404ef30a678db7c Mon Sep 17 00:00:00 2001 From: Harshad Vedartham Date: Fri, 2 Aug 2024 22:59:06 -0700 Subject: [PATCH 1/5] Added option and test --- plugin/bullets.vim | 11 ++++++++++- spec/bullets_spec.rb | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/plugin/bullets.vim b/plugin/bullets.vim index 9f9512f..5774921 100644 --- a/plugin/bullets.vim +++ b/plugin/bullets.vim @@ -61,6 +61,11 @@ end if !exists('g:bullets_max_alpha_characters') let g:bullets_max_alpha_characters = 2 end + +if !exists('g:bullets_enable_roman_list') + let g:bullets_enable_roman_list = 1 +end + " calculate the decimal equivalent to the last alphabetical list item let s:power = g:bullets_max_alpha_characters let s:abc_max = -1 @@ -166,12 +171,16 @@ endfun fun! s:match_roman_list_item(input_text) + if !g:bullets_enable_roman_list + return {} + endif + let l:rom_bullet_regex = join([ \ '\v\C', \ '^(', \ '(\s*)', \ '(', - \ 'M{0,4}%(CM|CD|D?C{0,3})%(XC|XL|L?X{0,3})%(IX|IV|V?I{0,3})', + \ 'M{0,4}%(CM|CD|D?C{0,3})%(XC|XL|L?X{0,3})%(IX|IV|V?I{0,3})',A \ '|', \ 'm{0,4}%(cm|cd|d?c{0,3})%(xc|xl|l?x{0,3})%(ix|iv|v?i{0,3})', \ ')', diff --git a/spec/bullets_spec.rb b/spec/bullets_spec.rb index 18a71b2..5a3452c 100644 --- a/spec/bullets_spec.rb +++ b/spec/bullets_spec.rb @@ -293,6 +293,39 @@ - TEXT end + + it 'toggles roman numeral bullets with g:bullets_enable_roman_list' do + filename = "#{SecureRandom.hex(6)}.txt" + write_file(filename, <<-TEXT) + # Hello there + i. this is the first bullet + TEXT + + vim.command 'let g:bullets_enable_roman_list = 1' + vim.edit filename + vim.type 'GA' + vim.feedkeys '\' + vim.type 'second bullet' + vim.feedkeys '\' + vim.type 'third bullet' + vim.feedkeys '\' + vim.command 'let g:bullets_enable_roman_list = 0' + vim.type 'fourth bullet' + vim.feedkeys '\' + vim.type 'fifth bullet' + vim.write + + file_contents = IO.read(filename) + + expect(file_contents).to eq normalize_string_indent(<<-TEXT) + # Hello there + i. this is the first bullet + ii. second bullet + iii. third bullet + fourth bullet + fifth bullet\n + TEXT + end end end end From 6336cee603e92fb9754d62370f573ec7941cb059 Mon Sep 17 00:00:00 2001 From: Harshad Vedartham Date: Fri, 2 Aug 2024 23:11:18 -0700 Subject: [PATCH 2/5] Changing test to == 0 --- plugin/bullets.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/bullets.vim b/plugin/bullets.vim index 5774921..46782ed 100644 --- a/plugin/bullets.vim +++ b/plugin/bullets.vim @@ -171,7 +171,7 @@ endfun fun! s:match_roman_list_item(input_text) - if !g:bullets_enable_roman_list + if g:bullets_enable_roman_list == 0 return {} endif From 2e1f40b8d2d1e77b52d195c6544e8fd6c4e89a49 Mon Sep 17 00:00:00 2001 From: Harshad Vedartham Date: Fri, 2 Aug 2024 23:33:09 -0700 Subject: [PATCH 3/5] Removed bad character --- plugin/bullets.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/bullets.vim b/plugin/bullets.vim index 46782ed..e5e017f 100644 --- a/plugin/bullets.vim +++ b/plugin/bullets.vim @@ -180,7 +180,7 @@ fun! s:match_roman_list_item(input_text) \ '^(', \ '(\s*)', \ '(', - \ 'M{0,4}%(CM|CD|D?C{0,3})%(XC|XL|L?X{0,3})%(IX|IV|V?I{0,3})',A + \ 'M{0,4}%(CM|CD|D?C{0,3})%(XC|XL|L?X{0,3})%(IX|IV|V?I{0,3})', \ '|', \ 'm{0,4}%(cm|cd|d?c{0,3})%(xc|xl|l?x{0,3})%(ix|iv|v?i{0,3})', \ ')', From 001037a9d7ee866dbdc238c8dffb5d6ee62f67f9 Mon Sep 17 00:00:00 2001 From: Harshad Vedartham Date: Fri, 2 Aug 2024 23:52:52 -0700 Subject: [PATCH 4/5] Isolating test to roman --- spec/bullets_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/bullets_spec.rb b/spec/bullets_spec.rb index 5a3452c..0dc0dce 100644 --- a/spec/bullets_spec.rb +++ b/spec/bullets_spec.rb @@ -301,6 +301,8 @@ i. this is the first bullet TEXT + # Disable alpha lists to isolate test to roman numerals + vim.command 'let g:bullets_max_alpha_characters = 0' vim.command 'let g:bullets_enable_roman_list = 1' vim.edit filename vim.type 'GA' From 098da9e3c3b9bca4c513fa8ec58dfe82ac5e6275 Mon Sep 17 00:00:00 2001 From: Harshad Vedartham Date: Sat, 3 Aug 2024 00:02:16 -0700 Subject: [PATCH 5/5] Fixing test --- spec/bullets_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/bullets_spec.rb b/spec/bullets_spec.rb index 0dc0dce..9d91c12 100644 --- a/spec/bullets_spec.rb +++ b/spec/bullets_spec.rb @@ -310,8 +310,8 @@ vim.type 'second bullet' vim.feedkeys '\' vim.type 'third bullet' - vim.feedkeys '\' vim.command 'let g:bullets_enable_roman_list = 0' + vim.feedkeys '\' vim.type 'fourth bullet' vim.feedkeys '\' vim.type 'fifth bullet'