Skip to content

Commit

Permalink
Merge pull request #23 from vitalk/repeatable-plugs
Browse files Browse the repository at this point in the history
Repeatable plugs
  • Loading branch information
vitalk committed Oct 2, 2015
2 parents 5c3fcd0 + da267bb commit e53baaa
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 35 deletions.
23 changes: 18 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Simple TODO in Vim
# Simple todo in Vim

May be this is the smallest Vim plugin in the world. It adds some useful
mappings for manage simple TODO lists (example below) and nothing more.
mappings for manage simple todo lists (example below) and nothing more.

```
[x] Create plugin
Expand All @@ -10,10 +10,22 @@ mappings for manage simple TODO lists (example below) and nothing more.
[ ] Spread the word
```

Plugin supports [GitHub-like task lists](https://github.com/blog/1375-task-lists-in-gfm-issues-pulls-comments) as well.
## Features

- [x] Support markdown list markers
+ [x] So it's easy to create tasks in issues or pull requests on GitHub
- Support [GitHub-like task lists](https://github.com/blog/1375-task-lists-in-gfm-issues-pulls-comments):

- [x] Works well with different markdown list markers, e.g. `-`, `+`, `*`.
+ [x] So it's easy to create tasks in issues or pull requests on GitHub

- Each mapping is repeatable via <kbd>.</kbd> (require [tpope/repeat](https://github.com/tpope/vim-repeat)).

- Tick symbol is configurable, e.g.

```
[y] Water
[y] Bread
[ ] Milk
```

## Installation

Expand Down Expand Up @@ -66,6 +78,7 @@ imap <c-i> <Plug>(simple-todo-new)
See `:help simple-todo-maps` for list of available <Plug> mappings.

You can also change the tick symbol to something else. Default is `x`.

```vim
let g:simple_todo_tick_symbol = 'y'
```
Expand Down
66 changes: 36 additions & 30 deletions plugin/simple-todo.vim
Original file line number Diff line number Diff line change
Expand Up @@ -33,51 +33,57 @@ endfu " }}}
" Public API {{{

" Create a new item
nnore <Plug>(simple-todo-new) i[ ]<space>
inore <Plug>(simple-todo-new) [ ]<space>
nnore <silent> <Plug>(simple-todo-new) i[ ]<space>
inore <silent> <Plug>(simple-todo-new) [ ]<space>

" Create a new item at the start of this line
inore <Plug>(simple-todo-new-start-of-line) <Esc>mzI<c-r>=<SID>get_list_marker(line('.')-1)<cr>[ ]<space><Esc>`z4la
nnore <Plug>(simple-todo-new-start-of-line) mzI<c-r>=<SID>get_list_marker(line('.')-1)<cr>[ ]<space><Esc>`z4l
vnore <Plug>(simple-todo-new-start-of-line) I<c-r>=<SID>get_list_marker(line('.')-1)<cr>[ ]<space>
inore <silent> <Plug>(simple-todo-new-start-of-line) <Esc>mzI<c-r>=<SID>get_list_marker(line('.')-1)<cr>[ ]<space><Esc>`z4la
nnore <silent> <Plug>(simple-todo-new-start-of-line) mzI<c-r>=<SID>get_list_marker(line('.')-1)<cr>[ ]<space><Esc>`z4l
vnore <silent> <Plug>(simple-todo-new-start-of-line) I<c-r>=<SID>get_list_marker(line('.')-1)<cr>[ ]<space>

" Create a new item below
nnore <Plug>(simple-todo-below) o<c-r>=<SID>get_list_marker(line('.')-1)<cr>[ ]<space>
inore <Plug>(simple-todo-below) <Esc>o<c-r>=<SID>get_list_marker(line('.')-1)<cr>[ ]<space>
nnore <silent> <Plug>(simple-todo-below) o<c-r>=<SID>get_list_marker(line('.')-1)<cr>[ ]<space>
inore <silent> <Plug>(simple-todo-below) <Esc>o<c-r>=<SID>get_list_marker(line('.')-1)<cr>[ ]<space>

" Create a new item above
nnore <Plug>(simple-todo-above) O<c-r>=<SID>get_list_marker(line('.')+1)<cr>[ ]<space>
inore <Plug>(simple-todo-above) <Esc>O<c-r>=<SID>get_list_marker(line('.')+1)<cr>[ ]<space>
nnore <silent> <Plug>(simple-todo-above) O<c-r>=<SID>get_list_marker(line('.')+1)<cr>[ ]<space>
inore <silent> <Plug>(simple-todo-above) <Esc>O<c-r>=<SID>get_list_marker(line('.')+1)<cr>[ ]<space>

" Mark item under cursor as done
nnore <Plug>(simple-todo-mark-as-done) :execute 's/^\(\s*[-+*]\?\s*\)\[ \]/\1[' . g:simple_todo_tick_symbol . ']/'<cr>
vnore <Plug>(simple-todo-mark-as-done) :execute 's/^\(\s*[-+*]\?\s*\)\[ \]/\1[' . g:simple_todo_tick_symbol . ']/'<cr>
inore <Plug>(simple-todo-mark-as-done) <Esc>:execute 's/^\(\s*[-+*]\?\s*\)\[ \]/\1[' . g:simple_todo_tick_symbol . ']/'<cr>
nnore <silent> <Plug>(simple-todo-mark-as-done) :execute 's/^\(\s*[-+*]\?\s*\)\[ \]/\1[' . g:simple_todo_tick_symbol . ']/'<cr>
\:silent! call repeat#set("\<Plug>(simple-todo-mark-as-done)")<cr>
vnore <silent> <Plug>(simple-todo-mark-as-done) :execute 's/^\(\s*[-+*]\?\s*\)\[ \]/\1[' . g:simple_todo_tick_symbol . ']/'<cr>
\:silent! call repeat#set("\<Plug>(simple-todo-mark-as-done)")<cr>
inore <silent> <Plug>(simple-todo-mark-as-done) <Esc>:execute 's/^\(\s*[-+*]\?\s*\)\[ \]/\1[' . g:simple_todo_tick_symbol . ']/'<cr>
\:silent! call repeat#set("\<Plug>(simple-todo-mark-as-done)")<cr>

" Mark as undone
nnore <Plug>(simple-todo-mark-as-undone) :execute 's/^\(\s*[-+*]\?\s*\)\[' . g:simple_todo_tick_symbol . ']/\1[ ]/'<cr>
vnore <Plug>(simple-todo-mark-as-undone) :execute 's/^\(\s*[-+*]\?\s*\)\[' . g:simple_todo_tick_symbol . ']/\1[ ]/'<cr>
inore <Plug>(simple-todo-mark-as-undone) <Esc>:execute 's/^\(\s*[-+*]\?\s*\)\[' . g:simple_todo_tick_symbol . ']/\1[ ]/'<cr>
nnore <silent> <Plug>(simple-todo-mark-as-undone) :execute 's/^\(\s*[-+*]\?\s*\)\[' . g:simple_todo_tick_symbol . ']/\1[ ]/'<cr>
\:silent! call repeat#set("\<Plug>(simple-todo-mark-as-undone)")<cr>
vnore <silent> <Plug>(simple-todo-mark-as-undone) :execute 's/^\(\s*[-+*]\?\s*\)\[' . g:simple_todo_tick_symbol . ']/\1[ ]/'<cr>
\:silent! call repeat#set("\<Plug>(simple-todo-mark-as-undone)")<cr>
inore <silent> <Plug>(simple-todo-mark-as-undone) <Esc>:execute 's/^\(\s*[-+*]\?\s*\)\[' . g:simple_todo_tick_symbol . ']/\1[ ]/'<cr>
\:silent! call repeat#set("\<Plug>(simple-todo-mark-as-undone)")<cr>

" }}}
" Key bindings {{{

if g:simple_todo_map_keys
nmap <silent><Leader>i <Plug>(simple-todo-new)
imap <silent><Leader>i <Plug>(simple-todo-new)
imap <silent><Leader>I <Plug>(simple-todo-new-start-of-line)
nmap <silent><Leader>I <Plug>(simple-todo-new-start-of-line)
vmap <silent><Leader>I <Plug>(simple-todo-new-start-of-line)
nmap <silent><Leader>o <Plug>(simple-todo-below)
imap <silent><Leader>o <Plug>(simple-todo-below)
nmap <silent><Leader>O <Plug>(simple-todo-above)
imap <silent><Leader>O <Plug>(simple-todo-above)
nmap <silent><Leader>x <Plug>(simple-todo-mark-as-done)
vmap <silent><Leader>x <Plug>(simple-todo-mark-as-done)
imap <silent><Leader>x <Plug>(simple-todo-mark-as-done)
nmap <silent><Leader>X <Plug>(simple-todo-mark-as-undone)
vmap <silent><Leader>X <Plug>(simple-todo-mark-as-undone)
imap <silent><Leader>X <Plug>(simple-todo-mark-as-undone)
nmap <Leader>i <Plug>(simple-todo-new)
imap <Leader>i <Plug>(simple-todo-new)
imap <Leader>I <Plug>(simple-todo-new-start-of-line)
nmap <Leader>I <Plug>(simple-todo-new-start-of-line)
vmap <Leader>I <Plug>(simple-todo-new-start-of-line)
nmap <Leader>o <Plug>(simple-todo-below)
imap <Leader>o <Plug>(simple-todo-below)
nmap <Leader>O <Plug>(simple-todo-above)
imap <Leader>O <Plug>(simple-todo-above)
nmap <Leader>x <Plug>(simple-todo-mark-as-done)
vmap <Leader>x <Plug>(simple-todo-mark-as-done)
imap <Leader>x <Plug>(simple-todo-mark-as-done)
nmap <Leader>X <Plug>(simple-todo-mark-as-undone)
vmap <Leader>X <Plug>(simple-todo-mark-as-undone)
imap <Leader>X <Plug>(simple-todo-mark-as-undone)
endif

" }}}

0 comments on commit e53baaa

Please sign in to comment.