diff options
-rw-r--r-- | autoload/todo/motion.vim | 30 | ||||
-rw-r--r-- | ftplugin/todo.vim | 42 |
2 files changed, 68 insertions, 4 deletions
diff --git a/autoload/todo/motion.vim b/autoload/todo/motion.vim index 82dd092..ea97b16 100644 --- a/autoload/todo/motion.vim +++ b/autoload/todo/motion.vim @@ -14,26 +14,48 @@ " along with Twodo. If not, see <http://www.gnu.org/licenses/>. let s:INCOMPLETE_MATCHER = '^\s*[\-_!] ' +let s:REGULAR_MATCHER = '^\s*- ' +let s:IMPORTANT_MATCHER = '^\s*! ' -function! s:Incomplete(extra_search_flags) +function! s:Search(pattern, extra_search_flags) let cnt = v:count1 let search_flags = 's' . a:extra_search_flags let i = 0 while i < cnt - call search(s:INCOMPLETE_MATCHER, search_flags) + call search(a:pattern, search_flags) let i += 1 endwhile endfunction function! todo#motion#NextIncomplete() - call s:Incomplete('') + call s:Search(s:INCOMPLETE_MATCHER, '') endfunction function! todo#motion#PreviousIncomplete() - call s:Incomplete('b') + call s:Search(s:INCOMPLETE_MATCHER, 'b') +endfunction + + +function! todo#motion#NextRegular() + call s:Search(s:REGULAR_MATCHER, '') +endfunction + + +function! todo#motion#PreviousRegular() + call s:Search(s:REGULAR_MATCHER, 'b') +endfunction + + +function! todo#motion#NextImportant() + call s:Search(s:IMPORTANT_MATCHER, '') +endfunction + + +function! todo#motion#PreviousImportant() + call s:Search(s:IMPORTANT_MATCHER, 'b') endfunction diff --git a/ftplugin/todo.vim b/ftplugin/todo.vim index e1b3ddb..9ad32dd 100644 --- a/ftplugin/todo.vim +++ b/ftplugin/todo.vim @@ -36,6 +36,16 @@ nnoremap <silent> <buffer> <Plug>TwodoPreviousIncomplete :<c-u>call todo#motion# onoremap <silent> <buffer> <Plug>TwodoNextIncomplete :<c-u>call todo#motion#NextIncomplete()<cr> onoremap <silent> <buffer> <Plug>TwodoPreviousIncomplete :<c-u>call todo#motion#PreviousIncomplete()<cr> +nnoremap <silent> <buffer> <Plug>TwodoNextRegular :<c-u>call todo#motion#NextRegular()<cr> +nnoremap <silent> <buffer> <Plug>TwodoPreviousRegular :<c-u>call todo#motion#PreviousRegular()<cr> +onoremap <silent> <buffer> <Plug>TwodoNextRegular :<c-u>call todo#motion#NextRegular()<cr> +onoremap <silent> <buffer> <Plug>TwodoPreviousRegular :<c-u>call todo#motion#PreviousRegular()<cr> + +nnoremap <silent> <buffer> <Plug>TwodoNextImportant :<c-u>call todo#motion#NextImportant()<cr> +nnoremap <silent> <buffer> <Plug>TwodoPreviousImportant :<c-u>call todo#motion#PreviousImportant()<cr> +onoremap <silent> <buffer> <Plug>TwodoNextImportant :<c-u>call todo#motion#NextImportant()<cr> +onoremap <silent> <buffer> <Plug>TwodoPreviousImportant :<c-u>call todo#motion#PreviousImportant()<cr> + if !hasmapto('<Plug>TwodoNewTodoBelow') && !maparg('<LocalLeader>n', 'n') nmap <silent> <buffer> <LocalLeader>n <Plug>TwodoNewTodoBelow endif @@ -83,3 +93,35 @@ endif if !hasmapto('<Plug>TwodoPreviousIncomplete', 'o') && !maparg('[u', 'o') omap <buffer> [u <Plug>TwodoPreviousIncomplete endif + +if !hasmapto('<Plug>TwodoNextRegular', 'n') && !maparg(']o', 'n') + nmap <buffer> ]o <Plug>TwodoNextRegular +endif + +if !hasmapto('<Plug>TwodoNextRegular', 'o') && !maparg(']o', 'o') + omap <buffer> ]o <Plug>TwodoNextRegular +endif + +if !hasmapto('<Plug>TwodoPreviousRegular', 'n') && !maparg('[o', 'n') + nmap <buffer> [o <Plug>TwodoPreviousRegular +endif + +if !hasmapto('<Plug>TwodoPreviousRegular', 'o') && !maparg('[o', 'o') + omap <buffer> [o <Plug>TwodoPreviousRegular +endif + +if !hasmapto('<Plug>TwodoNextImportant', 'n') && !maparg(']y', 'n') + nmap <buffer> ]y <Plug>TwodoNextImportant +endif + +if !hasmapto('<Plug>TwodoNextImportant', 'o') && !maparg(']y', 'o') + omap <buffer> ]y <Plug>TwodoNextImportant +endif + +if !hasmapto('<Plug>TwodoPreviousImportant', 'n') && !maparg('[y', 'n') + nmap <buffer> [y <Plug>TwodoPreviousImportant +endif + +if !hasmapto('<Plug>TwodoPreviousImportant', 'o') && !maparg('[y', 'o') + omap <buffer> [y <Plug>TwodoPreviousImportant +endif |