Add command and map to jump to the next unfinished task.

Introduce the command `VimwikiNextTask` and the mapping `gnt` to jump to
the next unfinished task.
This commit is contained in:
Henry Qin 2019-02-27 19:45:39 -08:00
parent b849a411e3
commit 3f7f85cfc6
3 changed files with 20 additions and 0 deletions

View File

@ -1156,6 +1156,11 @@ function! vimwiki#base#update_listing_in_buffer(strings, start_header,
call winrestview(winview_save) call winrestview(winview_save)
endfunction endfunction
function! vimwiki#base#find_next_task()
let taskRegex = vimwiki#vars#get_syntaxlocal('rxListItemWithoutCB')
\ . '\+\(\[ \]\s\+\)\zs'
call vimwiki#base#search_word(taskRegex, '')
endfunction
function! vimwiki#base#find_next_link() function! vimwiki#base#find_next_link()
call vimwiki#base#search_word(vimwiki#vars#get_syntaxlocal('rxAnyLink'), '') call vimwiki#base#search_word(vimwiki#vars#get_syntaxlocal('rxAnyLink'), '')

View File

@ -317,6 +317,12 @@ NORMAL MODE *vimwiki-local-mappings*
Maps to |:VimwikiPrevLink|. Maps to |:VimwikiPrevLink|.
To remap: > To remap: >
:nmap <Leader>wp <Plug>VimwikiPrevLink :nmap <Leader>wp <Plug>VimwikiPrevLink
<
gnt *vimwiki_gnt*
Find next unfinished task in the current page.
Maps to |:VimwikiNextTask|
To remap: >
:nmap <Leader>nt <Plug>VimwikiNextTask
< <
*vimwiki_<Leader>wd* *vimwiki_<Leader>wd*
<Leader>wd Delete wiki page you are in. <Leader>wd Delete wiki page you are in.
@ -723,6 +729,9 @@ Vimwiki file.
*:VimwikiRenameLink* *:VimwikiRenameLink*
Rename the wiki page you are in. Rename the wiki page you are in.
*:VimwikiNextTask*
Jump to the next unfinished task in the current wiki page.
*:Vimwiki2HTML* *:Vimwiki2HTML*
Convert current wiki page to HTML using Vimwiki's own converter or a Convert current wiki page to HTML using Vimwiki's own converter or a
user-supplied script (see |vimwiki-option-custom_wiki2html|). user-supplied script (see |vimwiki-option-custom_wiki2html|).

View File

@ -253,6 +253,7 @@ command! -buffer VimwikiAll2HTML
command! -buffer VimwikiTOC call vimwiki#base#table_of_contents(1) command! -buffer VimwikiTOC call vimwiki#base#table_of_contents(1)
command! -buffer VimwikiNextTask call vimwiki#base#find_next_task()
command! -buffer VimwikiNextLink call vimwiki#base#find_next_link() command! -buffer VimwikiNextLink call vimwiki#base#find_next_link()
command! -buffer VimwikiPrevLink call vimwiki#base#find_prev_link() command! -buffer VimwikiPrevLink call vimwiki#base#find_prev_link()
command! -buffer VimwikiDeleteLink call vimwiki#base#delete_link() command! -buffer VimwikiDeleteLink call vimwiki#base#delete_link()
@ -381,6 +382,11 @@ endif
vnoremap <silent><script><buffer> vnoremap <silent><script><buffer>
\ <Plug>VimwikiNormalizeLinkVisualCR :<C-U>VimwikiNormalizeLink 1<CR> \ <Plug>VimwikiNormalizeLinkVisualCR :<C-U>VimwikiNormalizeLink 1<CR>
if !hasmapto('<Plug>VimwikiNextTask')
nmap <silent><buffer> gnt <Plug>VimwikiNextTask
endif
nnoremap <silent><script><buffer> <Plug>VimwikiNextTask :VimwikiNextTask<CR>
if !hasmapto('<Plug>VimwikiTabnewLink') if !hasmapto('<Plug>VimwikiTabnewLink')
nmap <silent><buffer> <D-CR> <Plug>VimwikiTabnewLink nmap <silent><buffer> <D-CR> <Plug>VimwikiTabnewLink
nmap <silent><buffer> <C-S-CR> <Plug>VimwikiTabnewLink nmap <silent><buffer> <C-S-CR> <Plug>VimwikiTabnewLink