Skip to content

Commit

Permalink
Added option and test
Browse files Browse the repository at this point in the history
  • Loading branch information
harshad1 committed Aug 3, 2024
1 parent 448ad2a commit 57f289e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
11 changes: 10 additions & 1 deletion plugin/bullets.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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})',
\ ')',
Expand Down
33 changes: 33 additions & 0 deletions spec/bullets_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 '\<cr>'
vim.type 'second bullet'
vim.feedkeys '\<cr>'
vim.type 'third bullet'
vim.feedkeys '\<cr>'
vim.command 'let g:bullets_enable_roman_list = 0'
vim.type 'fourth bullet'
vim.feedkeys '\<cr>'
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

0 comments on commit 57f289e

Please sign in to comment.