From 73ba0effca6ade3339174d926047cccdd6e0b856 Mon Sep 17 00:00:00 2001 From: David Beniamine Date: Sun, 5 Jul 2015 15:00:07 +0200 Subject: [PATCH] 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 --- README.markdown | 50 ++++++++++++++++++++++++++-------- doc/todo.txt | 7 +++++ ftdetect/todo.vim | 4 +-- ftplugin/todo.vim | 18 +++++++----- ftplugin/todo_sort.vim | 2 +- syntax/todo.vim | 62 +++++++++++++++++++++--------------------- 6 files changed, 91 insertions(+), 52 deletions(-) diff --git a/README.markdown b/README.markdown index e07bac1..d543627 100644 --- a/README.markdown +++ b/README.markdown @@ -2,9 +2,12 @@ ## What is this plugin ? -This plugin is a fork of freitass todo.txt (see section 1.3) vim plugin adding -a nice two level sorting function designed for todo.txt files and a complete -function for context and projects (see section 1.4). +This plugin is a fork of [freitass +todo.txt](https://github.com/freitass/todo.txt-vim). It add severals functionalities including a [hierarchical sort](#sort), a +[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 @@ -14,13 +17,16 @@ function for context and projects (see section 1.4). cd todo.txt-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 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 you will be able to get the commands help with: :h todo.txt - +Then from vim: `:Helptags` to update the doc ## Features included in Freitass version @@ -32,8 +38,6 @@ This plugin gives syntax highlighting to [todo.txt](http://todotxt.com/) files. `s@` : Sort the file on @Contexts -`-sd` : Sort the file by due-date - `j` : Lower the priority of the current line `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` : (Insert mode) Insert the current date -`due:` : (Insert mode) Insert 'due:' followed by the current date - `x` : Toggle mark task as done (inserts current date as completion date) `X` : Mark all tasks as completed @@ -58,6 +60,8 @@ This plugin gives syntax highlighting to [todo.txt](http://todotxt.com/) files. ## New features +### Sort + This fork provides a hierarchical sorting function designed to do by project 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_second_level_sort_mode="i" -Also `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 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. TodoCompelte does the same thing for context except that it gives in the 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: + +`-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 + +`x` is a toggle which allow you to unmark a task as done. + +Syntax highlighting for couples key:value diff --git a/doc/todo.txt b/doc/todo.txt index 19e88c9..15e036b 100644 --- a/doc/todo.txt +++ b/doc/todo.txt @@ -19,6 +19,9 @@ COMMANDS *todo-commands* `spc` : Sort the file by project, context then by priority +`-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. + `j` : Lower the priority of the current line `k` : Increase the priority of the current line @@ -33,6 +36,10 @@ COMMANDS *todo-commands* `date` : (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 + `x` : Toggle mark task as done (inserts or remove current date as completion date) diff --git a/ftdetect/todo.vim b/ftdetect/todo.vim index 6fe1e06..f3fdb87 100644 --- a/ftdetect/todo.vim +++ b/ftdetect/todo.vim @@ -1,9 +1,9 @@ " File: todo.txt.vim " Description: Todo.txt filetype detection -" Author: Leandro Freitas +" Author: David Beniamine , Leandro Freitas " License: Vim license " 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 [Dd]one.txt set filetype=todo diff --git a/ftplugin/todo.vim b/ftplugin/todo.vim index 3cc51d8..ccbd368 100644 --- a/ftplugin/todo.vim +++ b/ftplugin/todo.vim @@ -1,9 +1,9 @@ " File: todo.txt.vim " Description: Todo.txt filetype detection -" Author: Leandro Freitas , David Beniamine +" Author: David Beniamine , Leandro Freitas " License: Vim license " Website: http://github.com/dbeniamine/todo.txt-vim -" Version: 0.6 +" Version: 0.7 " Save context {{{1 let s:save_cpo = &cpo @@ -85,12 +85,12 @@ function! TodoTxtSort() endfunction function! TodoTxtSortDue() - silent! %s/\(due:\s*\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 n /due:/ + sort n /[dD][uU][eE]:/ " Count the number of lines silent normal gg - execute "/due:" + execute "/[dD][uU][eE]:" let l:first=getpos(".")[1] silent normal N let l:last=getpos(".")[1] @@ -100,7 +100,7 @@ function! TodoTxtSortDue() execute ':d'.l:diff silent normal gg silent normal P - silent! %s/\(due:\s*\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) endfunction @@ -202,7 +202,11 @@ if !hasmapto("date",'i') endif if !hasmapto("due:",'i') - inoremap