Skip to content

Commit e0b1f8f

Browse files
authored
Merge pull request #49 from dkarter/minor-changes-to-alphabetic-bullets
Minor changes to alphabetic bullets
2 parents 5454d92 + afbe9d8 commit e0b1f8f

File tree

4 files changed

+175
-125
lines changed

4 files changed

+175
-125
lines changed

doc/bullets.txt

+15-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ types:
3030
- [ ] GFM markdown checkbox lists
3131
1. Numeric lists
3232
2) or this style of numeric lists
33+
a. alphabetic lists
34+
B) or this style of alphabetic
3335
\item latex item lists
3436
**** Org mode headers
3537

@@ -38,7 +40,6 @@ It also provides support for wrapped text in a bullet, allowing you to use the
3840

3941
Future versions aim to support the following:
4042

41-
a. Alphabetic lists
4243
]] User defined bullets
4344

4445

@@ -151,6 +152,19 @@ This tends to be fine even if you don't use it, but it can be disabled with:
151152
`let g:bullets_pad_right = 0`
152153

153154

155+
Alphabetic Bullet Max Size
156+
--------------------------
157+
To avoid falsely detecting a word as an alphabetic bullet we have limited the
158+
max size of an alphabetic bullets to `2` characters using the following setting:
159+
160+
`let g:bullets_max_alpha_characters = 2`
161+
162+
You can change this setting in certain file types if you are not worried about
163+
that using auto commands.
164+
165+
When changed to `0` this will disable alphabetic bullets altogether.
166+
167+
154168
INSERTING BULLETS *bullets-insert-new-bullet*
155169

156170
When a supported file type is opened (see |bullets-configuration|) you can start

plugin/bullets.vim

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
" Vim plugin for automated bulleted lists
2-
" Last Change: February 03, 2020
2+
" Last Change: February 23, 2020
33
" Maintainer: Dorian Karter
44
" License: MIT
55
" FileTypes: markdown, text, gitcommit
@@ -122,6 +122,10 @@ fun! s:match_roman_list_item(input_text)
122122
endfun
123123

124124
fun! s:match_alphabetical_list_item(input_text)
125+
if g:bullets_max_alpha_characters == 0
126+
return {}
127+
endif
128+
125129
let l:abc_bullet_regex = join([
126130
\ '\v^((\s*)(\u{1,',
127131
\ string(g:bullets_max_alpha_characters),

spec/alphabetic_bullets_spec.rb

+155
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
5+
RSpec.describe 'Bullets.vim' do
6+
describe 'alphabetic bullets' do
7+
it 'adds a new upper case bullet' do
8+
filename = "#{SecureRandom.hex(6)}.txt"
9+
write_file(filename, <<-TEXT)
10+
# Hello there
11+
A. this is the first bullet
12+
TEXT
13+
14+
vim.edit filename
15+
vim.type 'GA'
16+
vim.feedkeys '\<cr>'
17+
vim.type 'second bullet'
18+
vim.feedkeys '\<cr>'
19+
vim.type 'third bullet'
20+
vim.feedkeys '\<cr>'
21+
vim.type 'fourth bullet'
22+
vim.feedkeys '\<cr>'
23+
vim.type 'fifth bullet'
24+
vim.write
25+
26+
file_contents = IO.read(filename)
27+
28+
expect(file_contents).to eq normalize_string_indent(<<-TEXT)
29+
# Hello there
30+
A. this is the first bullet
31+
B. second bullet
32+
C. third bullet
33+
D. fourth bullet
34+
E. fifth bullet\n
35+
TEXT
36+
end
37+
38+
it 'adds a new lower case bullet' do
39+
filename = "#{SecureRandom.hex(6)}.txt"
40+
write_file(filename, <<-TEXT)
41+
# Hello there
42+
a. this is the first bullet
43+
TEXT
44+
45+
vim.edit filename
46+
vim.type 'GA'
47+
vim.feedkeys '\<cr>'
48+
vim.type 'second bullet'
49+
vim.feedkeys '\<cr>'
50+
vim.type 'third bullet'
51+
vim.feedkeys '\<cr>'
52+
vim.type 'fourth bullet'
53+
vim.feedkeys '\<cr>'
54+
vim.type 'fifth bullet'
55+
vim.write
56+
57+
file_contents = IO.read(filename)
58+
59+
expect(file_contents).to eq normalize_string_indent(<<-TEXT)
60+
# Hello there
61+
a. this is the first bullet
62+
b. second bullet
63+
c. third bullet
64+
d. fourth bullet
65+
e. fifth bullet\n
66+
TEXT
67+
end
68+
69+
it 'adds a new bullet and loops at z' do
70+
filename = "#{SecureRandom.hex(6)}.txt"
71+
write_file(filename, <<-TEXT)
72+
# Hello there
73+
y. this is the first bullet
74+
TEXT
75+
76+
vim.edit filename
77+
vim.type 'GA'
78+
vim.feedkeys '\<cr>'
79+
vim.type 'second bullet'
80+
vim.feedkeys '\<cr>'
81+
vim.type 'third bullet'
82+
vim.feedkeys '\<cr>'
83+
vim.feedkeys '\<cr>'
84+
vim.type 'AY. fourth bullet'
85+
vim.feedkeys '\<cr>'
86+
vim.type 'fifth bullet'
87+
vim.feedkeys '\<cr>'
88+
vim.type 'sixth bullet'
89+
vim.write
90+
91+
file_contents = IO.read(filename)
92+
93+
expect(file_contents).to eq normalize_string_indent(<<-TEXT)
94+
# Hello there
95+
y. this is the first bullet
96+
z. second bullet
97+
aa. third bullet
98+
99+
AY. fourth bullet
100+
AZ. fifth bullet
101+
BA. sixth bullet\n
102+
TEXT
103+
end
104+
105+
describe 'g:bullets_max_alpha_characters' do
106+
it 'stops adding items after configured max (default 2)' do
107+
filename = "#{SecureRandom.hex(6)}.txt"
108+
write_file(filename, <<-TEXT)
109+
# Hello there
110+
zy. this is the first bullet
111+
TEXT
112+
113+
vim.edit filename
114+
vim.type 'GA'
115+
vim.feedkeys '\<cr>'
116+
vim.type 'second bullet'
117+
vim.feedkeys '\<cr>'
118+
vim.type 'not a bullet'
119+
vim.write
120+
121+
file_contents = IO.read(filename)
122+
123+
expect(file_contents).to eq normalize_string_indent(<<-TEXT)
124+
# Hello there
125+
zy. this is the first bullet
126+
zz. second bullet
127+
not a bullet\n
128+
TEXT
129+
end
130+
131+
it 'does not bullets if configured as 0' do
132+
filename = "#{SecureRandom.hex(6)}.txt"
133+
write_file(filename, <<-TEXT)
134+
# Hello there
135+
a. this is the first bullet
136+
TEXT
137+
138+
vim.command 'let g:bullets_max_alpha_characters = 0'
139+
vim.edit filename
140+
vim.type 'GA'
141+
vim.feedkeys '\<cr>'
142+
vim.type 'not a bullet'
143+
vim.write
144+
145+
file_contents = IO.read(filename)
146+
147+
expect(file_contents).to eq normalize_string_indent(<<-TEXT)
148+
# Hello there
149+
a. this is the first bullet
150+
not a bullet\n
151+
TEXT
152+
end
153+
end
154+
end
155+
end

spec/bullets_spec.rb

-123
Original file line numberDiff line numberDiff line change
@@ -249,129 +249,6 @@
249249
TEXT
250250
end
251251

252-
it 'adds a new alphabetical list bullet' do
253-
filename = "#{SecureRandom.hex(6)}.txt"
254-
write_file(filename, <<-TEXT)
255-
# Hello there
256-
A. this is the first bullet
257-
TEXT
258-
259-
vim.edit filename
260-
vim.type 'GA'
261-
vim.feedkeys '\<cr>'
262-
vim.type 'second bullet'
263-
vim.feedkeys '\<cr>'
264-
vim.type 'third bullet'
265-
vim.feedkeys '\<cr>'
266-
vim.type 'fourth bullet'
267-
vim.feedkeys '\<cr>'
268-
vim.type 'fifth bullet'
269-
vim.write
270-
271-
file_contents = IO.read(filename)
272-
273-
expect(file_contents).to eq normalize_string_indent(<<-TEXT)
274-
# Hello there
275-
A. this is the first bullet
276-
B. second bullet
277-
C. third bullet
278-
D. fourth bullet
279-
E. fifth bullet\n
280-
TEXT
281-
end
282-
283-
it 'adds a new lower case alphabetical list bullet' do
284-
filename = "#{SecureRandom.hex(6)}.txt"
285-
write_file(filename, <<-TEXT)
286-
# Hello there
287-
a. this is the first bullet
288-
TEXT
289-
290-
vim.edit filename
291-
vim.type 'GA'
292-
vim.feedkeys '\<cr>'
293-
vim.type 'second bullet'
294-
vim.feedkeys '\<cr>'
295-
vim.type 'third bullet'
296-
vim.feedkeys '\<cr>'
297-
vim.type 'fourth bullet'
298-
vim.feedkeys '\<cr>'
299-
vim.type 'fifth bullet'
300-
vim.write
301-
302-
file_contents = IO.read(filename)
303-
304-
expect(file_contents).to eq normalize_string_indent(<<-TEXT)
305-
# Hello there
306-
a. this is the first bullet
307-
b. second bullet
308-
c. third bullet
309-
d. fourth bullet
310-
e. fifth bullet\n
311-
TEXT
312-
end
313-
314-
it 'adds a new alphabetical list bullet and loops at z' do
315-
filename = "#{SecureRandom.hex(6)}.txt"
316-
write_file(filename, <<-TEXT)
317-
# Hello there
318-
y. this is the first bullet
319-
TEXT
320-
321-
vim.edit filename
322-
vim.type 'GA'
323-
vim.feedkeys '\<cr>'
324-
vim.type 'second bullet'
325-
vim.feedkeys '\<cr>'
326-
vim.type 'third bullet'
327-
vim.feedkeys '\<cr>'
328-
vim.feedkeys '\<cr>'
329-
vim.type 'AY. fourth bullet'
330-
vim.feedkeys '\<cr>'
331-
vim.type 'fifth bullet'
332-
vim.feedkeys '\<cr>'
333-
vim.type 'sixth bullet'
334-
vim.write
335-
336-
file_contents = IO.read(filename)
337-
338-
expect(file_contents).to eq normalize_string_indent(<<-TEXT)
339-
# Hello there
340-
y. this is the first bullet
341-
z. second bullet
342-
aa. third bullet
343-
344-
AY. fourth bullet
345-
AZ. fifth bullet
346-
BA. sixth bullet\n
347-
TEXT
348-
end
349-
350-
it 'stops adding more alphabetical items after g:bullets_max_alpha_characters (2)' do
351-
filename = "#{SecureRandom.hex(6)}.txt"
352-
write_file(filename, <<-TEXT)
353-
# Hello there
354-
zy. this is the first bullet
355-
TEXT
356-
357-
vim.edit filename
358-
vim.type 'GA'
359-
vim.feedkeys '\<cr>'
360-
vim.type 'second bullet'
361-
vim.feedkeys '\<cr>'
362-
vim.type 'not a bullet'
363-
vim.write
364-
365-
file_contents = IO.read(filename)
366-
367-
expect(file_contents).to eq normalize_string_indent(<<-TEXT)
368-
# Hello there
369-
zy. this is the first bullet
370-
zz. second bullet
371-
not a bullet\n
372-
TEXT
373-
end
374-
375252
it 'deletes the last bullet if it is empty' do
376253
filename = "#{SecureRandom.hex(6)}.txt"
377254
write_file(filename, <<-TEXT)

0 commit comments

Comments
 (0)