From db675999d0c4fff6ee1cab8b87fe1e81d469dbaf Mon Sep 17 00:00:00 2001 From: Dorian Karter Date: Sun, 23 Feb 2020 00:02:39 -0600 Subject: [PATCH 1/4] Update doc --- doc/bullets.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/bullets.txt b/doc/bullets.txt index 14453d6..3f0464c 100644 --- a/doc/bullets.txt +++ b/doc/bullets.txt @@ -30,6 +30,8 @@ types: - [ ] GFM markdown checkbox lists 1. Numeric lists 2) or this style of numeric lists +a. alphabetic lists +B) or this style of alphabetic \item latex item lists **** Org mode headers @@ -38,7 +40,6 @@ It also provides support for wrapped text in a bullet, allowing you to use the Future versions aim to support the following: -a. Alphabetic lists ]] User defined bullets From deee79ee1584ccaf9b241ec272a5474c8d1b2b9c Mon Sep 17 00:00:00 2001 From: Dorian Karter Date: Sun, 23 Feb 2020 00:08:54 -0600 Subject: [PATCH 2/4] Move alphabetic bullet tests to their own file --- spec/alphabetic_bullets_spec.rb | 132 ++++++++++++++++++++++++++++++++ spec/bullets_spec.rb | 123 ----------------------------- 2 files changed, 132 insertions(+), 123 deletions(-) create mode 100644 spec/alphabetic_bullets_spec.rb diff --git a/spec/alphabetic_bullets_spec.rb b/spec/alphabetic_bullets_spec.rb new file mode 100644 index 0000000..55d980e --- /dev/null +++ b/spec/alphabetic_bullets_spec.rb @@ -0,0 +1,132 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Bullets.vim' do + describe 'alphabetic bullets' do + it 'adds a new upper case bullet' do + filename = "#{SecureRandom.hex(6)}.txt" + write_file(filename, <<-TEXT) + # Hello there + A. this is the first bullet + TEXT + + vim.edit filename + vim.type 'GA' + vim.feedkeys '\' + vim.type 'second bullet' + vim.feedkeys '\' + vim.type 'third bullet' + vim.feedkeys '\' + 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 + A. this is the first bullet + B. second bullet + C. third bullet + D. fourth bullet + E. fifth bullet\n + TEXT + end + + it 'adds a new lower case bullet' do + filename = "#{SecureRandom.hex(6)}.txt" + write_file(filename, <<-TEXT) + # Hello there + a. this is the first bullet + TEXT + + vim.edit filename + vim.type 'GA' + vim.feedkeys '\' + vim.type 'second bullet' + vim.feedkeys '\' + vim.type 'third bullet' + vim.feedkeys '\' + 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 + a. this is the first bullet + b. second bullet + c. third bullet + d. fourth bullet + e. fifth bullet\n + TEXT + end + + it 'adds a new bullet and loops at z' do + filename = "#{SecureRandom.hex(6)}.txt" + write_file(filename, <<-TEXT) + # Hello there + y. this is the first bullet + TEXT + + vim.edit filename + vim.type 'GA' + vim.feedkeys '\' + vim.type 'second bullet' + vim.feedkeys '\' + vim.type 'third bullet' + vim.feedkeys '\' + vim.feedkeys '\' + vim.type 'AY. fourth bullet' + vim.feedkeys '\' + vim.type 'fifth bullet' + vim.feedkeys '\' + vim.type 'sixth bullet' + vim.write + + file_contents = IO.read(filename) + + expect(file_contents).to eq normalize_string_indent(<<-TEXT) + # Hello there + y. this is the first bullet + z. second bullet + aa. third bullet + + AY. fourth bullet + AZ. fifth bullet + BA. sixth bullet\n + TEXT + end + + describe 'g:bullets_max_alpha_characters' do + it 'stops adding items after configured max (default 2)' do + filename = "#{SecureRandom.hex(6)}.txt" + write_file(filename, <<-TEXT) + # Hello there + zy. this is the first bullet + TEXT + + vim.edit filename + vim.type 'GA' + vim.feedkeys '\' + vim.type 'second bullet' + vim.feedkeys '\' + vim.type 'not a bullet' + vim.write + + file_contents = IO.read(filename) + + expect(file_contents).to eq normalize_string_indent(<<-TEXT) + # Hello there + zy. this is the first bullet + zz. second bullet + not a bullet\n + TEXT + end + end + end +end diff --git a/spec/bullets_spec.rb b/spec/bullets_spec.rb index e9b2c1f..84b79db 100644 --- a/spec/bullets_spec.rb +++ b/spec/bullets_spec.rb @@ -249,129 +249,6 @@ TEXT end - it 'adds a new alphabetical list bullet' do - filename = "#{SecureRandom.hex(6)}.txt" - write_file(filename, <<-TEXT) - # Hello there - A. this is the first bullet - TEXT - - vim.edit filename - vim.type 'GA' - vim.feedkeys '\' - vim.type 'second bullet' - vim.feedkeys '\' - vim.type 'third bullet' - vim.feedkeys '\' - 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 - A. this is the first bullet - B. second bullet - C. third bullet - D. fourth bullet - E. fifth bullet\n - TEXT - end - - it 'adds a new lower case alphabetical list bullet' do - filename = "#{SecureRandom.hex(6)}.txt" - write_file(filename, <<-TEXT) - # Hello there - a. this is the first bullet - TEXT - - vim.edit filename - vim.type 'GA' - vim.feedkeys '\' - vim.type 'second bullet' - vim.feedkeys '\' - vim.type 'third bullet' - vim.feedkeys '\' - 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 - a. this is the first bullet - b. second bullet - c. third bullet - d. fourth bullet - e. fifth bullet\n - TEXT - end - - it 'adds a new alphabetical list bullet and loops at z' do - filename = "#{SecureRandom.hex(6)}.txt" - write_file(filename, <<-TEXT) - # Hello there - y. this is the first bullet - TEXT - - vim.edit filename - vim.type 'GA' - vim.feedkeys '\' - vim.type 'second bullet' - vim.feedkeys '\' - vim.type 'third bullet' - vim.feedkeys '\' - vim.feedkeys '\' - vim.type 'AY. fourth bullet' - vim.feedkeys '\' - vim.type 'fifth bullet' - vim.feedkeys '\' - vim.type 'sixth bullet' - vim.write - - file_contents = IO.read(filename) - - expect(file_contents).to eq normalize_string_indent(<<-TEXT) - # Hello there - y. this is the first bullet - z. second bullet - aa. third bullet - - AY. fourth bullet - AZ. fifth bullet - BA. sixth bullet\n - TEXT - end - - it 'stops adding more alphabetical items after g:bullets_max_alpha_characters (2)' do - filename = "#{SecureRandom.hex(6)}.txt" - write_file(filename, <<-TEXT) - # Hello there - zy. this is the first bullet - TEXT - - vim.edit filename - vim.type 'GA' - vim.feedkeys '\' - vim.type 'second bullet' - vim.feedkeys '\' - vim.type 'not a bullet' - vim.write - - file_contents = IO.read(filename) - - expect(file_contents).to eq normalize_string_indent(<<-TEXT) - # Hello there - zy. this is the first bullet - zz. second bullet - not a bullet\n - TEXT - end - it 'deletes the last bullet if it is empty' do filename = "#{SecureRandom.hex(6)}.txt" write_file(filename, <<-TEXT) From d39bfa8c8beada6de1e82fcd64ad6c0f476c8cb6 Mon Sep 17 00:00:00 2001 From: Dorian Karter Date: Sun, 23 Feb 2020 00:15:12 -0600 Subject: [PATCH 3/4] Allow disabling alphabetic bullets --- doc/bullets.txt | 13 +++++++++++++ plugin/bullets.vim | 4 ++++ spec/alphabetic_bullets_spec.rb | 23 +++++++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/doc/bullets.txt b/doc/bullets.txt index 3f0464c..e70ec7e 100644 --- a/doc/bullets.txt +++ b/doc/bullets.txt @@ -152,6 +152,19 @@ This tends to be fine even if you don't use it, but it can be disabled with: `let g:bullets_pad_right = 0` +Alphabetic Bullet Max Size +-------------------------- +To avoid falsely detecting a word as an alphabetic bullet we have limited the +max size of an alphabetic bullets to `2` characters using the following setting: + + `let g:bullets_max_alpha_characters = 2` + +You can change this setting in certain file types if you are not worried about +that using auto commands. + +When changed to `0` this will disable alphabetic bullets altogether. + + INSERTING BULLETS *bullets-insert-new-bullet* When a supported file type is opened (see |bullets-configuration|) you can start diff --git a/plugin/bullets.vim b/plugin/bullets.vim index 93ca133..65b8072 100644 --- a/plugin/bullets.vim +++ b/plugin/bullets.vim @@ -122,6 +122,10 @@ fun! s:match_roman_list_item(input_text) endfun fun! s:match_alphabetical_list_item(input_text) + if g:bullets_max_alpha_characters == 0 + return {} + endif + let l:abc_bullet_regex = join([ \ '\v^((\s*)(\u{1,', \ string(g:bullets_max_alpha_characters), diff --git a/spec/alphabetic_bullets_spec.rb b/spec/alphabetic_bullets_spec.rb index 55d980e..e7c227f 100644 --- a/spec/alphabetic_bullets_spec.rb +++ b/spec/alphabetic_bullets_spec.rb @@ -127,6 +127,29 @@ not a bullet\n TEXT end + + it 'does not bullets if configured as 0' do + filename = "#{SecureRandom.hex(6)}.txt" + write_file(filename, <<-TEXT) + # Hello there + a. this is the first bullet + TEXT + + vim.command 'let g:bullets_max_alpha_characters = 0' + vim.edit filename + vim.type 'GA' + vim.feedkeys '\' + vim.type 'not a bullet' + vim.write + + file_contents = IO.read(filename) + + expect(file_contents).to eq normalize_string_indent(<<-TEXT) + # Hello there + a. this is the first bullet + not a bullet\n + TEXT + end end end end From afbe9d85430c1cc740b884dc7e5cfc899ae5d1e6 Mon Sep 17 00:00:00 2001 From: Dorian Karter Date: Sun, 23 Feb 2020 00:17:59 -0600 Subject: [PATCH 4/4] Bump version --- plugin/bullets.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/bullets.vim b/plugin/bullets.vim index 65b8072..49bdba0 100644 --- a/plugin/bullets.vim +++ b/plugin/bullets.vim @@ -1,5 +1,5 @@ " Vim plugin for automated bulleted lists -" Last Change: February 03, 2020 +" Last Change: February 23, 2020 " Maintainer: Dorian Karter " License: MIT " FileTypes: markdown, text, gitcommit