From 6a9876afd797eb306f63cda250bc2815d3f3ceef Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 15 Mar 2020 16:08:59 +0100 Subject: Add mappings to move to the next and previous to-do `[u` and `]u` for "unfinished". --- autoload/todo/motion.vim | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 autoload/todo/motion.vim (limited to 'autoload') diff --git a/autoload/todo/motion.vim b/autoload/todo/motion.vim new file mode 100644 index 0000000..3ebab2d --- /dev/null +++ b/autoload/todo/motion.vim @@ -0,0 +1,13 @@ +let s:INCOMPLETE_MATCHER = '^\s*[\-_!] ' + + +function! todo#motion#NextIncomplete() + normal! m' + call search(s:INCOMPLETE_MATCHER) +endfunction + + +function! todo#motion#PreviousIncomplete() + normal! m' + call search(s:INCOMPLETE_MATCHER, 'b') +endfunction -- cgit v1.2.3 From 953c0b15706cb7f8cded7d6792e5031e2a78228f Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 21 Mar 2020 19:20:39 +0100 Subject: todo#motion#NextIncomplete(): Add count support --- autoload/todo/motion.vim | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'autoload') diff --git a/autoload/todo/motion.vim b/autoload/todo/motion.vim index 3ebab2d..96877a9 100644 --- a/autoload/todo/motion.vim +++ b/autoload/todo/motion.vim @@ -2,8 +2,15 @@ let s:INCOMPLETE_MATCHER = '^\s*[\-_!] ' function! todo#motion#NextIncomplete() + let cnt = v:count1 + normal! m' - call search(s:INCOMPLETE_MATCHER) + + let i = 0 + while i < cnt + call search(s:INCOMPLETE_MATCHER) + let i += 1 + endwhile endfunction -- cgit v1.2.3 From 0fa59c30f1a6f5e1a9796e5df53c7cd955994509 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 21 Mar 2020 19:44:44 +0100 Subject: Support counts in both `NextIncomplete()` and `PreviousIncomplete()` --- autoload/todo/motion.vim | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'autoload') diff --git a/autoload/todo/motion.vim b/autoload/todo/motion.vim index 96877a9..27d6264 100644 --- a/autoload/todo/motion.vim +++ b/autoload/todo/motion.vim @@ -1,20 +1,24 @@ let s:INCOMPLETE_MATCHER = '^\s*[\-_!] ' -function! todo#motion#NextIncomplete() +function! s:Incomplete(search_flags) let cnt = v:count1 normal! m' let i = 0 while i < cnt - call search(s:INCOMPLETE_MATCHER) + call search(s:INCOMPLETE_MATCHER, a:search_flags) let i += 1 endwhile endfunction +function! todo#motion#NextIncomplete() + call s:Incomplete('') +endfunction + + function! todo#motion#PreviousIncomplete() - normal! m' - call search(s:INCOMPLETE_MATCHER, 'b') + call s:Incomplete('b') endfunction -- cgit v1.2.3 From cb76590a7d75f9e49273b1f5ad7fbffaf3a0fd17 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 21 Mar 2020 20:01:34 +0100 Subject: motion.vim/s:Incomplete(): Use `s` search flag to mark Learned that `search()` accepts an `s` flag to mark the previous cursor location, so figured we should take advantage of that and remove the manual mark line. --- autoload/todo/motion.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'autoload') diff --git a/autoload/todo/motion.vim b/autoload/todo/motion.vim index 27d6264..32a7c88 100644 --- a/autoload/todo/motion.vim +++ b/autoload/todo/motion.vim @@ -1,14 +1,14 @@ let s:INCOMPLETE_MATCHER = '^\s*[\-_!] ' -function! s:Incomplete(search_flags) +function! s:Incomplete(extra_search_flags) let cnt = v:count1 - normal! m' + let search_flags = 's' . a:extra_search_flags let i = 0 while i < cnt - call search(s:INCOMPLETE_MATCHER, a:search_flags) + call search(s:INCOMPLETE_MATCHER, search_flags) let i += 1 endwhile endfunction -- cgit v1.2.3