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
This commit is contained in:
David Beniamine
2015-07-05 15:00:07 +02:00
parent cf10a3b0b8
commit 73ba0effca
6 changed files with 91 additions and 52 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](#complete) 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,13 +17,16 @@ 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
If you want the help installed, run ":helptags ~/.vim/doc" inside vim after having copied the files. Then from vim: `:Helptags` to update the doc
Then you will be able to get the commands help with: :h todo.txt
## Features included in Freitass version ## Features included in Freitass version
@@ -32,8 +38,6 @@ This plugin gives syntax highlighting to [todo.txt](http://todotxt.com/) files.
`<LocalLeader>s@` : Sort the file on @Contexts `<LocalLeader>s@` : Sort the file on @Contexts
`<leader>-sd` : Sort the file by due-date
`<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
@@ -48,8 +52,6 @@ This plugin gives syntax highlighting to [todo.txt](http://todotxt.com/) files.
`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
`<LocalLeader>x` : Toggle mark task as done (inserts current date as completion date) `<LocalLeader>x` : Toggle mark task as done (inserts current date as completion date)
`<LocalLeader>X` : Mark all tasks as completed `<LocalLeader>X` : Mark all tasks as completed
@@ -58,6 +60,8 @@ This plugin gives syntax highlighting to [todo.txt](http://todotxt.com/) files.
## 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.
@@ -72,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:
@@ -97,3 +101,27 @@ 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

View File

@@ -19,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
@@ -33,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)

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
" Save context {{{1 " Save context {{{1
let s:save_cpo = &cpo let s:save_cpo = &cpo
@@ -85,12 +85,12 @@ function! TodoTxtSort()
sort /\v\([A-Z]\)/ r sort /\v\([A-Z]\)/ r
endfunction endfunction
function! TodoTxtSortDue() function! TodoTxtSortDue()
silent! %s/\([dD][uU][eE]:\d\{4}\)-\(\d\{2}\)-\(\d\{2}\)/\1\2\3/g 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 adding entries with due dates add the beginning
sort n /[dD][uU][eE]:/ sort n /[dD][uU][eE]:/
" Count the number of lines " Count the number of lines
silent normal gg silent normal gg
execute "/[dD][uU][eE]:" execute "/[dD][uU][eE]:"
let l:first=getpos(".")[1] let l:first=getpos(".")[1]
silent normal N silent normal N
@@ -100,7 +100,7 @@ function! TodoTxtSortDue()
execute ':'.l:first execute ':'.l:first
execute ':d'.l:diff execute ':d'.l:diff
silent normal gg silent normal gg
silent normal P silent normal P
silent! %s/\([dD][uU][eE]:\d\{4}\)\(\d\{2}\)/\1-\2-/g 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
@@ -202,7 +202,11 @@ 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') 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> inoremap <script> <silent> <buffer> DUE: DUE:<C-R>=strftime("%Y-%m-%d")<CR>
endif endif

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,48 +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=TodoDue,TodoDate,TodoProject,TodoContext syntax match TodoDone '^[xX]\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityA '^([aA])\s.\+$' contains=TodoDue,TodoDate,TodoProject,TodoContext syntax match TodoPriorityA '^([aA])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityB '^([bB])\s.\+$' contains=TodoDue,TodoDate,TodoProject,TodoContext syntax match TodoPriorityB '^([bB])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityC '^([cC])\s.\+$' contains=TodoDue,TodoDate,TodoProject,TodoContext syntax match TodoPriorityC '^([cC])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityD '^([dD])\s.\+$' contains=TodoDue,TodoDate,TodoProject,TodoContext syntax match TodoPriorityD '^([dD])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityE '^([eE])\s.\+$' contains=TodoDue,TodoDate,TodoProject,TodoContext syntax match TodoPriorityE '^([eE])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityF '^([fF])\s.\+$' contains=TodoDue,TodoDate,TodoProject,TodoContext syntax match TodoPriorityF '^([fF])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityG '^([gG])\s.\+$' contains=TodoDue,TodoDate,TodoProject,TodoContext syntax match TodoPriorityG '^([gG])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityH '^([hH])\s.\+$' contains=TodoDue,TodoDate,TodoProject,TodoContext syntax match TodoPriorityH '^([hH])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityI '^([iI])\s.\+$' contains=TodoDue,TodoDate,TodoProject,TodoContext syntax match TodoPriorityI '^([iI])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityJ '^([jJ])\s.\+$' contains=TodoDue,TodoDate,TodoProject,TodoContext syntax match TodoPriorityJ '^([jJ])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityK '^([kK])\s.\+$' contains=TodoDue,TodoDate,TodoProject,TodoContext syntax match TodoPriorityK '^([kK])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityL '^([lL])\s.\+$' contains=TodoDue,TodoDate,TodoProject,TodoContext syntax match TodoPriorityL '^([lL])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityM '^([mM])\s.\+$' contains=TodoDue,TodoDate,TodoProject,TodoContext syntax match TodoPriorityM '^([mM])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityN '^([nN])\s.\+$' contains=TodoDue,TodoDate,TodoProject,TodoContext syntax match TodoPriorityN '^([nN])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityO '^([oO])\s.\+$' contains=TodoDue,TodoDate,TodoProject,TodoContext syntax match TodoPriorityO '^([oO])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityP '^([pP])\s.\+$' contains=TodoDue,TodoDate,TodoProject,TodoContext syntax match TodoPriorityP '^([pP])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityQ '^([qQ])\s.\+$' contains=TodoDue,TodoDate,TodoProject,TodoContext syntax match TodoPriorityQ '^([qQ])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityR '^([rR])\s.\+$' contains=TodoDue,TodoDate,TodoProject,TodoContext syntax match TodoPriorityR '^([rR])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityS '^([sS])\s.\+$' contains=TodoDue,TodoDate,TodoProject,TodoContext syntax match TodoPriorityS '^([sS])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityT '^([tT])\s.\+$' contains=TodoDue,TodoDate,TodoProject,TodoContext syntax match TodoPriorityT '^([tT])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityU '^([uU])\s.\+$' contains=TodoDue,TodoDate,TodoProject,TodoContext syntax match TodoPriorityU '^([uU])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityV '^([vV])\s.\+$' contains=TodoDue,TodoDate,TodoProject,TodoContext syntax match TodoPriorityV '^([vV])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityW '^([wW])\s.\+$' contains=TodoDue,TodoDate,TodoProject,TodoContext syntax match TodoPriorityW '^([wW])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityX '^([xX])\s.\+$' contains=TodoDue,TodoDate,TodoProject,TodoContext syntax match TodoPriorityX '^([xX])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityY '^([yY])\s.\+$' contains=TodoDue,TodoDate,TodoProject,TodoContext syntax match TodoPriorityY '^([yY])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
syntax match TodoPriorityZ '^([zZ])\s.\+$' contains=TodoDue,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 TodoDue 'due:' 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 TodoDue Special 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