Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
aserebryakov committed Aug 20, 2017
2 parents 1fad3a4 + fbe56fa commit c650c39
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 17 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Plugin is automatically applied for files with `.todo` extension.

##### TODO Items

The sequence matching the expression '^ [ ] ' marks a line as a TODO list item.
The sequence matching the expression '^\s\*[ ].\*' marks a line as a TODO list item.

###### Example

Expand All @@ -45,7 +45,7 @@ The sequence matching the expression '^ [ ] ' marks a line as a TODO list item.
* `:VimTodoListsCreateNewItem` - creates a new item in current line
* `:VimTodoListsGoToNextItem` - go to the next item
* `:VimTodoListsGoToPreviousItem` - go to the previous item
* `:VimTodoListsToggleItem` - toggles the item
* `:VimTodoListsToggleItem` - toggles the current item (or selected items in visual mode)

##### Default key mappings

Expand Down Expand Up @@ -118,7 +118,13 @@ Changelog

#### 0.2.0

* Adds an option to configure custom key mappings
* Added an option to configure custom key mappings

#### 0.3.0

* Added items toggling in visual mode
* Improves work with indentations of list items
* Fixed the error when trying to navigate the buffer that doesn't contain items

Credits
-------
Expand Down
13 changes: 10 additions & 3 deletions doc/vim-todo-lists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*vim-todo-lists.txt* Version 0.2.0
*vim-todo-lists.txt* Version 0.3.0
*vim-todo-lists*

Plugin for TODO lists management.
Expand Down Expand Up @@ -70,7 +70,8 @@ Commands
* :VimTodoListsCreateNewItem - creates a new item in current line
* :VimTodoListsGoToNextItem - go to the next item
* :VimTodoListsGoToPreviousItem - go to the previous item
* :VimTodoListsToggleItem - toggles the item
* :VimTodoListsToggleItem - toggles the current item (or selected items
in visual mode)


Default key bindings
Expand Down Expand Up @@ -150,7 +151,13 @@ SOFTWARE.

0.2.0

* Adds an option to configure custom key mappings
* Added an option to configure custom key mappings

0.3.0

* Added items toggling in visual mode
* Improves work with indentations of list items
* Fixed the error when trying to navigate the buffer that doesn't contain items

==============================================================================
8. Credits *VimTodoListsCredits*
Expand Down
24 changes: 13 additions & 11 deletions plugin/vim-todo-lists.vim
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function! VimTodoListsSetNormalMode()
nunmap <buffer> j
nunmap <buffer> k
nnoremap <buffer> <Space> :VimTodoListsToggleItem<CR>
vnoremap <buffer> <Space> :'<,'>VimTodoListsToggleItem<CR>
noremap <buffer> <leader>e :silent call VimTodoListsSetItemMode()<CR>
endfunction

Expand All @@ -62,8 +63,9 @@ function! VimTodoListsSetItemMode()
nnoremap <buffer> j :VimTodoListsGoToNextItem<CR>
nnoremap <buffer> k :VimTodoListsGoToPreviousItem<CR>
nnoremap <buffer> <Space> :VimTodoListsToggleItem<CR>
noremap <buffer> <leader>e :silent call VimTodoListsSetNormalMode()<CR>
vnoremap <buffer> <Space> :VimTodoListsToggleItem<CR>
inoremap <buffer> <CR> <CR><ESC>:VimTodoListsCreateNewItem<CR>
noremap <buffer> <leader>e :silent call VimTodoListsSetNormalMode()<CR>
endfunction


Expand Down Expand Up @@ -91,8 +93,8 @@ endfunction
" Moves te cursor to the next item
function! VimTodoListsGoToNextItem()
normal! $
silent exec '/^ \[.\]'
silent exec 'noh'
silent! exec '/^\s*\[.\]'
silent! exec 'noh'
normal! f[
normal! l
endfunction
Expand All @@ -101,21 +103,21 @@ endfunction
" Moves te cursor to the previous item
function! VimTodoListsGoToPreviousItem()
normal! 0
silent exec '?^ \[.\]'
silent exec 'noh'
silent! exec '?^\s*\[.\]'
silent! exec 'noh'
normal! f[
normal! l
endfunction


" Toggles todo item in list
" Toggles todo list item
function! VimTodoListsToggleItem()
let l:line = getline('.')

if match(l:line, '^ \[ \] .*') != -1
call setline('.', substitute(l:line, '^ \[ \] ', ' [X] ', ''))
elseif match(l:line, '^ \[X\] .*') != -1
call setline('.', substitute(l:line, '^ \[X\] ', ' [ ] ', ''))
if match(l:line, '^\s*\[ \].*') != -1
call setline('.', substitute(l:line, '^\(\s*\)\[ \]', '\1[X]', ''))
elseif match(l:line, '^\s*\[X\] .*') != -1
call setline('.', substitute(l:line, '^\(\s*\)\[X\]', '\1[ ]', ''))
endif

endfunction
Expand All @@ -142,6 +144,6 @@ if !exists('g:vimtodolists_plugin')
command! VimTodoListsCreateNewItem silent call VimTodoListsCreateNewItem()
command! VimTodoListsGoToNextItem silent call VimTodoListsGoToNextItem()
command! VimTodoListsGoToPreviousItem silent call VimTodoListsGoToPreviousItem()
command! VimTodoListsToggleItem silent call VimTodoListsToggleItem()
command! -range VimTodoListsToggleItem silent <line1>,<line2>call VimTodoListsToggleItem()
endif

0 comments on commit c650c39

Please sign in to comment.