10 Commits
v0.6 ... v0.7.1

Author SHA1 Message Date
David Beniamine
4da3c4ae12 Small bug fixes
FIX: Typo in sort function
FIX: Keyword completion
CHG: Sort done.txt by completion date
2015-07-05 16:41:58 +02:00
David Beniamine
e7dee69733 fix bad links in readme 2015-07-05 15:06:03 +02:00
David Beniamine
73ba0effca Small improvements on due dates + key:value
ADD: syntax highlight for couples key:value
ADD: Handle DUE:date
CHG: No space between due: and date
CHG: Doc updated
2015-07-05 15:00:07 +02:00
David Beniamine
cf10a3b0b8 better due date sorting and due compeltion 2015-07-05 13:17:50 +02:00
David Beniamine
e49cc7d595 Incorporated due date workaround from durcheinandr 2015-07-05 12:29:02 +02:00
David Beniamine
7bca6726ea Recommand buffer mapping for completion 2015-06-12 15:24:23 +02:00
durcheinandr
eb5ece482d shorten short due date function 2015-05-27 16:24:48 +02:00
durcheinandr
eb6d973887 last fix for sorting due dates 2015-05-27 05:56:52 +02:00
durcheinandr
84c815bb21 fixed sorting by due-date 2015-05-26 19:50:37 +02:00
durcheinandr
1b49ec094c here we go 2015-05-25 23:57:26 +02:00
6 changed files with 158 additions and 51 deletions

View File

@@ -2,9 +2,12 @@
## What is this plugin ? ## What is this plugin ?
This plugin is a fork of freitass todo.txt (see section 1.3) vim plugin adding This plugin is a fork of [freitass
a nice two level sorting function designed for todo.txt files and a complete todo.txt](https://github.com/freitass/todo.txt-vim). It add severals functionalities including a [hierarchical sort](#sort), a
function for context and projects (see section 1.4). [complete](#completion) function, some stuff to handle [due dates](#due-dates)
and others stuff see [new features](#new-features).
Freitass announced on october 30th 2014 that he is not going to merge his version.
## Install ## Install
@@ -14,10 +17,17 @@ function for context and projects (see section 1.4).
cd todo.txt-vim cd todo.txt-vim
cp -r ./* ~/.vim cp -r ./* ~/.vim
If you want the help installed, run `:helptags ~/.vim/doc` inside vim after
having copied the files. Then you will be able to get the commands help with:
`:h todo.txt`
### Pathogen install ### Pathogen install
git clone https://github.com/dbeniamine/todo.txt-vim.git ~/.vim/bundle/todo.txt-vim git clone https://github.com/dbeniamine/todo.txt-vim.git ~/.vim/bundle/todo.txt-vim
Then from vim: `:Helptags` to update the doc
## Features included in Freitass version ## Features included in Freitass version
This plugin gives syntax highlighting to [todo.txt](http://todotxt.com/) files. It also defines a few mappings, to help with editing these files: This plugin gives syntax highlighting to [todo.txt](http://todotxt.com/) files. It also defines a few mappings, to help with editing these files:
@@ -48,11 +58,10 @@ This plugin gives syntax highlighting to [todo.txt](http://todotxt.com/) files.
`<leader>-D` : Move completed tasks to done.txt `<leader>-D` : Move completed tasks to done.txt
If you want the help installed, run ":helptags ~/.vim/doc" inside vim after having copied the files.
Then you will be able to get the commands help with: :h todo.txt
## New features ## New features
### Sort
This fork provides a hierarchical sorting function designed to do by project This fork provides a hierarchical sorting function designed to do by project
and/or by context sorts and a priority sort. and/or by context sorts and a priority sort.
@@ -67,7 +76,7 @@ see :help sort
let g:Todo_txt_first_level_sort_mode="! i" let g:Todo_txt_first_level_sort_mode="! i"
let g:Todo_txt_second_level_sort_mode="i" let g:Todo_txt_second_level_sort_mode="i"
Also `<LocalLeader>x` is a toggle which allow you to unmark a task as done. ### Completion
We also provide a nice complete function for project and context, to use it We also provide a nice complete function for project and context, to use it
add the following lines to your vimrc: add the following lines to your vimrc:
@@ -79,16 +88,43 @@ You can also start automatically the completion when entering '+' or '@' by
adding the next lines to your vimrc: adding the next lines to your vimrc:
" Auto complete projects " Auto complete projects
au filetype todo imap + +<C-X><C-O> au filetype todo imap <buffer> + +<C-X><C-O>
" Auto complete contexts " Auto complete contexts
au filetype todo imap @ @<C-X><C-O> au filetype todo imap <buffer> @ @<C-X><C-O>
The TodoComplete function is designed to complete projects (starting by '+') The TodoComplete function is designed to complete projects (starting by '+')
and context (starting by '@'). If you use it on a regular word, it will do a and context (starting by '@'). If you use it on a regular word, it will do a
normal buffer completion. normal keyword completion (on all buffers).
If you try to complete a project, it will propose all projects in all open If you try to complete a project, it will propose all projects in all open
buffers and for each of them, it will show their context and the name of the buffers and for each of them, it will show their context and the name of the
buffers in which they appears in the preview window. buffers in which they appears in the preview window.
TodoCompelte does the same thing for context except that it gives in the TodoCompelte does the same thing for context except that it gives in the
preview the list of projects existing in each existing contexts. preview the list of projects existing in each existing contexts.
### Due dates
I've integrated the [work from
durcheinandr](https://github.com/durcheinandr/todo.txt-vim/) concerning due
dates + some little improvements:
Accorrding to the todo.txt rules, one can define due dates using `due:date` or
`DUE:date` or any other `key:value` combination. This plugins handle dates at
the format `YYYY-MM-DD` and the key `due` can be spell using any combination
of lower and upper case letters. The following mappings are provided:
`<leader>-sd` : Sort the file by due-date. Entries with a due date appears
sorted by at the beginning of the file, the rest of the file is not modified.
`due:` : (Insert mode) Insert `due:` followed by the current date
`DUE:` : (Insert mode) Insert `DUE:` followed by the current date
### Others
`<LocalLeader>x` is a toggle which allow you to unmark a task as done.
Syntax highlighting for couples key:value
If the current buffer is a done.txt file, the basic sort sorts on completion
date.

View File

@@ -9,6 +9,8 @@ COMMANDS *todo-commands*
`<LocalLeader>s@` : Sort the file on @Contexts `<LocalLeader>s@` : Sort the file on @Contexts
`<LocalLeader>s@` : Sort the file on due dates
`<LocalLeader>sc` : Sort the file by context then by priority `<LocalLeader>sc` : Sort the file by context then by priority
`<LocalLeader>scp` : Sort the file by context, project then by priority `<LocalLeader>scp` : Sort the file by context, project then by priority
@@ -17,6 +19,9 @@ COMMANDS *todo-commands*
`<LocalLeader>spc` : Sort the file by project, context then by priority `<LocalLeader>spc` : Sort the file by project, context then by priority
`<leader>-sd` : Sort the file by due-date. Entries with a due date appears
sorted by at the beginning of the file, the rest of the file is not modified.
`<LocalLeader>j` : Lower the priority of the current line `<LocalLeader>j` : Lower the priority of the current line
`<LocalLeader>k` : Increase the priority of the current line `<LocalLeader>k` : Increase the priority of the current line
@@ -31,6 +36,10 @@ COMMANDS *todo-commands*
`date<tab>` : (Insert mode) Insert the current date `date<tab>` : (Insert mode) Insert the current date
`due:` : (Insert mode) Insert `due:` followed by the current date
`DUE:` : (Insert mode) Insert `DUE:` followed by the current date
`<LocalLeader>x` : Toggle mark task as done (inserts or remove current date as `<LocalLeader>x` : Toggle mark task as done (inserts or remove current date as
completion date) completion date)
@@ -67,16 +76,17 @@ You can also start automatically the completion when entering '+' or '@' by
adding the next lines to your vimrc: adding the next lines to your vimrc:
" Auto complete projects " Auto complete projects
au filetype todo imap + +<C-X><C-O> au filetype todo imap <buffer> + +<C-X><C-O>
" Auto complete contexts " Auto complete contexts
au filetype todo imap @ @<C-X><C-O> au filetype todo imap <buffer> @ @<C-X><C-O>
=============================================================================== ===============================================================================
COMPLETION *todo-complete* COMPLETION *todo-complete*
The TodoComplete function is designed to complete projects (starting by '+') The TodoComplete function is designed to complete projects (starting by '+')
and context (starting by '@'). If you use it on a regular word, it will do a and context (starting by '@'). If you use it on a regular word, it will do a
normal buffer completion. normal keyword completion (on all buffers).
If you try to complete a project, it will propose all projects in all open If you try to complete a project, it will propose all projects in all open
buffers and for each of them, it will show their context and the name of the buffers and for each of them, it will show their context and the name of the
buffers in which they appears in the preview window. buffers in which they appears in the preview window.

View File

@@ -1,9 +1,9 @@
" File: todo.txt.vim " File: todo.txt.vim
" Description: Todo.txt filetype detection " Description: Todo.txt filetype detection
" Author: Leandro Freitas <freitass@gmail.com> " Author: David Beniamine <david@beniamine.net>, Leandro Freitas <freitass@gmail.com>
" License: Vim license " License: Vim license
" Website: http://github.com/dbeniamine/todo.txt-vim " Website: http://github.com/dbeniamine/todo.txt-vim
" Version: 0.6 " Version: 0.7
autocmd BufNewFile,BufRead [Tt]odo.txt set filetype=todo autocmd BufNewFile,BufRead [Tt]odo.txt set filetype=todo
autocmd BufNewFile,BufRead [Dd]one.txt set filetype=todo autocmd BufNewFile,BufRead [Dd]one.txt set filetype=todo

View File

@@ -1,9 +1,9 @@
" File: todo.txt.vim " File: todo.txt.vim
" Description: Todo.txt filetype detection " Description: Todo.txt filetype detection
" Author: Leandro Freitas <freitass@gmail.com>, David Beniamine <David@Beniamine.net> " Author: David Beniamine <David@Beniamine.net>, Leandro Freitas <freitass@gmail.com>
" License: Vim license " License: Vim license
" Website: http://github.com/dbeniamine/todo.txt-vim " Website: http://github.com/dbeniamine/todo.txt-vim
" Version: 0.6 " Version: 0.7.1
" Save context {{{1 " Save context {{{1
let s:save_cpo = &cpo let s:save_cpo = &cpo
@@ -39,7 +39,6 @@ function! TodoTxtUnMarkAsDone()
:s/\s*x\s*\d\{4}-\d\{1,2}-\d\{1,2}\s*//g :s/\s*x\s*\d\{4}-\d\{1,2}-\d\{1,2}\s*//g
endfunction endfunction
function! TodoTxtMarkAsDone()
function! TodoTxtMarkAsDone() function! TodoTxtMarkAsDone()
call TodoTxtPrependDate() call TodoTxtPrependDate()
normal! Ix normal! Ix
@@ -80,9 +79,35 @@ endfunction
function! TodoTxtSort() function! TodoTxtSort()
" vim :sort is usually stable " vim :sort is usually stable
" we sort first on contexts, then on projects and then on priority " we sort first on contexts, then on projects and then on priority
:sort /@[a-zA-Z]*/ r if expand('%')=~'done.txt'
:sort /+[a-zA-Z]*/ r silent! %s/\(x\s*\d\{4}\)-\(\d\{2}\)-\(\d\{2}\)/\1\2\3/g
sort n /^x\s*/
silent! %s/\(x\s*\d\{4}\)\(\d\{2}\)/\1-\2-/g
else
sort /@[a-zA-Z]*/ r
sort /+[a-zA-Z]*/ r
sort /\v\([A-Z]\)/ r
endif
endfunction
function! TodoTxtSortDue()
silent! %s/\([dD][uU][eE]:\d\{4}\)-\(\d\{2}\)-\(\d\{2}\)/\1\2\3/g
" Sort adding entries with due dates add the beginning
sort n /[dD][uU][eE]:/
" Count the number of lines
silent normal gg
execute "/[dD][uU][eE]:"
let l:first=getpos(".")[1]
silent normal N
let l:last=getpos(".")[1]
let l:diff=l:last-l:first+1
" Put the sorted lines at the beginning of the file
execute ':'.l:first
execute ':d'.l:diff
silent normal gg
silent normal P
silent! %s/\([dD][uU][eE]:\d\{4}\)\(\d\{2}\)/\1-\2-/g
" TODO: add time sorting (YYYY-MM-DD HH:MM) " TODO: add time sorting (YYYY-MM-DD HH:MM)
endfunction endfunction
@@ -182,6 +207,14 @@ if !hasmapto("date<Tab>",'i')
if !hasmapto("date<Tab>",'i') if !hasmapto("date<Tab>",'i')
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>
endif endif
if !hasmapto("due:",'i')
inoremap <script> <silent> <buffer> due: due:<C-R>=strftime("%Y-%m-%d")<CR>
endif
if !hasmapto("DUE:",'i')
inoremap <script> <silent> <buffer> DUE: DUE:<C-R>=strftime("%Y-%m-%d")<CR>
endif
if !hasmapto("<localleader>d",'n') if !hasmapto("<localleader>d",'n')
nnoremap <script> <silent> <buffer> <localleader>d :call TodoTxtPrependDate()<CR> nnoremap <script> <silent> <buffer> <localleader>d :call TodoTxtPrependDate()<CR>
@@ -209,6 +242,11 @@ if !hasmapto("<localleader>D",'n')
if !hasmapto("<localleader>D",'n') if !hasmapto("<localleader>D",'n')
nnoremap <script> <silent> <buffer> <localleader>D :call TodoTxtRemoveCompleted()<CR> nnoremap <script> <silent> <buffer> <localleader>D :call TodoTxtRemoveCompleted()<CR>
endif endif
" Sort by due: date {{{2
if !hasmapto("<localleader>sd".'n')
nnoremap <script> <silent> <buffer> <localleader>sd :call TodoTxtSortDue()<CR>
endif
" Folding {{{1 " Folding {{{1
" Options {{{2 " Options {{{2
@@ -237,6 +275,24 @@ function! TodoFoldText()
\ . (v:foldend - v:foldstart + 1) \ . (v:foldend - v:foldstart + 1)
\ . ' Completed tasks ' \ . ' Completed tasks '
endfunction endfunction
" Simple keyword completion on all buffers
function! TodoKeywordComplete(base)
" Search for matchs
let res = []
for bufnr in range(1,bufnr('$'))
let lines=getbufline(bufnr,1,"$")
for line in lines
if line =~ a:base
" init temporary item
let item={}
let item.word=substitute(line,'.*\('.a:base.'\S*\).*','\1',"")
call add(res,item)
endif
endfor
endfor
return res
endfunction
" Intelligent completion for projects and Contexts " Intelligent completion for projects and Contexts
fun! TodoComplete(findstart, base) fun! TodoComplete(findstart, base)
@@ -247,6 +303,9 @@ fun! TodoComplete(findstart, base)
let start -= 1 let start -= 1
endwhile endwhile
return start return start
else
if a:base !~ '^+' && a:base !~ '^@'
return TodoKeywordComplete(a:base)
endif endif
" Opposite sign " Opposite sign
let opp=a:base=~'+'?'@':'+' let opp=a:base=~'+'?'@':'+'

View File

@@ -3,7 +3,7 @@
" Author: David Beniamine <david@beniamine.net> " Author: David Beniamine <david@beniamine.net>
" Licence: Vim licence " Licence: Vim licence
" Website: http://github.com/dbeniamine/todo.txt.vim " Website: http://github.com/dbeniamine/todo.txt.vim
" Version: 0.6 " Version: 0.7
" vim: ts=4 sw=4 :help tw=78 cc=80 " vim: ts=4 sw=4 :help tw=78 cc=80
" These two variables are parameters for the successive calls the vim sort " These two variables are parameters for the successive calls the vim sort

View File

@@ -1,46 +1,48 @@
" File: todo.txt.vim " File: todo.txt.vim
" Description: Todo.txt syntax settings " Description: Todo.txt syntax settings
" Author: Leandro Freitas <freitass@gmail.com>, David Beniamine <David@Beniamine.net> " Author: David Beniamine <David@Beniamine.net>,Leandro Freitas <freitass@gmail.com>
" License: Vim license " License: Vim license
" Website: http://github.com/dbeniamine/todo.txt-vim " Website: http://github.com/dbeniamine/todo.txt-vim
" Version: 0.6 " Version: 0.7
if exists("b:current_syntax") if exists("b:current_syntax")
finish finish
endif endif
syntax match TodoDone '^[xX]\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoDone '^[xX]\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityA '^([aA])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityA '^([aA])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityB '^([bB])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityB '^([bB])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityC '^([cC])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityC '^([cC])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityD '^([dD])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityD '^([dD])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityE '^([eE])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityE '^([eE])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityF '^([fF])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityF '^([fF])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityG '^([gG])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityG '^([gG])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityH '^([hH])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityH '^([hH])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityI '^([iI])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityI '^([iI])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityJ '^([jJ])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityJ '^([jJ])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityK '^([kK])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityK '^([kK])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityL '^([lL])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityL '^([lL])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityM '^([mM])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityM '^([mM])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityN '^([nN])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityN '^([nN])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityO '^([oO])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityO '^([oO])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityP '^([pP])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityP '^([pP])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityQ '^([qQ])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityQ '^([qQ])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityR '^([rR])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityR '^([rR])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityS '^([sS])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityS '^([sS])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityT '^([tT])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityT '^([tT])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityU '^([uU])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityU '^([uU])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityV '^([vV])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityV '^([vV])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityW '^([wW])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityW '^([wW])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityX '^([xX])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityX '^([xX])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityY '^([yY])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityY '^([yY])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityZ '^([zZ])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityZ '^([zZ])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoDate '\d\{2,4\}-\d\{2\}-\d\{2\}' contains=NONE syntax match TodoDate '\d\{2,4\}-\d\{2\}-\d\{2\}' contains=NONE
syntax match TodoKey '\S*:\S*' contains=TodoDate
syntax match TodoProject '\(^\|\W\)+[^[:blank:]]\+' contains=NONE syntax match TodoProject '\(^\|\W\)+[^[:blank:]]\+' contains=NONE
syntax match TodoContext '\(^\|\W\)@[^[:blank:]]\+' contains=NONE syntax match TodoContext '\(^\|\W\)@[^[:blank:]]\+' contains=NONE
" Other priority colours might be defined by the user " Other priority colours might be defined by the user
highlight default link TodoKey Special
highlight default link TodoDone Comment highlight default link TodoDone Comment
highlight default link TodoPriorityA Identifier highlight default link TodoPriorityA Identifier
highlight default link TodoPriorityB statement highlight default link TodoPriorityB statement