summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Beniamine <david@beniamine.net>2018-04-19 23:45:48 +0200
committerDavid Beniamine <david@beniamine.net>2018-04-19 23:45:48 +0200
commit2483961aaf236bd75f464ab52069aefa2bb07a88 (patch)
tree36c8ec601d454982090b4fbf0cdec87eabd22219
parent7b0262ae84ccf345d50babe6575c7e608365d855 (diff)
parentf23b1c2cac9d2407825ff1cae01ecd1ea93510ff (diff)
downloadtodo.txt-vim-2483961aaf236bd75f464ab52069aefa2bb07a88.zip
Merge branch 'master' of https://github.com/fretep/todo.txt-vim
-rw-r--r--autoload/todo.vim4
-rw-r--r--ftplugin/todo.vim116
2 files changed, 63 insertions, 57 deletions
diff --git a/autoload/todo.vim b/autoload/todo.vim
index 8b6c928..937c3e0 100644
--- a/autoload/todo.vim
+++ b/autoload/todo.vim
@@ -29,10 +29,6 @@ function! todo#GetCurpos()
return getpos('.')
endfunction
-" Increment and Decrement The Priority.
-" TODO: Make nrformats local to buffers of type todo
-:set nf=octal,hex,alpha
-
function! todo#PrioritizeIncrease()
normal! 0f)h
endfunction
diff --git a/ftplugin/todo.vim b/ftplugin/todo.vim
index 79c6c39..5949e7b 100644
--- a/ftplugin/todo.vim
+++ b/ftplugin/todo.vim
@@ -16,81 +16,91 @@ set cpo&vim
" General options {{{1
" 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.
setlocal textwidth=0
setlocal wrapmargin=0
+" Increment and decrement the priority use <C-A> and <C-X> on alpha
+setlocal nrformats+=alpha
+
" Mappings {{{1
-nnoremap <silent> <buffer> <Plug>TodotxtIncrementDueDateNormal :<C-u>call <SID>ChangeDueDateWrapper(1, "\<Plug>TodotxtIncrementDueDateNormal")<CR>
-vnoremap <silent> <buffer> <Plug>TodotxtIncrementDueDateVisual :call <SID>ChangeDueDateWrapper(1, "\<Plug>TodotxtIncrementDueDateVisual")<CR>
-nnoremap <silent> <buffer> <Plug>TodotxtDecrementDueDateNormal :<C-u>call <SID>ChangeDueDateWrapper(-1, "\<Plug>TodotxtDecrementDueDateNormal")<CR>
-vnoremap <silent> <buffer> <Plug>TodotxtDecrementDueDateVisual :call <SID>ChangeDueDateWrapper(-1, "\<Plug>TodotxtDecrementDueDateVisual")<CR>
+" <Plug> mappings that users can map alternate keys to {{{2
+" if they choose not to map default keys (or otherwise)
+nnoremap <script> <silent> <buffer> <Plug>TodotxtIncrementDueDateNormal :<C-u>call <SID>ChangeDueDateWrapper(1, "\<Plug>TodotxtIncrementDueDateNormal")<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
-" Sort todo by (first) context
- noremap <silent><localleader>sc :call todo#HierarchicalSort('@', '', 1)<CR>
-
- noremap <silent><localleader>scp :call todo#HierarchicalSort('@', '+', 1)<CR>
-" Sort todo by (first) project
- noremap <silent><localleader>sp :call todo#HierarchicalSort('+', '',1)<CR>
- noremap <silent><localleader>spc :call todo#HierarchicalSort('+', '@',1)<CR>
-
-" Sort tasks {{{2
- 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>
-" 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>
- noremap <script> <silent> <buffer> <LocalLeader>b :call todo#PrioritizeAdd('B')<CR>
- noremap <script> <silent> <buffer> <LocalLeader>c :call todo#PrioritizeAdd('C')<CR>
-
-" Insert date {{{2
+" Sort todo by (first) context {{{3
+ noremap <script> <silent> <buffer> <localleader>sc :call todo#HierarchicalSort('@', '', 1)<CR>
+ noremap <script> <silent> <buffer> <localleader>scp :call todo#HierarchicalSort('@', '+', 1)<CR>
+
+" Sort todo by (first) project {{{3
+ noremap <script> <silent> <buffer> <localleader>sp :call todo#HierarchicalSort('+', '',1)<CR>
+ noremap <script> <silent> <buffer> <localleader>spc :call todo#HierarchicalSort('+', '@',1)<CR>
+
+" Sort tasks {{{3
+ 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>
+
+" Priorities {{{3
+ " TODO: Make vim-repeat work on inc/dec priority
+ 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>
+ 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> due: due:<C-R>=strftime("%Y-%m-%d")<CR>
inoremap <script> <silent> <buffer> DUE: DUE:<C-R>=strftime("%Y-%m-%d")<CR>
- noremap <script> <silent> <buffer> <localleader>d :call todo#PrependDate()<CR>
+ noremap <script> <silent> <buffer> <localleader>d :call todo#PrependDate()<CR>
-" Mark done {{{2
- noremap <script> <silent> <buffer> <Plug>DoToggleMarkAsDone :call todo#ToggleMarkAsDone('')<CR>
- \:silent! call repeat#set("\<Plug>DoToggleMarkAsDone")<CR>
- nmap <localleader>x <Plug>DoToggleMarkAsDone
- " noremap <script> <silent> <buffer> <localleader>x :call todo#ToggleMarkAsDone('')<CR>
+" Mark done {{{3
+ nmap <silent> <buffer> <localleader>x <Plug>DoToggleMarkAsDone
-" Mark done {{{2
- noremap <script> <silent> <buffer> <Plug>DoCancel :call todo#ToggleMarkAsDone('Cancelled')<CR>
- \:silent! call repeat#set("\<Plug>DoCancel")<CR>
- nmap <localleader>C <Plug>DoCancel
+" Mark cancelled {{{3
+ nmap <silent> <buffer> <localleader>C <Plug>DoCancel
-" Mark all done {{{2
- noremap <script> <silent> <buffer> <localleader>X :call todo#MarkAllAsDone()<CR>
+" Mark all done {{{3
+ 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>
-" Sort by due: date {{{2
+" Sort by due: date {{{3
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>
-" increment and decrement due:date {{{2
- nmap <localleader>p <Plug>TodotxtIncrementDueDateNormal
- vmap <localleader>p <Plug>TodotxtIncrementDueDateVisual
- nmap <localleader>P <Plug>TodotxtDecrementDueDateNormal
- vmap <localleader>P <Plug>TodotxtDecrementDueDateVisual
-
-" Prefix creation date when opening a new line {{{2
- 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>
- inoremap <script> <silent> <buffer> <CR> <CR><C-R>=strftime("%Y-%m-%d")<CR>
- endif
+" increment and decrement due:date {{{3
+ nmap <silent> <buffer> <localleader>p <Plug>TodotxtIncrementDueDateNormal
+ vmap <silent> <buffer> <localleader>p <Plug>TodotxtIncrementDueDateVisual
+ nmap <silent> <buffer> <localleader>P <Plug>TodotxtDecrementDueDateNormal
+ vmap <silent> <buffer> <localleader>P <Plug>TodotxtDecrementDueDateVisual
+
+endif
+
+" Additional options {{{2
+" Prefix creation date when opening a new line {{{3
+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>
+ inoremap <script> <silent> <buffer> <CR> <CR><C-R>=strftime("%Y-%m-%d")<CR>
endif
" Functions for maps {{{1