Skip to content

Commit

Permalink
Merge pull request #153 from harshad1/option_to_disable_roman_list
Browse files Browse the repository at this point in the history
Option to disable roman lists
  • Loading branch information
harshad1 committed Aug 3, 2024
2 parents 448ad2a + 098da9e commit 50ea5b7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
9 changes: 9 additions & 0 deletions 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,6 +171,10 @@ endfun


fun! s:match_roman_list_item(input_text)
if g:bullets_enable_roman_list == 0
return {}
endif

let l:rom_bullet_regex = join([
\ '\v\C',
\ '^(',
Expand Down
35 changes: 35 additions & 0 deletions spec/bullets_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,41 @@
-
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

# 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'
vim.feedkeys '\<cr>'
vim.type 'second bullet'
vim.feedkeys '\<cr>'
vim.type 'third bullet'
vim.command 'let g:bullets_enable_roman_list = 0'
vim.feedkeys '\<cr>'
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 50ea5b7

Please sign in to comment.