This commit is contained in:
David Beniamine
2018-04-19 23:45:48 +02:00
2 changed files with 58 additions and 52 deletions

View File

@@ -29,10 +29,6 @@ function! todo#GetCurpos()
return getpos('.') return getpos('.')
endfunction endfunction
" Increment and Decrement The Priority.
" TODO: Make nrformats local to buffers of type todo
:set nf=octal,hex,alpha
function! todo#PrioritizeIncrease() function! todo#PrioritizeIncrease()
normal! 0f)h normal! 0f)h
endfunction endfunction

View File

@@ -16,40 +16,53 @@ set cpo&vim
" General options {{{1 " General options {{{1
" Some options lose their values when window changes. They will be set every " Some options lose their values when window changes. They will be set every
" time this script is invocated, which is whenever a file of this type is " time this script is invoked, which is whenever a file of this type is
" created or edited. " created or edited.
setlocal textwidth=0 setlocal textwidth=0
setlocal wrapmargin=0 setlocal wrapmargin=0
" Increment and decrement the priority use <C-A> and <C-X> on alpha
setlocal nrformats+=alpha
" Mappings {{{1 " Mappings {{{1
nnoremap <silent> <buffer> <Plug>TodotxtIncrementDueDateNormal :<C-u>call <SID>ChangeDueDateWrapper(1, "\<Plug>TodotxtIncrementDueDateNormal")<CR> " <Plug> mappings that users can map alternate keys to {{{2
vnoremap <silent> <buffer> <Plug>TodotxtIncrementDueDateVisual :call <SID>ChangeDueDateWrapper(1, "\<Plug>TodotxtIncrementDueDateVisual")<CR> " if they choose not to map default keys (or otherwise)
nnoremap <silent> <buffer> <Plug>TodotxtDecrementDueDateNormal :<C-u>call <SID>ChangeDueDateWrapper(-1, "\<Plug>TodotxtDecrementDueDateNormal")<CR> nnoremap <script> <silent> <buffer> <Plug>TodotxtIncrementDueDateNormal :<C-u>call <SID>ChangeDueDateWrapper(1, "\<Plug>TodotxtIncrementDueDateNormal")<CR>
vnoremap <silent> <buffer> <Plug>TodotxtDecrementDueDateVisual :call <SID>ChangeDueDateWrapper(-1, "\<Plug>TodotxtDecrementDueDateVisual")<CR> vnoremap <script> <silent> <buffer> <Plug>TodotxtIncrementDueDateVisual :call <SID>ChangeDueDateWrapper(1, "\<Plug>TodotxtIncrementDueDateVisual")<CR>
nnoremap <script> <silent> <buffer> <Plug>TodotxtDecrementDueDateNormal :<C-u>call <SID>ChangeDueDateWrapper(-1, "\<Plug>TodotxtDecrementDueDateNormal")<CR>
vnoremap <script> <silent> <buffer> <Plug>TodotxtDecrementDueDateVisual :call <SID>ChangeDueDateWrapper(-1, "\<Plug>TodotxtDecrementDueDateVisual")<CR>
noremap <script> <silent> <buffer> <Plug>DoToggleMarkAsDone :call todo#ToggleMarkAsDone('')<CR>
\:silent! call repeat#set("\<Plug>DoToggleMarkAsDone")<CR>
noremap <script> <silent> <buffer> <Plug>DoCancel :call todo#ToggleMarkAsDone('Cancelled')<CR>
\:silent! call repeat#set("\<Plug>DoCancel")<CR>
" Default key mappings {{{2
if !exists("g:Todo_txt_do_not_map") || ! g:Todo_txt_do_not_map if !exists("g:Todo_txt_do_not_map") || ! g:Todo_txt_do_not_map
" Sort todo by (first) context " Sort todo by (first) context {{{3
noremap <silent><localleader>sc :call todo#HierarchicalSort('@', '', 1)<CR> noremap <script> <silent> <buffer> <localleader>sc :call todo#HierarchicalSort('@', '', 1)<CR>
noremap <script> <silent> <buffer> <localleader>scp :call todo#HierarchicalSort('@', '+', 1)<CR>
noremap <silent><localleader>scp :call todo#HierarchicalSort('@', '+', 1)<CR> " Sort todo by (first) project {{{3
" Sort todo by (first) project noremap <script> <silent> <buffer> <localleader>sp :call todo#HierarchicalSort('+', '',1)<CR>
noremap <silent><localleader>sp :call todo#HierarchicalSort('+', '',1)<CR> noremap <script> <silent> <buffer> <localleader>spc :call todo#HierarchicalSort('+', '@',1)<CR>
noremap <silent><localleader>spc :call todo#HierarchicalSort('+', '@',1)<CR>
" Sort tasks {{{2 " Sort tasks {{{3
nnoremap <script> <silent> <buffer> <LocalLeader>s :call todo#Sort()<CR> nnoremap <script> <silent> <buffer> <localleader>s :call todo#Sort()<CR>
nnoremap <script> <silent> <buffer> <LocalLeader>s@ :sort /.\{-}\ze@/ <CR> nnoremap <script> <silent> <buffer> <localleader>s@ :sort /.\{-}\ze@/ <CR>
nnoremap <script> <silent> <buffer> <LocalLeader>s+ :sort /.\{-}\ze+/ <CR> nnoremap <script> <silent> <buffer> <localleader>s+ :sort /.\{-}\ze+/ <CR>
" Priorities {{{2
noremap <script> <silent> <buffer> <LocalLeader>j :call todo#PrioritizeIncrease()<CR>
noremap <script> <silent> <buffer> <LocalLeader>k :call todo#PrioritizeDecrease()<CR>
noremap <script> <silent> <buffer> <LocalLeader>a :call todo#PrioritizeAdd('A')<CR> " Priorities {{{3
noremap <script> <silent> <buffer> <LocalLeader>b :call todo#PrioritizeAdd('B')<CR> " TODO: Make vim-repeat work on inc/dec priority
noremap <script> <silent> <buffer> <LocalLeader>c :call todo#PrioritizeAdd('C')<CR> noremap <script> <silent> <buffer> <localleader>j :call todo#PrioritizeIncrease()<CR>
noremap <script> <silent> <buffer> <localleader>k :call todo#PrioritizeDecrease()<CR>
" Insert date {{{2 noremap <script> <silent> <buffer> <localleader>a :call todo#PrioritizeAdd('A')<CR>
noremap <script> <silent> <buffer> <localleader>b :call todo#PrioritizeAdd('B')<CR>
noremap <script> <silent> <buffer> <localleader>c :call todo#PrioritizeAdd('C')<CR>
" Insert date {{{3
inoremap <script> <silent> <buffer> date<Tab> <C-R>=strftime("%Y-%m-%d")<CR> inoremap <script> <silent> <buffer> date<Tab> <C-R>=strftime("%Y-%m-%d")<CR>
inoremap <script> <silent> <buffer> due: due:<C-R>=strftime("%Y-%m-%d")<CR> inoremap <script> <silent> <buffer> due: due:<C-R>=strftime("%Y-%m-%d")<CR>
@@ -57,41 +70,38 @@ if !exists("g:Todo_txt_do_not_map") || ! g:Todo_txt_do_not_map
noremap <script> <silent> <buffer> <localleader>d :call todo#PrependDate()<CR> noremap <script> <silent> <buffer> <localleader>d :call todo#PrependDate()<CR>
" Mark done {{{2 " Mark done {{{3
noremap <script> <silent> <buffer> <Plug>DoToggleMarkAsDone :call todo#ToggleMarkAsDone('')<CR> nmap <silent> <buffer> <localleader>x <Plug>DoToggleMarkAsDone
\:silent! call repeat#set("\<Plug>DoToggleMarkAsDone")<CR>
nmap <localleader>x <Plug>DoToggleMarkAsDone
" noremap <script> <silent> <buffer> <localleader>x :call todo#ToggleMarkAsDone('')<CR>
" Mark done {{{2 " Mark cancelled {{{3
noremap <script> <silent> <buffer> <Plug>DoCancel :call todo#ToggleMarkAsDone('Cancelled')<CR> nmap <silent> <buffer> <localleader>C <Plug>DoCancel
\:silent! call repeat#set("\<Plug>DoCancel")<CR>
nmap <localleader>C <Plug>DoCancel
" Mark all done {{{2 " Mark all done {{{3
noremap <script> <silent> <buffer> <localleader>X :call todo#MarkAllAsDone()<CR> noremap <script> <silent> <buffer> <localleader>X :call todo#MarkAllAsDone()<CR>
" Remove completed {{{2 " Remove completed {{{3
nnoremap <script> <silent> <buffer> <localleader>D :call todo#RemoveCompleted()<CR> nnoremap <script> <silent> <buffer> <localleader>D :call todo#RemoveCompleted()<CR>
" Sort by due: date {{{2 " Sort by due: date {{{3
nnoremap <script> <silent> <buffer> <localleader>sd :call todo#SortDue()<CR> nnoremap <script> <silent> <buffer> <localleader>sd :call todo#SortDue()<CR>
" try fix format {{{2 " try fix format {{{3
nnoremap <script> <silent> <buffer> <localleader>ff :call todo#FixFormat()<CR> nnoremap <script> <silent> <buffer> <localleader>ff :call todo#FixFormat()<CR>
" increment and decrement due:date {{{2 " increment and decrement due:date {{{3
nmap <localleader>p <Plug>TodotxtIncrementDueDateNormal nmap <silent> <buffer> <localleader>p <Plug>TodotxtIncrementDueDateNormal
vmap <localleader>p <Plug>TodotxtIncrementDueDateVisual vmap <silent> <buffer> <localleader>p <Plug>TodotxtIncrementDueDateVisual
nmap <localleader>P <Plug>TodotxtDecrementDueDateNormal nmap <silent> <buffer> <localleader>P <Plug>TodotxtDecrementDueDateNormal
vmap <localleader>P <Plug>TodotxtDecrementDueDateVisual vmap <silent> <buffer> <localleader>P <Plug>TodotxtDecrementDueDateVisual
" Prefix creation date when opening a new line {{{2 endif
" Additional options {{{2
" Prefix creation date when opening a new line {{{3
if exists("g:Todo_txt_prefix_creation_date") if exists("g:Todo_txt_prefix_creation_date")
nnoremap <script> <silent> <buffer> o o<C-R>=strftime("%Y-%m-%d")<CR> nnoremap <script> <silent> <buffer> o o<C-R>=strftime("%Y-%m-%d")<CR>
nnoremap <script> <silent> <buffer> O O<C-R>=strftime("%Y-%m-%d")<CR> nnoremap <script> <silent> <buffer> O O<C-R>=strftime("%Y-%m-%d")<CR>
inoremap <script> <silent> <buffer> <CR> <CR><C-R>=strftime("%Y-%m-%d")<CR> inoremap <script> <silent> <buffer> <CR> <CR><C-R>=strftime("%Y-%m-%d")<CR>
endif endif
endif
" Functions for maps {{{1 " Functions for maps {{{1
function! s:ChangeDueDateWrapper(by_days, repeat_mapping) function! s:ChangeDueDateWrapper(by_days, repeat_mapping)