Skip to content

Commit 47b9693

Browse files
authored
Merge pull request #65 from kaymmm/vimwiki-checkboxes
Vimwiki checkboxes
2 parents 4637e51 + 3ffddb5 commit 47b9693

7 files changed

Lines changed: 777 additions & 290 deletions

File tree

README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,74 @@ let g:bullets_renumber_on_change = 0
162162
" 3. third existing bullet [ no renumbering so this bullet remained `3` ]
163163
```
164164

165+
Enable/disable toggling parent and child checkboxes to indicate "completion" of child checkboxes:
166+
167+
```vim
168+
let g:bullets_nested_checkboxes = 1 " default = 1
169+
" Example:
170+
" - [ ] first bullet
171+
" - [ ] child bullet [ type <leader>x ]
172+
" - [ ] sub-child
173+
" - [ ] child bullet
174+
"
175+
" Result:
176+
" - [o] first bullet [ <- indicates partial completion of sub-tasks ]
177+
" - [X] child bullet
178+
" - [X] sub-child [ <- children get checked when parents get checked ]
179+
" - [ ] child bullet
180+
```
181+
182+
Define the checkbox markers to use to indicate unchecked, checked, and "partially" checked. When only two marker characters are defined, the use of partial completion markers will be disabled. If more than two markers are defined, each character between the first and last characters will be used to indicate a percentage of the child checkboxes that are checked. Each marker corresponds to 1/n, where n is the number of partial completion markers. By default, there are three partial completion markers, `.`, `o`, and `O`, corresponding to 33%, 66%, and up to but less than 100%, respectively. Note that unchecked (`[ ]`) and checked (`[x]` or `[X]`) statuses using the default markers are always valid, even if you set custom markers for unchecked and checked.
183+
184+
```vim
185+
let g:bullets_checkbox_markers = ' .oOX'
186+
" Example:
187+
" - [o] parent bullet [ <- `o` indicates 66% - 99% of children are checked ]
188+
" - [ ] child bullet
189+
" - [.] child bullet [ <- partial completions don't count as complete ]
190+
" - [ ] sub-child bullet [ <- 1/4 of children checked so parent is `.` ]
191+
" - [ ] sub-child bullet
192+
" - [ ] sub-child bullet
193+
" - [X] sub-child bullet
194+
" - [X] child bullet
195+
" - [X] child bullet
196+
"
197+
" You can use fancy markers:
198+
" let g:bullets_checkbox_markers = '✗○◐●✓'
199+
" - [✗] unchecked
200+
" - [○] partial
201+
" - [✓] checked
202+
" - [✗] unchecked
203+
" - [✗] unchecked
204+
" - [✗] unchecked
205+
```
206+
207+
Define whether toggling partially complete checkboxes sets the checkbox to checked or unchecked:
208+
209+
```vim
210+
" Example 1:
211+
let g:bullets_checkbox_partials_toggle = 1 " default = 1
212+
" - [o] partially checked [ type <leader>x ]
213+
" - [x] sub bullet
214+
" - [ ] sub bullet
215+
"
216+
" Result:
217+
" - [x] checked
218+
" - [x] sub bullet
219+
" - [x] sub bullet
220+
"
221+
" Example 2:
222+
let g:bullets_checkbox_partials_toggle = 0
223+
" - [o] partially checked [ type <leader>x ]
224+
" - [x] sub bullet
225+
" - [ ] sub bullet
226+
"
227+
" Result:
228+
" - [ ] checked
229+
" - [ ] sub bullet
230+
" - [ ] sub bullet
231+
```
232+
165233
# Mappings
166234

167235
* Insert new bullet in INSERT mode: `<cr>` (Return key)
@@ -243,6 +311,7 @@ Capybara integration testing. ❤️
243311
- [x] change nested outline levels in visual mode
244312
- [x] support renumbering of alphabetical, roman numerals, and nested lists
245313
- [x] update documentation for nested bullets
314+
- [x] support nested bullets with child and partial completion
246315
- [ ] support for nested numerical bullets, e.g., 1. -> 1.1 -> 1.1.1, 1.1.2
247316
- [ ] add option to turn non-bullet lines into new bullets with `<C-t>`/`>>`/`>`
248317

doc/bullets.txt

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ TABLE OF CONTENTS *bullets-toc*
1010
|bullets-configuration| Configuration
1111
|bullets-insert-new-bullet| Inserting Bullets
1212
|bullets-indenting| Indenting Bullets
13-
|bullets-checkboxes| Gfm Markdown Checkboxes
13+
|bullets-checkboxes| Gfm/vimwiki Markdown Checkboxes
1414
|bullets-mappings| Mappings
1515

1616

@@ -28,7 +28,7 @@ types:
2828
- Hyphenated lists
2929
* Star (or bullet) lists
3030
+ Plus (also bullet) lists
31-
- [ ] GFM markdown checkbox lists
31+
- [ ] GFM/vimwiki markdown checkbox lists
3232
1. Numeric lists
3333
2) or this style of numeric lists
3434
a. alphabetic lists
@@ -223,6 +223,57 @@ You can always manually renumber the current list or visual selection using
223223
`gN` in NORMAL or VISUAL mode.
224224

225225

226+
Toggle Parent and Child Checkboxes
227+
----------------------------------
228+
If a checkbox has child checkboxes, checking the checkbox will check all
229+
its children, and unchecking it will uncheck all its children. When toggling
230+
a child checkbox, the parent will be checked, unchecked, or marked with
231+
a partial completion marker (see |bullets-checkboxes|). You can disable this
232+
behavior using the following:
233+
234+
`let g:bullets_nested_checkboxes = 0`
235+
236+
237+
Checkbox Marker and Partial Completion Symbols
238+
----------------------------------------------
239+
In addition to the GFM markdown checkbox symbols, ` ` (unchecked) and `x`
240+
(checked), you can define and use custom marker symbols. You can also define
241+
and use marker symbols indicating partial completion of child checkboxes,
242+
like vimwiki syntax. By default, three symbols are defined for 1%-33% complete
243+
(`.`), 34%-66% complete (`o`), and 67%-99% complete (`O`), with 0% and 100%
244+
completion indicated by the unchecked and checked markers, respectively.
245+
246+
The marker symbols are defined in a text string consisting of the sequential
247+
markers to use for unckecked (first character), partially checked (0+ middle
248+
characters), and checked (last character) statuses:
249+
250+
`let g:bullets_checkbox_markers = ' .oOX'`
251+
252+
You can define fewer or more intermediate characters for partial completion,
253+
and the completion intervals will be adjusted accordingly.
254+
255+
If you only define a checked and unchecked marker symbol, partial completion
256+
will be disabled:
257+
258+
`let g:bullets_checkbox_markers = ' X'`
259+
260+
The standard GFM marker symbols for checked and unchecked (` ` and `x`) will
261+
always work for compatibility purposes, even when you use custom marker symbols.
262+
263+
You can also use fancy marker symbols, for example:
264+
265+
`let g:bullets_checkbox_markers = '✗○◐●✓'`
266+
267+
268+
Toggling Partially Checked Checkboxes
269+
-------------------------------------
270+
You can define whether toggling a partially checked checkbox will result in it
271+
being marked checked (1, default) or unchecked (0):
272+
273+
274+
`let g:bullets_checkbox_partials_toggle = 1`
275+
276+
226277
INSERTING BULLETS *bullets-insert-new-bullet*
227278

228279
When a supported file type is opened (see |bullets-configuration|) you can start
@@ -249,13 +300,21 @@ To indent the current bullet to the left: from insert mode press <CTRL-d>.
249300
For more information `:h i_CTRL-T` and `:h i_CTRL-D`
250301

251302

252-
GFM MARKDOWN CHECKBOXES *bullets-checkboxes*
303+
GFM AND VIMWIKI MARKDOWN CHECKBOXES *bullets-checkboxes*
304+
305+
Bullets.vim supports checking and unchecking GFM- and vimwiki-style markdown
306+
checkboxes. While in normal mode, move over a checkbox list item (anywhere
307+
on the item) and use <leader>x to toggle the checkbox state.
253308

254-
Bullets.vim supports checking and unchecking GFM markdown checkboxes. While in
255-
normal mode, move over a checkbox list item (anywhere on the item) and use
256-
<leader>x to toggle the checkbox state.
309+
Vimwiki-style checkboxes allow for marking a checkbox as partially complete
310+
based on how many of its child checkboxes are checked. Partially complete
311+
checkboxes can use different markers to indicate a relative percentage of
312+
completion. Vimwiki-style (partial completion) checkboxes can be disabled
313+
through the `g:bullets_checkbox_markers` configuration option (see
314+
|bullets-configuration|).
257315

258-
There are also |bullets-commands| that you can use to to create your own mappings.
316+
There are also |bullets-commands| that you can use to to create your own
317+
mappings.
259318

260319

261320
MAPPINGS *bullets-mappings*

0 commit comments

Comments
 (0)