117 Commits
v0.6 ... v0.8.1

Author SHA1 Message Date
David Beniamine
35810c388d Micro release 2017-09-11 13:34:49 +02:00
fretep
311761e327 Added TodoDueToday syntax highlight 2017-09-11 13:32:07 +02:00
David Beniamine
71505569c0 Vestion 0.8
Fix and close #14 and #15
Merge PR#13 and PR#16
2017-09-10 12:13:26 +02:00
David Beniamine
6d1d2d035a Do not consider done tasks when sorting by due date 2017-09-10 12:13:25 +02:00
David Beniamine
491c3c7fba Remove python dependency 2017-09-10 12:13:25 +02:00
fretep
70b05c2c76 Modified SortDue() to fix error if every line of the todo.txt had a
due:date specified, also allow setting a global variable to specify
the line the cursor should be place on after the sort
2017-09-10 12:13:25 +02:00
fretep
a778ef5590 Fix case sensitivity with "due:" in overdue date highlighting 2017-09-09 20:35:44 +10:00
fretep
03fe8bb167 Added native vim function to highlight overdue dates 2017-09-09 13:22:07 +10:00
David Beniamine
aa618973e2 Do not highlight overdue when marked done 2017-09-05 10:48:06 +02:00
David Beniamine
7b9c9815a4 Integrating sietse's work, version 0.7.6 2017-08-15 12:22:21 +02:00
Sietse Brouwer
57d45200c8 Enable vim-repeat for Done and Cancel 2017-08-08 11:09:22 +02:00
Rene Vergara
484c12771e Improve todo#PrependDate to follow format
Add logic to place the completion date after the priority, if it exists,
when completing a task.
2017-04-05 11:15:59 -05:00
David Beniamine
f77215ca80 Fix issue #11
Complete function assumed that a line started with x <date> or a
priority which is not necessarily true, thus some lines where ignored
from completion.
2017-03-30 18:57:18 +02:00
David Beniamine
849a7d5f61 Better way to put done at the end
+ Limit side effects
+ Sort done entries at the end
+ Work fine also without done entries
2016-11-25 11:26:44 +01:00
David Beniamine
0e2b110903 Merge remote-tracking branch 'dkarwowski/master' 2016-11-25 10:33:30 +01:00
David Beniamine
aad48b0231 Merge pull request #10 from victal/master
Fix overduedate regex breaking in November
2016-11-04 14:02:50 +01:00
Guilherme Victal
81e64682d0 Fix overduedate regex breaking in November 2016-11-04 09:46:42 -02:00
David Karwowski
303ab65237 priorities at top, x at bottom 2016-09-28 12:31:37 -04:00
David Beniamine
c2eb67f1a6 Version 0.7.5
No major changes, yet the merge with Fievel's work impacts considerably
the git tree thus a minor version update.
2016-09-05 15:46:52 +02:00
David Beniamine
85c215b4cc Use python3 if available
This commit incorporates [fievel's work](0863e1434e) to use python3 if possible.

I have not personally test vim+python3 but overdue dates still works with
python2.
2016-09-05 15:36:31 +02:00
David Beniamine
3e3251f8b5 Fievel work for python3 support 2016-09-05 15:26:03 +02:00
Florent Fievez
0863e1434e Vim distributed on recent linux distribution is now linked with
python3. Ensure compatibility with it.
2016-08-09 14:57:43 +02:00
David Beniamine
ca8ae307d3 removed error message if no python support 2016-05-20 19:46:48 +02:00
David Beniamine
95d97151c5 Remove unused files from freitass 2016-05-14 12:22:11 +02:00
David Beniamine
1cdb39032f Doc updated 2016-05-14 12:15:22 +02:00
David Beniamine
f3c5e7b892 Included Guilherme Victal works on overduedate
See https://github.com/freitass/todo.txt-vim/pull/45
2016-05-14 12:03:55 +02:00
Leandro Freitas
1e3a5e58ae Merge pull request #47 from colinsullivan/complete_all_grey
When tasks are completed, make the entire line grey.
2016-03-09 10:22:42 -03:00
Colin Sullivan
89570cbaef When tasks are completed, make the entire line grey. 2016-03-08 09:37:44 -08:00
David Beniamine
a21fd1198c Fix missing items in completion
FIX: This commit fix dbeniamine/todo.txt-vim#7 some the last completion item
was not added to the completion list
CHG: This commit also provide a small refactor of todo#Complete
2016-02-09 22:31:00 +01:00
David Beniamine
7515fde8ae Fix bad todo#Complete name
see issue#7
2016-02-09 20:53:58 +01:00
Leandro Freitas
4548961329 Merge pull request #46 from rleon/fix-trailing-space
Fix wrong prefix for completed tasks
2016-01-28 14:33:29 -02:00
Leon Romanovsky
8dd24d0b68 Fix wrong prefix for completed tasks
The commit a612ebe ('Remove trailing whitespaces') removed the
whitespace which was after 'x' markup. It caused to mark the
completed task without space and didn't allow to remove it
automatically.

Before this change:
xCOMPLETION_DATE ....
After this change:
x COMPLETION_DATE ...

Fixes: a612ebe ('Remove trailing whitespaces')
Signed-off-by: Leon Romanovsky <leon@leon.nu>
2016-01-28 16:17:37 +02:00
Leandro Freitas
e2a02d4f30 Fix link to issue 2016-01-27 14:25:17 -02:00
Leandro Freitas
595fc0b49e Reinserted some of the trailing spaces
They were important for markdown formatting after all.
2016-01-27 14:24:22 -02:00
Leandro Freitas
a612ebeaf1 Remove trailing whitespaces 2016-01-27 14:09:17 -02:00
Leandro Freitas
17a2345675 Ignore .pyc files 2016-01-27 14:09:00 -02:00
Leandro Freitas
e13eb4bb9c Merge pull request #45 from victal/master
Syntax Highlight for overdue dates
2016-01-27 14:01:46 -02:00
Guilherme Victal
d769f12710 Embed dateregex instead of using a submodule 2016-01-27 11:01:57 -02:00
Guilherme Victal
2535cf2ece Remove dateregex submodule 2016-01-27 10:53:13 -02:00
Guilherme Victal
eb7f7cb8f4 Add plugin manager notice 2016-01-26 21:02:22 -02:00
Guilherme Victal
87a6c371dd Add Overdue Date group to (Z) tasks syntax match 2016-01-26 20:56:48 -02:00
Guilherme Victal
29a6ea4b1d Add description and license info 2016-01-26 10:29:37 -02:00
Guilherme Victal
03501dfe42 Remove test on syntax file 2016-01-26 09:32:10 -02:00
victal
fc0b4c3272 Update README with +python warning 2016-01-25 10:02:02 -02:00
Guilherme Victal
b87c7dd98d Correct .gitmodules file 2016-01-24 17:23:50 -02:00
Guilherme Victal
7232106f45 Move python scripts to syntax/ 2016-01-24 17:22:24 -02:00
Guilherme Victal
6e1bcc0e1a Overdue date syntax highlight 2016-01-24 16:57:01 -02:00
Guilherme Victal
03f5575363 Add syntax highlight for overdue dates 2016-01-22 22:09:20 -02:00
David Beniamine
2e2d39daee Merge branch 'patch-1' of https://github.com/ultrablue/todo.txt-vim 2015-12-18 10:31:42 +01:00
David Beniamine
a03d01e58e Get linescount in a more conventional way
This should solve issue #5 see
https://github.com/dbeniamine/todo.txt-vim/issues/5
2015-12-18 10:17:26 +01:00
David Beniamine
81c2772905 Add debug info in hierarchical sort
ADD: Debug info needed for solving issue #5
FIX: Incomplete group detection in hierarchical sort (should not impact
    issue #5)
2015-12-17 23:23:10 +01:00
David Beniamine
b6d5dc6bb9 Fix issue #6 : typo in the documentation
See https://github.com/dbeniamine/todo.txt-vim/issues/6
2015-12-17 10:56:11 +01:00
David Beniamine
f9a007ac58 Merge branch 'citec-fix_getcurpos_missing' 2015-12-08 10:52:05 +01:00
David Beniamine
45bfb325ae FIX getcurpos incompatibility with old versions
It seems that getcurpos() (used on PrioritizeAdd) appeared on vim 7.4.313
therefore using it was causing troubles to some users ...
2015-12-08 10:51:21 +01:00
David Beniamine
081d9d2e3a Merge branch 'fix_getcurpos_missing' of https://github.com/citec/todo.txt-vim into citec-fix_getcurpos_missing 2015-12-08 10:41:53 +01:00
Greg
4d819f888b Update README.markdown
It looks like there's a typo on line 136; the function appears to be todo#Complete, not todo#complete.
2015-12-02 16:49:23 -07:00
Leandro Freitas
b3d9e18b08 Merge pull request #43 from JonathanReeve/due-date
add ability to sort on due dates
2015-10-25 17:35:39 -02:00
Jonathan Reeve
a98711da91 add documentation for new feature 2015-10-25 14:54:25 -04:00
Jonathan Reeve
0a917143c5 sort by due date 2015-10-25 14:49:23 -04:00
David Beniamine
41a75a8f50 FIX issue #2
FIX: hasmapto was use wrongly, there is now a setting to forbid todo-txt.vim to set
mappings.
FIX: There was a bug and MarkAllAsDone
2015-10-25 01:57:29 -02:00
Jaime Alberto Sanchez Hidalgo
cc281c47eb FIX getcurpos invalid expression 2015-10-20 08:43:13 -02:00
David Beniamine
f3a3bdbefb link fix 2015-09-22 17:37:27 +02:00
David Beniamine
3089527c71 Documentation re written
Cleaner documentation
2015-09-22 16:59:36 +02:00
David Beniamine
7fdf0427a8 use <localleader>C for cancel as c is used for priority 2015-09-22 15:46:09 +02:00
David Beniamine
644b6d6628 Cancel tasks with <localleader>c 2015-09-16 17:02:42 +02:00
David Beniamine
d3b011b718 Vizardry install 2015-09-16 16:22:37 +02:00
David Beniamine
f9715af4a4 move hierarchical sort to auto start
Note: because of this, TodoComplete is now known as todo#Complete, you might
need to update your vimrc.
2015-08-22 18:39:59 +02:00
Leandro Freitas
c13a277e2a Merge branch 'master' of https://github.com/freitass/todo.txt-vim 2015-08-03 14:22:57 -03:00
Leandro Freitas
421916b25d Fixes #42 2015-08-03 14:22:30 -03:00
Leandro Freitas
8da977113b Fixes 42 2015-08-03 14:21:49 -03:00
David Beniamine
ab4ecf5220 FIX: sort done.txt 2015-07-08 11:04:55 +02:00
David Beniamine
dc4bb8e856 Fix: vimscript is not bash 2015-07-08 11:00:54 +02:00
David Beniamine
6a103f1429 v0.7.2 2015-07-08 09:53:02 +02:00
David Beniamine
9f87eec204 More flexible file naming (Request #2)
CHG: More flexible file naming files matching one of the following are todo
files:
    YYYY-MM-[Tt]odo.txt
    YYYY-MM-DD[Tt]odo.txt
    [Tt]odo-YYYY-MM.txt
    [Tt]odo-YYYY-MM-DD.txt
    [Tt]odo.txt
    [Tt]oday.txt
    YYYY-MM-[Dd]one.txt
    YYYY-MM-DD[Dd]one.txt
    [Dd]one-YYYY-MM.txt
    [Dd]one-YYYY-MM-DD.txt
    [Dd]one.txt
    [Dd]one-[Tt]oday.txt
 Moreover, remove complete tasks (<LocalLeader>D) moves the task to the
 done.txt file corresponding to the current todo.txt, aka if you are editing
 2015-07-07-todo.txt, the done file while be 2015-07-07-done.txt.
 This behaviour can be cancelled by fixing the done filename using
 g:TodoTxtForceDoneName
FIX: Bug while completing empty file
2015-07-08 09:48:12 +02:00
David Beniamine
53ad73ebda FIX hierarchical sort stability bug 2015-07-06 14:55:02 +02:00
David Beniamine
68a32427ab FIX: Todo Key detection
Fix bad detection of key: a couple key:value must not contain spaces foo: bar
was detected as a couple key:value while it shouldn't ...
2015-07-06 10:02:06 +02:00
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
Leandro Freitas
2a04312e8d Merge pull request #40 from siddharthist/master
Clarified which files are considered todo.txt
2015-05-21 14:01:41 -03:00
siddharthist
85b2e86b73 Clarified which files are considered todo.txt 2015-05-21 10:39:33 -05:00
Leandro Freitas
1e465dd931 Fixes #39: Completion date replaces creation date. 2015-05-20 17:13:27 -03:00
Leandro Freitas
79e4d352a2 Renamed function to reflect its implementation 2015-05-20 17:12:46 -03:00
Leandro Freitas
ddbcdd823f fixup! Fixes #37. Inserting date on new tasks 2015-05-18 19:03:57 -03:00
Leandro Freitas
77cfafb9f0 Fixes #37. Inserting date on new tasks 2015-05-14 14:55:31 -03:00
Leandro Freitas
fbc45c5c8c Fixed README formatting 2015-05-06 16:59:44 -03:00
Leandro Freitas
6c5a37e6c6 Improved README 2015-05-06 16:50:08 -03:00
Leandro Freitas
25a63d5ecd Improved documentation 2015-05-06 16:39:14 -03:00
Leandro Freitas
04210abd70 Fixes #37. Replacing existing priority 2015-05-06 10:00:35 -03:00
Leandro Freitas
649f962211 Fixes #37. Replacing existing date 2015-05-06 09:47:04 -03:00
Leandro Freitas
b1ed8608d1 Fixes 'date' test 2015-05-05 09:52:28 -03:00
Leandro Freitas
f30ac979a1 Fixes 'mark as done' test 2015-05-05 09:50:50 -03:00
Leandro Freitas
40faa56012 Fixes #9 2015-05-05 09:37:02 -03:00
Leandro Freitas
51c821b5da Inserted date do note. 2015-04-22 10:31:31 -03:00
Leandro Freitas
6c073cdb42 Added note on mappings change. 2015-04-22 09:11:26 -03:00
Leandro Freitas
e508140f90 When sorting on date, tasks with no date go to the end. 2015-04-17 11:31:40 -03:00
Leandro Freitas
d0080e66f9 Testing functions only (not mappings). 2015-04-17 09:04:30 -03:00
Leandro Freitas
e071156b8d Fixes #16 2015-04-17 08:38:08 -03:00
Leandro Freitas
1f8b706d8e Fixes #28 2015-04-16 23:10:49 -03:00
Leandro Freitas
0e3c5cb2b6 Major refactoring 2015-04-16 22:56:09 -03:00
Leandro Freitas
32188000f9 Added documentation for sorting on dates. 2015-04-16 21:31:41 -03:00
Leandro Freitas
1cc11c56ad Sorting tasks by date. 2015-04-16 20:47:53 -03:00
Leandro Freitas
639fcd85a2 Implemented sorting on visual selection. 2015-04-16 20:25:58 -03:00
Leandro Freitas
b8a5bd64ca Testing date functions 2015-04-12 11:42:29 -03:00
Leandro Freitas
95ed508741 Added test cases for sorting and marking as done. 2015-04-11 11:28:33 -03:00
Leandro Freitas
05b5be07d2 Hopefully fixes #30 2015-04-11 11:25:28 -03:00
Leandro Freitas
08fcb4ccdb Merge branch 'master' of https://github.com/freitass/todo.txt-vim 2015-04-07 22:29:32 -03:00
Leandro Freitas
e817f5eca8 Merge pull request #32 from naught101/prefixed_files
Allow prefixed files like blah.todo.txt. Fixes #29
2015-04-07 22:28:37 -03:00
Leandro Freitas
2d83ed8dc2 Fixes #30 2015-04-07 21:49:51 -03:00
naught101
52e1527e9b allow prefixed files like blah.todo.txt 2015-04-07 22:55:42 +10:00
9 changed files with 1249 additions and 527 deletions

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
*.swp *.swp
doc/tags doc/tags
*.pyc

View File

@@ -1,57 +1,179 @@
# Readme # Todo.txt-vim
## What is this plugin ? ##### # #
# #### ##### #### ##### # # ##### # # # # #
# # # # # # # # # # # # # # ## ##
# # # # # # # # ## # ### # # # # ## #
# # # # # # # # ## # # # # # #
# # # # # # # ## # # # # # # # # #
# #### ##### #### ## # # # # # # # #
This plugin is a fork of freitass todo.txt (see section 1.3) vim plugin adding Efficient Todo.txt management in vim
a nice two level sorting function designed for todo.txt files and a complete
function for context and projects (see section 1.4).
## Install ## Table of Contents
### Quick install 1. [Release notes](#release-notes)
2. [Introduction](#introduction)
1. [Todo.txt rules](#todo.txt-rules)
2. [Why this Fork ?](#Why-this-fork)
3. [Installation](#installation)
3. [TodoTxt Files](#todotxt-files)
4. [Completion](#completion)
5. [Hierarchical Sort](#hierarchical-sort)
6. [Mappings](#mappings)
1. [Sort](#sort)
2. [Priorities](#priorities)
3. [Dates](#dates)
4. [Done](#done)
git clone https://github.com/dbeniamine/todo.txt-vim.git ## Release notes
cd todo.txt-vim
cp -r ./* ~/.vim
### Pathogen install + V0.8.1 Incorporates yet antoher Fretep work : highlithing for tasks due today.
+ v0.8 Incorporates Fretep's work on overdue dates (PR#13 and PR#16) witch
removes python dependency, allow to control the cursor position after a sort by
todo (see (sort)[#sort] and/or issue #15) and fixes bug when sorting a file
containing only lines with due:date (issue #14).
+ v0.7.6 Incorporates [Sietse's work](https://github.com/sietse/todo.txt-vim/commit/57d45200c8b033d31c9191ee0eb0711c801cdb1d) to make cancel and mark as done mapping repeatable using [vim-repeat](https://github.com/tpope/vim-repeat).
+ v0.7.5 Incorporates [Fievel's work](https://github.com/fievel/todo.txt-vim/commit/0863e1434e9a89ace06c4856b6cb32ba9906e3de) to make overduedates work on python3.
+ v0.7.4 includes the overduedate support from Guilherme Victal (see pull
[request #45 on freitass version](https://github.com/freitass/todo.txt-vim/pull/45)),
it highlight dates in overdue tasks as an Error. It depends on a
Python library, however, and as such will only be able to work if your version
of Vim was compiled with the `+python` option (as most common versions do).
If your Vim installation does **not** have Python support, this plugin **will work just fine** but this feature will be disabled.
+ Since v0.7.3, `TodoComplete` is replaced by `todo#Complete`, you might need to update your vimrc (see [completion](#completion)).
## Introduction
Todo.txt-vim is a plugin to manage todo.txt files it was initially designed by
[Freitass](https://github.com/freitass/todo.txt-vim) then forked and improved
by David Beniamine.
### Todo.txt rules
Todo.txt is a standard human readable todo notes file defined [here](http://todotxt.com):
"The todo.txt format is a simple set of
[rules](https://github.com/ginatrapani/todo.txt-cli/wiki/The-Todo.txt-Format)
that make todo.txt both human and machine-readable. The format supports
priorities, creation and completion dates, projects and contexts. That's
all you need to be productive. See an example Todo.txt file":
(A) Call Mom @Phone +Family
(A) Schedule annual checkup +Health
(B) Outline chapter 5 +FamilyNovel @Computer
(C) Add cover sheets @ComputerOffice +FamilyTPSReports
Plan backyard herb garden @ComputerHome
Pick up milk @ComputerGroceryStore
Research self-publishing services +FamilyNovel @ComputerComputer
x Download Todo.txt mobile app @ComputerPhone
### Why this fork ?
This plugin is a fork of [freitass
todo.txt-vim](https://github.com/freitass/todo.txt-vim). It add severals cool
functionalities including:
+ [Hierarchical sort](##hierarchical-sort)
+ [A completion function](#completion)
+ [A proper handling of due dates](#dates)
+ [A Flexible file naming](#todotxt-files).
+ Syntax Highlight for couples key:value.
+ `<LocalLeader>x` is a toggle which allow you to unmark a task as done.
+ `<LocalLeader>C` Toggle Mark a task cancelled
+ If the current buffer is a done.txt file, the basic sort sorts on
completion date.
+ ...
### Installation
#### Vizardry
If you have [Vizardry](https://github.com/dbeniamine/vizardry) installed,
you can run from vim:
:Invoke -u dbeniamine todo.txt-vim
#### 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
## Features included in Freitass version Then from vim: `:Helptags` to update the doc
This plugin gives syntax highlighting to [todo.txt](http://todotxt.com/) files. It also defines a few mappings, to help with editing these files: #### Quick install
`<LocalLeader>s` : Sort the file git clone https://github.com/dbeniamine/todo.txt-vim.git
cd todo.txt-vim
cp -r ./* ~/.vim
`<LocalLeader>s+` : Sort the file on +Projects
`<LocalLeader>s@` : Sort the file on @Contexts 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`
`<LocalLeader>j` : Lower the priority of the current line ## TodoTxt Files
`<LocalLeader>k` : Increase the priority of the current line This plugin provides a Flexible file naming for todo.txt, all the following
names are recognized as todo:
`<LocalLeader>a` : Add the priority (A) to the current line YYYY-MM-[Tt]odo.txt
YYYY-MM-DD[Tt]odo.txt
[Tt]odo-YYYY-MM.txt
[Tt]odo-YYYY-MM-DD.txt
[Tt]odo.txt
[Tt]oday.txt
`<LocalLeader>b` : Add the priority (B) to the current line And obviously the same are recognize as done:
`<LocalLeader>c` : Add the priority (C) to the current line YYYY-MM-[Dd]one.txt
YYYY-MM-DD[Dd]one.txt
[Dd]one-YYYY-MM.txt
[Dd]one-YYYY-MM-DD.txt
[Dd]one.txt
[Dd]one-[Tt]oday.txt
`<LocalLeader>d` : Insert the current date Moreover, `<LocalLeader>D` moves the task under the cursor to the done.txt
file corresponding to the current todo.txt, aka if you are editing
2015-07-07-todo.txt, the done file while be 2015-07-07-done.txt. If you don't
like this behavior, you can set the default done.txt name:
`date<tab>` : (Insert mode) Insert the current date let g:TodoTxtForceDoneName='done.txt'
`<LocalLeader>x` : Toggle mark task as done (inserts current date as completion date) ## Completion
`<LocalLeader>X` : Mark all tasks as completed This plugin provides a nice complete function for project and context, to use
it add the following lines to your vimrc:
`<leader>-D` : Move completed tasks to done.txt " Use todo#Complete as the omni complete function for todo files
au filetype todo setlocal omnifunc=todo#Complete
If you want the help installed, run ":helptags ~/.vim/doc" inside vim after having copied the files. You can also start automatically the completion when entering '+' or '@' by
Then you will be able to get the commands help with: :h todo.txt adding the next lines to your vimrc:
## New features " Auto complete projects
au filetype todo imap <buffer> + +<C-X><C-O>
" Auto complete contexts
au filetype todo imap <buffer> @ @<C-X><C-O>
The `todo#Complete` function is designed to complete projects (starting by `+`)
and context (starting by `@`). If you use it on a regular word, it will do a
normal keyword completion (on all buffers).
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 in which they appears in the preview window. It does the same thing
for context except that it gives in the preview the list of projects existing
in each existing contexts.
## Hierarchical 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.
@@ -61,34 +183,79 @@ and/or by context sorts and a priority sort.
`<LocalLeader>sp` : Sort the file by project then by priority `<LocalLeader>sp` : Sort the file by project then by priority
`<LocalLeader>spc` : Sort the file by project, context then by priority `<LocalLeader>spc` : Sort the file by project, context then by priority
The user can give argument for the two call to vim sort function by changing The user can give argument for the two calls to vim sort function by changing
the following variables in its vimrc: the following variables:
see :help sort
let g:Todo_txt_first_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. g:Todo_txt_first_level_sort_mode
g:Todo_txt_second_level_sort_mode
We also provide a nice complete function for project and context, to use it Defaults values are:
add the following lines to your vimrc:
" Use TodoComplete as the omni complete function for todo files
au filetype todo setlocal omnifunc=TodoComplete
You can also start automatically the completion when entering '+' or '@' by g:Todo_txt_first_level_sort_mode="i"
adding the next lines to your vimrc: g:Todo_txt_second_level_sort_mode="i"
" Auto complete projects
au filetype todo imap + +<C-X><C-O>
" Auto complete contexts For more information on the available flags see `help :sort`
au filetype todo imap @ @<C-X><C-O>
The TodoComplete function is designed to complete projects (starting by '+') ## Mappings
and context (starting by '@'). If you use it on a regular word, it will do a
normal buffer completion. By default todo-txt.vim set all the mappings secribed in this section. To
If you try to complete a project, it will propose all projects in all open prevent this behavior, add the following line to your vimrc
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. let g:Todo_txt_do_not_map=1
TodoCompelte does the same thing for context except that it gives in the
preview the list of projects existing in each existing contexts.
`<LocalLeader>` is \ by default, so ̀`<LocaLeader>-s` means you type \s
### Sort
+ `<LocalLeader>s` : Sort the file by priority
+ `<LocalLeader>s+` : Sort the file on `+Projects`
+ `<LocalLeader>s@` : Sort the file on `@Contexts`
+ `<LocalLeader>sd` : Sort the file on due dates
+ `<LocalLeader>sc` : Sort the file by context then by priority
+ `<LocalLeader>scp` : Sort the file by context, project then by priority
+ `<LocalLeader>sp` : Sort the file by project 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.
When you sort by due dates, at the end of the sort, your cursor will be placed
at the top of the file. This behavior can be set with the following global
variable :
let g:TodoTxtSortDueDateCursorPos = "top"
Possible values are :
+ `top` (default): The first line of the buffer, i.e. your most outstanding task
+ `lastdue`: The last task with a due:date set
+ `notoverdue`: The first task that is not overdue (requires #13)
+ `bottom`: The last line of the buffer
### Priorities
+ `<LocalLeader>j` : Lower the priority of the current line
+ `<LocalLeader>k` : Increase the priority of the current line
+ `<LocalLeader>a` : Add the priority (A) to the current line
+ `<LocalLeader>b` : Add the priority (B) to the current line
+ `<LocalLeader>c` : Add the priority (C) to the current line
### Dates
+ `<LocalLeader>d` : 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
### Done
+ `<LocalLeader>x` : Toggle mark task as done (inserts or remove current
+ date as completion date)
+ `<LocalLeader>C` : Toggle mark task cancelled
+ `<LocalLeader>X` : Mark all tasks as completed
+ `<LocalLeader>D` : Move completed tasks to done file, see [TodoTxt
Files](#todotxt-files)

423
autoload/todo.vim Normal file
View File

@@ -0,0 +1,423 @@
" File: autoload/todo.vim
" Description: Todo.txt sorting plugin
" Author: David Beniamine <david@beniamine.net>
" Licence: Vim licence
" Website: http://github.com/dbeniamine/todo.txt.vim
" vim: ts=4 sw=4 :help tw=78 cc=80
" These two variables are parameters for the successive calls the vim sort
" '' means no flags
" '! i' means reverse and ignore case
" for more information on flags, see :help sort
if (! exists("g:Todo_txt_first_level_sort_mode"))
let g:Todo_txt_first_level_sort_mode='i'
endif
if (! exists("g:Todo_txt_second_level_sort_mode"))
let g:Todo_txt_second_level_sort_mode='i'
endif
if (! exists("g:Todo_txt_third_level_sort_mode"))
let g:Todo_txt_third_level_sort_mode='i'
endif
" Functions {{{1
function! todo#GetCurpos()
if exists("*getcurpos")
return getcurpos()
endif
return getpos('.')
endfunction
" Increment and Decrement The Priority
:set nf=octal,hex,alpha
function! todo#PrioritizeIncrease()
normal! 0f)h
endfunction
function! todo#PrioritizeDecrease()
normal! 0f)h
endfunction
function! todo#PrioritizeAdd (priority)
let oldpos=todo#GetCurpos()
let line=getline('.')
if line !~ '^([A-F])'
:call todo#PrioritizeAddAction(a:priority)
let oldpos[2]+=4
else
exec ':s/^([A-F])/('.a:priority.')/'
endif
call setpos('.',oldpos)
endfunction
function! todo#PrioritizeAddAction (priority)
execute "normal! mq0i(".a:priority.") \<esc>`q"
endfunction
function! todo#RemovePriority()
:s/^(\w)\s\+//ge
endfunction
function! todo#PrependDate()
if (getline(".") =~ '\v^\(')
execute "normal! 0f)a\<space>\<esc>l\"=strftime(\"%Y-%m-%d\")\<esc>P"
else
normal! 0"=strftime("%Y-%m-%d ")
P
endif
endfunction
function! todo#ToggleMarkAsDone(status)
if (getline(".") =~ 'x\s*\d\{4\}')
:call todo#UnMarkAsDone(a:status)
else
:call todo#MarkAsDone(a:status)
endif
endfunction
function! todo#UnMarkAsDone(status)
if a:status==''
let pat=''
else
let pat=' '.a:status
endif
exec ':s/\s*x\s*\d\{4}-\d\{1,2}-\d\{1,2}'.pat.'\s*//g'
endfunction
function! todo#MarkAsDone(status)
if a:status!=''
exec 'normal! I'.a:status.' '
endif
call todo#PrependDate()
normal! Ix
endfunction
function! todo#MarkAllAsDone()
:g!/^x /:call todo#MarkAsDone('')
endfunction
function! s:AppendToFile(file, lines)
let l:lines = []
" Place existing tasks in done.txt at the beggining of the list.
if filereadable(a:file)
call extend(l:lines, readfile(a:file))
endif
" Append new completed tasks to the list.
call extend(l:lines, a:lines)
" Write to file.
call writefile(l:lines, a:file)
endfunction
function! todo#RemoveCompleted()
" Check if we can write to done.txt before proceeding.
let l:target_dir = expand('%:p:h')
if exists("g:TodoTxtForceDoneName")
let l:done=g:TodoTxtForceDoneName
else
let l:done=substitute(substitute(expand('%:t'),'todo','done',''),'Todo','Done','')
endif
let l:done_file = l:target_dir.'/'.l:done
echo "Writing to ".l:done_file
if !filewritable(l:done_file) && !filewritable(l:target_dir)
echoerr "Can't write to file '".l:done_file."'"
return
endif
let l:completed = []
:g/^x /call add(l:completed, getline(line(".")))|d
call s:AppendToFile(l:done_file, l:completed)
endfunction
function! todo#Sort()
" vim :sort is usually stable
" we sort first on contexts, then on projects and then on priority
if expand('%')=~'[Dd]one.*.txt'
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
let oldcursor=getpos(".")
silent normal gg
let l:first=search('^\s*x')
if l:first != 0
sort /^./r
" at this point done tasks are at the end
let l:first=search('^\s*x')
let l:last=search('^\s*x','b')
let l:diff=l:last-l:first+1
" Cut the done lines
execute ':'.l:first.'d a '.l:diff
endif
sort /@[a-zA-Z]*/ r
sort /+[a-zA-Z]*/ r
sort /\v([A-Z])/ r
if l:first != 0
silent normal G"ap
execute ':'.l:first.','.l:last.'sort /@[a-zA-Z]*/ r'
execute ':'.l:first.','.l:last.'sort /+[a-zA-Z]*/ r'
execute ':'.l:first.','.l:last.'sort /\v([A-Z])/ r'
endif
call cursor(oldcursor)
endif
endfunction
function! todo#SortDue()
" Check how many lines have a due:date on them
let l:tasksWithDueDate = 0
silent! %global/\v\c^[^x].*<due:\d{4}-\d{2}-\d{2}>/let l:tasksWithDueDate += 1
if l:tasksWithDueDate == 0
" No tasks with a due:date: No need to modify the buffer at all
" Also means we don't need to cater for no matches on searches below
return
endif
" FIXME: There is a small chance that due:\d{8} might legitimately exist in the buffer
" We modify due:yyyy-mm-dd to yyyymmdd which would then mean we would alter the buffer
" in an unexpected way, altering user data. Not sure how to deal with this at the moment.
" I'm going to throw an exception, and if this is a problem we can revisit.
silent %global/\v\c<due:\d{8}>/throw "Text matching 'due:\\d\\{8\\}' exists in the buffer, this function cannot sort your buffer"
" Turn the due:date from due:yyyy-mm-dd to due:yyyymmdd so we can do a numeric sort
silent! %substitute/\v<(due:\d{4})\-(\d{2})\-(\d{2})>/\1\2\3/ei
" Sort all the lines with due: by numeric yyyymmdd, they will end up in ascending order at the bottom of the buffer
sort in /^[^x].*\<due:/
" Determine the line number of the first task with a due:date
let l:firstLineWithDue = line("$") - l:tasksWithDueDate + 1
" Put the sorted lines at the beginning of the file
if l:firstLineWithDue > 1
" ...but only if the whole file didn't get sorted.
execute l:firstLineWithDue . ",$move 0"
endif
" Change the due:yyyymmdd back to due:yyyy-mm-dd.
silent! %substitute/\v<(due:\d{4})(\d{2})(\d{2})>/\1-\2-\3/ei
" Cursor is now on the last task with a due:date
" Let's check a global for a user preference on the cursor position.
if exists("g:TodoTxtSortDueDateCursorPos")
if g:TodoTxtSortDueDateCursorPos ==? "top"
normal gg
elseif g:TodoTxtSortDueDateCursorPos ==? "lastdue"
" Nothing to do
elseif g:TodoTxtSortDueDateCursorPos ==? "notoverdue"
" Let's try to put the cursor on the first non-overdue task
let l:overduePat = todo#GetDateRegexForPastDates()
execute ":silent! ?\\v<due:" . l:overduePat . ">?+1"
elseif g:TodoTxtSortDueDateCursorPos ==? "bottom"
silent normal G
endif
else
" Default: Top of the document
normal gg
endif
" TODO: add time sorting (YYYY-MM-DD HH:MM)
endfunction
" This is a Hierarchical sort designed for todo.txt todo lists, however it
" might be used for other files types
" At the first level, lines are sorted by the word right after the first
" occurence of a:symbol, there must be no space between the symbol and the
" word. At the second level, the same kind of sort is done based on
" a:symbolsub, is a:symbol==' ', the second sort doesn't occurs
" Therefore, according to todo.txt syntaxt, if
" a:symbol is a '+' it sort by the first project
" a:symbol is an '@' it sort by the first context
" The last level of sort is done directly on the line, so according to
" todo.txt syntax, it means by priority. This sort is done if and only if the
" las argument is not 0
function! todo#HierarchicalSort(symbol, symbolsub, dolastsort)
if v:statusmsg =~ '--No lines in buffer--'
"Empty buffer do nothing
return
endif
"if the sort modes doesn't start by '!' it must start with a space
let l:sortmode=Todo_txt_InsertSpaceIfNeeded(g:Todo_txt_first_level_sort_mode)
let l:sortmodesub=Todo_txt_InsertSpaceIfNeeded(g:Todo_txt_second_level_sort_mode)
let l:sortmodefinal=Todo_txt_InsertSpaceIfNeeded(g:Todo_txt_third_level_sort_mode)
" Count the number of lines
let l:position= todo#GetCurpos()
execute "silent normal G"
let l:linecount=getpos(".")[1]
if(exists("g:Todo_txt_debug"))
echo "Linescount: ".l:linecount
endif
execute "silent normal gg"
" Get all the groups names
let l:groups=GetGroups(a:symbol,1,l:linecount)
if(exists("g:Todo_txt_debug"))
echo "Groups: "
echo l:groups
echo 'execute sort'.l:sortmode.' /.\{-}\ze'.a:symbol.'/'
endif
" Sort by groups
execute 'sort'.l:sortmode.' /.\{-}\ze'.a:symbol.'/'
for l:g in l:groups
let l:pat=a:symbol.l:g.'.*$'
if(exists("g:Todo_txt_debug"))
echo l:pat
endif
normal gg
" Find the beginning of the group
let l:groupBegin=search(l:pat,'c')
" Find the end of the group
let l:groupEnd=search(l:pat,'b')
" I'm too lazy to sort groups of one line
if(l:groupEnd==l:groupBegin)
continue
endif
if a:dolastsort
if( a:symbolsub!='')
" Sort by subgroups
let l:subgroups=GetGroups(a:symbolsub,l:groupBegin,l:groupEnd)
" Go before the first line of the group
" Sort the group using the second symbol
for l:sg in l:subgroups
normal gg
let l:pat=a:symbol.l:g.'.*'.a:symbolsub.l:sg.'.*$\|'.a:symbolsub.l:sg.'.*'.a:symbol.l:g.'.*$'
" Find the beginning of the subgroup
let l:subgroupBegin=search(l:pat,'c')
" Find the end of the subgroup
let l:subgroupEnd=search(l:pat,'b')
" Sort by priority
execute l:subgroupBegin.','.l:subgroupEnd.'sort'.l:sortmodefinal
endfor
else
" Sort by priority
if(exists("g:Todo_txt_debug"))
echo 'execute '.l:groupBegin.','.l:groupEnd.'sort'.l:sortmodefinal
endif
execute l:groupBegin.','.l:groupEnd.'sort'.l:sortmodefinal
endif
endif
endfor
" Restore the cursor position
call setpos('.', position)
endfunction
" Returns the list of groups starting by a:symbol between lines a:begin and
" a:end
function! GetGroups(symbol,begin, end)
let l:curline=a:begin
let l:groups=[]
while l:curline <= a:end
let l:curproj=strpart(matchstr(getline(l:curline),a:symbol.'\S*'),1)
if l:curproj != "" && index(l:groups,l:curproj) == -1
let l:groups=add(l:groups , l:curproj)
endif
let l:curline += 1
endwhile
return l:groups
endfunction
" Insert a space if needed (the first char isn't '!' or ' ') in front of
" sort parameters
function! Todo_txt_InsertSpaceIfNeeded(str)
let l:c=strpart(a:str,1,1)
if( l:c != '!' && l:c !=' ')
return " ".a:str
endif
retur a:str
endfunction
" Completion {{{1
" Simple keyword completion on all buffers {{{2
function! TodoKeywordComplete(base)
" Search for matches
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
" Convert an item to the completion format and add it to the completion list
fun! TodoAddToCompletionList(list,item,opp)
" Create the definitive item
let resitem={}
let resitem.word=a:item.word
let resitem.info=a:opp=='+'?"Projects":"Contexts"
let resitem.info.=": ".join(a:item.related, ", ")
\."\nBuffers: ".join(a:item.buffers, ", ")
call add(a:list,resitem)
endfun
fun! TodoCopyTempItem(item)
let ret={}
let ret.word=a:item.word
let ret.related=[a:item.related]
let ret.buffers=[a:item.buffers]
return ret
endfun
" Intelligent completion for projects and Contexts {{{2
fun! todo#Complete(findstart, base)
if a:findstart
let line = getline('.')
let start = col('.') - 1
while start > 0 && line[start - 1] !~ '\s'
let start -= 1
endwhile
return start
else
if a:base !~ '^+' && a:base !~ '^@'
return TodoKeywordComplete(a:base)
endif
" Opposite sign
let opp=a: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',"")
let item.buffers=bufname(bufnr)
let item.related=substitute(line,'.*\s\('.opp.'\S\S*\).*','\1',"")
call add(res,item)
endif
endfor
endfor
call sort(res)
" Here all results are sorted in res, but we need to merge them
let ret=[]
if res != []
let curitem=TodoCopyTempItem(res[0])
for it in res
if curitem.word==it.word
" Merge results
if index(curitem.related,it.related) <0
call add(curitem.related,it.related)
endif
if index(curitem.buffers,it.buffers) <0
call add(curitem.buffers,it.buffers)
endif
else
" Add to list
call TodoAddToCompletionList(ret,curitem,opp)
" Init new item from it
let curitem=TodoCopyTempItem(it)
endif
endfor
" Don't forget to add the list item
call TodoAddToCompletionList(ret,curitem,opp)
endif
return ret
endif
endfun

123
autoload/todo/txt.vim Normal file
View File

@@ -0,0 +1,123 @@
" File: todo.txt.vim
" Description: Todo.txt filetype detection
" Author: Leandro Freitas <freitass@gmail.com>
" License: Vim license
" Website: http://github.com/freitass/todo.txt-vim
" Version: 0.4
" Export Context Dictionary for unit testing {{{1
function! s:get_SID()
return matchstr(expand('<sfile>'), '<SNR>\d\+_')
endfunction
let s:SID = s:get_SID()
delfunction s:get_SID
function! todo#txt#__context__()
return { 'sid': s:SID, 'scope': s: }
endfunction
" Functions {{{1
function! s:remove_priority()
:s/^(\w)\s\+//ge
endfunction
function! s:get_current_date()
return strftime('%Y-%m-%d')
endfunction
function! todo#txt#prepend_date()
execute 'normal! I' . s:get_current_date() . ' '
endfunction
function! todo#txt#replace_date()
let current_line = getline('.')
if (current_line =~ '^\(([a-zA-Z]) \)\?\d\{2,4\}-\d\{2\}-\d\{2\} ') &&
\ exists('g:todo_existing_date') && g:todo_existing_date == 'n'
return
endif
execute 's/^\(([a-zA-Z]) \)\?\(\d\{2,4\}-\d\{2\}-\d\{2\} \)\?/\1' . s:get_current_date() . ' /'
endfunction
function! todo#txt#mark_as_done()
call s:remove_priority()
call todo#txt#prepend_date()
normal! Ix
endfunction
function! todo#txt#mark_all_as_done()
:g!/^x /:call todo#txt#mark_as_done()
endfunction
function! s:append_to_file(file, lines)
let l:lines = []
" Place existing tasks in done.txt at the beggining of the list.
if filereadable(a:file)
call extend(l:lines, readfile(a:file))
endif
" Append new completed tasks to the list.
call extend(l:lines, a:lines)
" Write to file.
call writefile(l:lines, a:file)
endfunction
function! todo#txt#remove_completed()
" Check if we can write to done.txt before proceeding.
let l:target_dir = expand('%:p:h')
let l:todo_file = expand('%:p')
let l:done_file = substitute(substitute(l:todo_file, 'todo.txt$', 'done.txt', ''), 'Todo.txt$', 'Done.txt', '')
if !filewritable(l:done_file) && !filewritable(l:target_dir)
echoerr "Can't write to file 'done.txt'"
return
endif
let l:completed = []
:g/^x /call add(l:completed, getline(line(".")))|d
call s:append_to_file(l:done_file, l:completed)
endfunction
function! todo#txt#sort_by_context() range
execute a:firstline . "," . a:lastline . "sort /\\(^\\| \\)\\zs@[^[:blank:]]\\+/ r"
endfunction
function! todo#txt#sort_by_project() range
execute a:firstline . "," . a:lastline . "sort /\\(^\\| \\)\\zs+[^[:blank:]]\\+/ r"
endfunction
function! todo#txt#sort_by_date() range
let l:date_regex = "\\d\\{2,4\\}-\\d\\{2\\}-\\d\\{2\\}"
execute a:firstline . "," . a:lastline . "sort /" . l:date_regex . "/ r"
execute a:firstline . "," . a:lastline . "g!/" . l:date_regex . "/m" . a:lastline
endfunction
function! todo#txt#sort_by_due_date() range
let l:date_regex = "due:\\d\\{2,4\\}-\\d\\{2\\}-\\d\\{2\\}"
execute a:firstline . "," . a:lastline . "sort /" . l:date_regex . "/ r"
execute a:firstline . "," . a:lastline . "g!/" . l:date_regex . "/m" . a:lastline
endfunction
" Increment and Decrement The Priority
:set nf=octal,hex,alpha
function! todo#txt#prioritize_increase()
normal! 0f)h
endfunction
function! todo#txt#prioritize_decrease()
normal! 0f)h
endfunction
function! todo#txt#prioritize_add(priority)
" Need to figure out how to only do this if the first visible letter in a line is not (
:call todo#txt#prioritize_add_action(a:priority)
endfunction
function! todo#txt#prioritize_add_action(priority)
execute 's/^\(([a-zA-Z]) \)\?/(' . a:priority . ') /'
endfunction
" Modeline {{{1
" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1

View File

@@ -1,84 +1,287 @@
*todo.txt* *Todo.txt-vim*
============================================================================== ##### # #
COMMANDS *todo-commands* # #### ##### #### ##### # # ##### # # # # #
# # # # # # # # # # # # # # ## ##
# # # # # # # # ## # ### # # # # ## #
# # # # # # # # ## # # # # # #
# # # # # # # ## # # # # # # # # #
# #### ##### #### ## # # # # # # # #
`<LocalLeader>s` : Sort the file by priority Efficient Todo.txt management in vim
`<LocalLeader>s+` : Sort the file on +Projects
`<LocalLeader>s@` : Sort the file on @Contexts
`<LocalLeader>sc` : Sort the file by context then by priority
`<LocalLeader>scp` : Sort the file by context, project then by priority
`<LocalLeader>sp` : Sort the file by project then by priority
`<LocalLeader>spc` : Sort the file by project, context then by priority
`<LocalLeader>j` : Lower the priority of the current line
`<LocalLeader>k` : Increase the priority of the current line
`<LocalLeader>a` : Add the priority (A) to the current line
`<LocalLeader>b` : Add the priority (B) to the current line
`<LocalLeader>c` : Add the priority (C) to the current line
`<LocalLeader>d` : Insert the current date
`date<tab>` : (Insert mode) Insert the current date
`<LocalLeader>x` : Toggle mark task as done (inserts or remove current date as
completion date)
`<LocalLeader>X` : Mark all tasks as completed
`<LocalLeader>D` : Move completed tasks to done.txt
<LocalLeader> is \ by default, so <leader>-s means you type \s
=============================================================================== ===============================================================================
CONFIGURATION *todo-configuration* Table of Contents *TodoTxt-Contents* ~
1. Release notes.................................|TodoTxt-ReleaseNotes|
2. Introduction..................................|TodoTxt-Introduction|
2.1 Todo.txt rules...........................|TodoTxt-Rules|
2.2 Why this Fork............................|TodoTxt-Fork|
2.3 Installation.............................|TodoTxt-Installation|
3. TodoTxt Files.................................|TodoTxt-Files|
4. Completion....................................|TodoTxt-Completion|
5. Hierarchical Sort.............................|TodoTxt-HierarchicalSort|
6. Mappings......................................|TodoTxt-Mappings|
6.1 Sort.....................................|TodoTxt-Sort|
6.2 Priorities...............................|TodoTxt-Priorities|
6.3 Dates....................................|TodoTxt-Dates|
6.4 Done.txt.................................|TodoTxt-Done|
===============================================================================
1. Release notes *TodoTxt-ReleaseNotes* ~
V0.8.1 Incorporates yet antoher Fretep work : highlithing for tasks due today.
v0.8 Incorporates Fretep's work on overdue dates (PR#13 and PR#16) witch removes
python dependency, allow to control the cursor position after a sort by todo
(see |TodoTxt-Sort| and/or issue #15) and fixes bug when sorting a file
containing only lines with due:date (issue #14).
v0.7.6 Incorporates [Sietse's work](https://github.com/sietse/todo.txt-vim/commit/57d45200c8b033d31c9191ee0eb0711c801cdb1d) to make cancel and mark as done mapping repeatable using [vim-repeat](https://github.com/tpope/vim-repeat).
v0.7.5 Incorporates Fievel's work
(https://github.com/fievel/todo.txt-vim/commit/0863e1434e9a89ace06c4856b6cb32ba9906e3de)
to make overduedates work on python3.
v0.7.4 includes the overduedate support from Guilherme Victal (see pull
request #45 on freitass version (https://github.com/freitass/todo.txt-vim/pull/45)),
it highlight dates in overdue tasks as an Error. It depends on a
Python library, however, and as such will only be able to work if your version
of Vim was compiled with the `+python` option (as most common versions do).
Since v0.7.3, `TodoComplete` is replaced by `todo#Complete`, you might need to
update your vimrc (see |TodoTxt-Completion|).
===============================================================================
2. Introduction *TodoTxt-Introduction* ~
Todo.txt-vim is a plugin to manage todo.txt files it was initially designed by
Freitass (https://github.com/freitass/todo.txt-vim) then forked and improved
by David Beniamine.
2.1 Todo.txt rules *TodoTxt-Rules*
Todo.txt is a standard human readable todo notes file defined here:
http://todotxt.com
"The todo.txt format is a simple set of
rules(https://github.com/ginatrapani/todo.txt-cli/wiki/The-Todo.txt-Format)
that make todo.txt both human and machine-readable. The format supports
priorities, creation and completion dates, projects and contexts. That's
all you need to be productive. See an example Todo.txt file":
>
(A) Call Mom @Phone +Family
(A) Schedule annual checkup +Health
(B) Outline chapter 5 +FamilyNovel @Computer
(C) Add cover sheets @ComputerOffice +FamilyTPSReports
Plan backyard herb garden @ComputerHome
Pick up milk @ComputerGroceryStore
Research self-publishing services +FamilyNovel @ComputerComputer
x Download Todo.txt mobile app @ComputerPhone
<
2.2 Why this fork ? *TodoTxt-Fork*
This plugin is a fork of freitass todo.txt-vim
(https://github.com/freitass/todo.txt-vim). It add severals cool
functionalities including:
+ Hierarchical sort: |TodoTxt-Sort| and |TodoTxt-HierarchicalSort|.
+ A completion function: |TodoTxt-Completion|.
+ A proper handling of due dates: |TodoTxt-Dates|
+ A Flexible file naming: |TodoTxt-Files|.
+ Syntax Highlight for couples key:value.
+ `<LocalLeader>x` is a toggle which allow you to unmark a task as done.
+ `<LocalLeader>C` Toggle Mark a task cancelled
+ If the current buffer is a done.txt file, the basic sort sorts on
completion date.
+ ...
2.3 Installation *TodoTxt-Installation*
+ Vizardry
If you have Vizardry(https://github.com/dbeniamine/vizardry) installed,
you can run from vim:
>
:Invoke -u dbeniamine todo.txt-vim
<
+ Pathogen install
>
git clone https://github.com/dbeniamine/todo.txt-vim.git ~/.vim/bundle/todo.txt-vim
<
Then from vim: `:Helptags` to update the doc
+ Quick install
>
git clone https://github.com/dbeniamine/todo.txt-vim.git
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`
===============================================================================
3. TodoTxt Files *TodoTxt-Files* ~
This plugin provides a Flexible file naming for todo.txt, all the following
names are recognized as todo:
>
YYYY-MM-[Tt]odo.txt
YYYY-MM-DD[Tt]odo.txt
[Tt]odo-YYYY-MM.txt
[Tt]odo-YYYY-MM-DD.txt
[Tt]odo.txt
[Tt]oday.txt
<
And obviously the same are recognize as done:
>
YYYY-MM-[Dd]one.txt
YYYY-MM-DD[Dd]one.txt
[Dd]one-YYYY-MM.txt
[Dd]one-YYYY-MM-DD.txt
[Dd]one.txt
[Dd]one-[Tt]oday.txt
<
Moreover, `<LocalLeader>D` moves the task under the cursor to the done.txt
file corresponding to the current todo.txt, aka if you are editing
2015-07-07-todo.txt, the done file while be 2015-07-07-done.txt. If you don't
like this behavior, you can set the default done.txt name:
>
let g:TodoTxtForceDoneName='done.txt'
<
===============================================================================
4. Completion *TodoTxt-Completion* ~
This plugin provides a nice complete function for project and context, to use
it add the following lines to your vimrc:
>
" Use todo#complete as the omni complete function for todo files
au filetype todo setlocal omnifunc=todo#complete
<
You can also start automatically the completion when entering '+' or '@' by
adding the next lines to your vimrc:
>
" Auto complete projects
au filetype todo imap <buffer> + +<C-X><C-O>
" Auto complete contexts
au filetype todo imap <buffer> @ @<C-X><C-O>
<
The `todo#complete` function is designed to complete projects (starting by `+`)
and context (starting by `@`). If you use it on a regular word, it will do a
normal keyword completion (on all buffers).
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 in which they appears in the preview window. It does the same thing
for context except that it gives in the preview the list of projects existing
in each existing contexts.
===============================================================================
5. Hierarchical sort *TodoTxt-HierarchicalSort* ~
This fork provides a hierarchical sorting function designed to do by project
and/or by context sorts and a priority sort.
`<LocalLeader>sc` : Sort the file by context then by priority
`<LocalLeader>scp` : Sort the file by context, project then by priority
`<LocalLeader>sp` : Sort the file by project then by priority
`<LocalLeader>spc` : Sort the file by project, context then by priority
The user can give argument for the two calls to vim sort function by changing The user can give argument for the two calls to vim sort function by changing
the following variables: the following variables:
>
g:Todo_txt_first_level_sort_mode g:Todo_txt_first_level_sort_mode
g:Todo_txt_second_level_sort_mode g:Todo_txt_second_level_sort_mode
<
Defaults values are: Defaults values are:
g:Todo_txt_first_level_sort_mode="i" >
g:Todo_txt_second_level_sort_mode="i" g:Todo_txt_first_level_sort_mode="i"
g:Todo_txt_second_level_sort_mode="i"
<
For more information on the available flags see |:sort|
For more information on the available flags see help :sort
We also provide a nice complete function for project and context, to use it
add the following lines to your vimrc:
" Use TodoComplete as the omni complete for todo files
au filetype todo setlocal omnifunc=TodoComplete
You can also start automatically the completion when entering '+' or '@' by
adding the next lines to your vimrc:
" Auto complete projects
au filetype todo imap + +<C-X><C-O>
" Auto complete contexts
au filetype todo imap @ @<C-X><C-O>
=============================================================================== ===============================================================================
COMPLETION *todo-complete* 6. Mappings *TodoTxt-Mappings* ~
The TodoComplete function is designed to complete projects (starting by '+') By default todo-txt.vim set all the mappings secribed in this section. To
and context (starting by '@'). If you use it on a regular word, it will do a prevent this behavior, add the following line to your vimrc
normal buffer completion. >
If you try to complete a project, it will propose all projects in all open let g:Todo_txt_do_not_map=1
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 6.1 Sort *TodoTxt-Sort*
preview the list of projects existing in each existing contexts.
`<LocalLeader>s` : Sort the file by priority
`<LocalLeader>s+` : Sort the file on +Projects
`<LocalLeader>s@` : Sort the file on @Contexts
`<LocalLeader>sd` : Sort the file on due dates
`<LocalLeader>sc` : Sort the file by context then by priority
`<LocalLeader>scp` : Sort the file by context, project then by priority
`<LocalLeader>sp` : Sort the file by project 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.
When you sort by due dates, at the end of the sort, your cursor will be placed
at the top of the file. This behavior can be set with the following global
variable :
let g:TodoTxtSortDueDateCursorPos = "top"
Possible values are :
+ `top` (default): The first line of the buffer, i.e. your most outstanding task
+ `lastdue`: The last task with a due:date set
+ `notoverdue`: The first task that is not overdue (requires #13)
+ `bottom`: The last line of the buffer
6.2 Priorities *TodoTxt-Priorities*
`<LocalLeader>j` : Lower the priority of the current line
`<LocalLeader>k` : Increase the priority of the current line
`<LocalLeader>a` : Add the priority (A) to the current line
`<LocalLeader>b` : Add the priority (B) to the current line
`<LocalLeader>c` : Add the priority (C) to the current line
6.3 Dates *TodoTxt-Dates*
`<LocalLeader>d` : 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
6.4 Done *TodoTxt-Done*
`<LocalLeader>x` : Toggle mark task as done (inserts or remove current
date as completion date)
`<LocalLeader>C` : Toggle mark task cancelled
`<LocalLeader>X` : Mark all tasks as completed
`<LocalLeader>D` : Move completed tasks to done file, see |TodoTxt-Files|
`<LocalLeader>` is \ by default, so ̀`<LocaLeader>-s` means you type \s

View File

@@ -1,10 +1,19 @@
" 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 " vim: ts=4 sw=4 :help tw=78 cc=80
autocmd BufNewFile,BufRead [Tt]odo.txt set filetype=todo autocmd BufNewFile,BufRead [Tt]odo.txt set filetype=todo
autocmd BufNewFile,BufRead [Tt]odo-\d\\\{4\}-\d\\\{2\}-\d\\\{2\}.txt set filetype=todo
autocmd BufNewFile,BufRead [Tt]odo-\d\\\{4\}-\d\\\{2\}.txt set filetype=todo
autocmd BufNewFile,BufRead \d\\\{4\}-\d\\\{2\}-\d\\\{2\}-[Tt]odo.txt set filetype=todo
autocmd BufNewFile,BufRead \d\\\{4\}-\d\\\{2\}-[Tt]odo.txt set filetype=todo
autocmd BufNewFile,BufRead [Tt]oday.txt set filetype=todo
autocmd BufNewFile,BufRead [Dd]one.txt set filetype=todo autocmd BufNewFile,BufRead [Dd]one.txt set filetype=todo
autocmd BufNewFile,BufRead [Dd]one-\d\\\{4\}-\d\\\{2\}-\d\\\{2\}.txt set filetype=todo
autocmd BufNewFile,BufRead [Dd]one-\d\\\{4\}-\d\\\{2\}.txt set filetype=todo
autocmd BufNewFile,BufRead \d\\\{4\}-\d\\\{2\}-\d\\\{2\}-[Dd]one.txt set filetype=todo
autocmd BufNewFile,BufRead \d\\\{4\}-\d\\\{2\}-[Dd]one.txt set filetype=todo
autocmd BufNewFile,BufRead [Dd]one-[Tt]oday.txt set filetype=todo

View File

@@ -1,14 +1,20 @@
" 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 " vim: ts=4 sw=4 :help tw=78 cc=80
" Save context {{{1 " Save context {{{1
let s:save_cpo = &cpo let s:save_cpo = &cpo
set cpo&vim set cpo&vim
if exists("g:Todo_txt_loaded")
finish
else
let g:Todo_txt_loaded=0.8.1
endif
" 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 invocated, which is whenever a file of this type is
@@ -16,197 +22,56 @@ set cpo&vim
setlocal textwidth=0 setlocal textwidth=0
setlocal wrapmargin=0 setlocal wrapmargin=0
" Functions {{{1
function! s:TodoTxtRemovePriority()
:s/^(\w)\s\+//ge
endfunction
function! TodoTxtPrependDate()
normal! 0"=strftime("%Y-%m-%d ")
P
endfunction
function! TodoTxtToggleMarkAsDone()
if (getline(".") =~ 'x\s*\d\{4\}')
:call TodoTxtUnMarkAsDone()
else
:call TodoTxtMarkAsDone()
endif
endfunction
function! TodoTxtUnMarkAsDone()
:s/\s*x\s*\d\{4}-\d\{1,2}-\d\{1,2}\s*//g
endfunction
function! TodoTxtMarkAsDone()
" call s:TodoTxtRemovePriority()
call TodoTxtPrependDate()
normal! Ix
endfunction
function! TodoTxtMarkAllAsDone()
:g!/^x /:call TodoTxtMarkAsDone()
endfunction
function! s:AppendToFile(file, lines)
let l:lines = []
" Place existing tasks in done.txt at the beggining of the list.
if filereadable(a:file)
call extend(l:lines, readfile(a:file))
endif
" Append new completed tasks to the list.
call extend(l:lines, a:lines)
" Write to file.
call writefile(l:lines, a:file)
endfunction
function! TodoTxtRemoveCompleted()
" Check if we can write to done.txt before proceeding.
let l:target_dir = expand('%:p:h')
let l:done_file = l:target_dir.'/done.txt'
if !filewritable(l:done_file) && !filewritable(l:target_dir)
echoerr "Can't write to file 'done.txt'"
return
endif
let l:completed = []
:g/^x /call add(l:completed, getline(line(".")))|d
call s:AppendToFile(l:done_file, l:completed)
endfunction
function! TodoTxtSort()
" vim :sort is usually stable
" we sort first on contexts, then on projects and then on priority
:sort /@[a-zA-Z]*/ r
:sort /+[a-zA-Z]*/ r
:sort /\v\([A-Z]\)/ r
endfunction
" Mappings {{{1 " Mappings {{{1
if !exists("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 " Sort tasks {{{2
" Sort tasks {{{2 nnoremap <script> <silent> <buffer> <LocalLeader>s :call todo#Sort()<CR>
if !hasmapto("<localleader>s",'n')
nnoremap <script> <silent> <buffer> <LocalLeader>s :call TodoTxtSort()<CR>
endif
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>
endif
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>
" Increment and Decrement The Priority noremap <script> <silent> <buffer> <LocalLeader>b :call todo#PrioritizeAdd('B')<CR>
:set nf=octal,hex,alpha noremap <script> <silent> <buffer> <LocalLeader>c :call todo#PrioritizeAdd('C')<CR>
function! TodoTxtPrioritizeIncrease()
normal! 0f)h
endfunction
function! TodoTxtPrioritizeDecrease()
normal! 0f)h
endfunction
function! TodoTxtPrioritizeAdd (priority)
let oldpos=getcurpos()
let line=getline('.')
if line !~ '^([A-F])'
:call TodoTxtPrioritizeAddAction(a:priority)
let oldpos[2]+=4
else
exec ':s/^([A-F])/('.a:priority.')/'
endif
call setpos('.',oldpos)
endfunction
function! TodoTxtPrioritizeAddAction (priority)
execute "normal! mq0i(".a:priority.") \<esc>`q"
endfunction
if !hasmapto("<LocalLeader>j",'n')
nnoremap <script> <silent> <buffer> <LocalLeader>j :call TodoTxtPrioritizeIncrease()<CR>
endif
if !hasmapto("<LocalLeader>j",'v')
vnoremap <script> <silent> <buffer> <LocalLeader>j :call TodoTxtPrioritizeIncrease()<CR>
endif
if !hasmapto("<LocalLeader>k",'n')
nnoremap <script> <silent> <buffer> <LocalLeader>k :call TodoTxtPrioritizeDecrease()<CR>
endif
if !hasmapto("<LocalLeader>k",'v')
vnoremap <script> <silent> <buffer> <LocalLeader>k :call TodoTxtPrioritizeDecrease()<CR>
endif
if !hasmapto("<LocalLeader>a",'n')
nnoremap <script> <silent> <buffer> <LocalLeader>a :call TodoTxtPrioritizeAdd('A')<CR>
endif
if !hasmapto("<LocalLeader>a",'i')
inoremap <script> <silent> <buffer> <LocalLeader>a <ESC>:call TodoTxtPrioritizeAdd('A')<CR>i
endif
if !hasmapto("<LocalLeader>a",'v')
vnoremap <script> <silent> <buffer> <LocalLeader>a :call TodoTxtPrioritizeAdd('A')<CR>
endif
if !hasmapto("<LocalLeader>b",'n')
nnoremap <script> <silent> <buffer> <LocalLeader>b :call TodoTxtPrioritizeAdd('B')<CR>
endif
if !hasmapto("<LocalLeader>b",'i')
inoremap <script> <silent> <buffer> <LocalLeader>b <ESC>:call TodoTxtPrioritizeAdd('B')<CR>i
endif
if !hasmapto("<LocalLeader>b",'v')
vnoremap <script> <silent> <buffer> <LocalLeader>b :call TodoTxtPrioritizeAdd('B')<CR>
endif
if !hasmapto("<LocalLeader>c",'n')
nnoremap <script> <silent> <buffer> <LocalLeader>c :call TodoTxtPrioritizeAdd('C')<CR>
endif
if !hasmapto("<LocalLeader>c",'i')
inoremap <script> <silent> <buffer> <LocalLeader>c <ESC>:call TodoTxtPrioritizeAdd('C')<CR>i
endif
if !hasmapto("<LocalLeader>c",'v')
vnoremap <script> <silent> <buffer> <LocalLeader>c :call TodoTxtPrioritizeAdd('C')<CR>
" Insert date {{{2 " Insert date {{{2
" Insert date {{{2
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> date<Tab> <C-R>=strftime("%Y-%m-%d")<CR>
inoremap <script> <silent> <buffer> due: due:<C-R>=strftime("%Y-%m-%d")<CR>
if !hasmapto("<localleader>d",'n') inoremap <script> <silent> <buffer> DUE: DUE:<C-R>=strftime("%Y-%m-%d")<CR>
nnoremap <script> <silent> <buffer> <localleader>d :call TodoTxtPrependDate()<CR>
noremap <script> <silent> <buffer> <localleader>d :call todo#PrependDate()<CR>
if !hasmapto("<localleader>d",'v')
vnoremap <script> <silent> <buffer> <localleader>d :call TodoTxtPrependDate()<CR>
" Mark done {{{2 " Mark done {{{2
" Mark done {{{2 noremap <script> <silent> <buffer> <Plug>DoToggleMarkAsDone :call todo#ToggleMarkAsDone('')<CR>
if !hasmapto("<localleader>x",'n') \:call repeat#set("\<Plug>DoToggleMarkAsDone")<CR>
nnoremap <script> <silent> <buffer> <localleader>x :call TodoTxtToggleMarkAsDone()<CR> nmap <localleader>x <Plug>DoToggleMarkAsDone
" noremap <script> <silent> <buffer> <localleader>x :call todo#ToggleMarkAsDone('')<CR>
" Mark done {{{2
if !hasmapto("<localleader>x",'v') noremap <script> <silent> <buffer> <Plug>DoCancel :call todo#ToggleMarkAsDone('Cancelled')<CR>
vnoremap <script> <silent> <buffer> <localleader>x :call TodoTxtToggleMarkAsDone()<CR> \:call repeat#set("\<Plug>DoCancel")<CR>
nmap <localleader>C <Plug>DoCancel
" Mark all done {{{2 " Mark all done {{{2
" Mark all done {{{2 noremap <script> <silent> <buffer> <localleader>X :call todo#MarkAllAsDone()<CR>
if !hasmapto("<localleader>X",'n')
nnoremap <script> <silent> <buffer> <localleader>X :call TodoTxtMarkAllAsDone()<CR>
" Remove completed {{{2 " Remove completed {{{2
" Remove completed {{{2 nnoremap <script> <silent> <buffer> <localleader>D :call todo#RemoveCompleted()<CR>
if !hasmapto("<localleader>D",'n')
" Sort by due: date {{{2
nnoremap <script> <silent> <buffer> <localleader>sd :call todo#SortDue()<CR>
endif endif
" Folding {{{1 " Folding {{{1
@@ -237,68 +102,5 @@ function! TodoFoldText()
\ . ' Completed tasks ' \ . ' Completed tasks '
endfunction endfunction
" Intelligent completion for projects and Contexts
fun! TodoComplete(findstart, base)
if a:findstart
let line = getline('.')
let start = col('.') - 1
while start > 0 && line[start - 1] !~ '\s'
let start -= 1
endwhile
return start
else
" Opposite sign
let opp=a:base=~'+'?'@':'+'
" Search for matchs
let res = []
for bufnr in range(1,bufnr('$'))
let lines=getbufline(bufnr,1,"$")
for line in lines
if line =~ "[x\s0-9\-]*([a-Z]).* ".a:base
" init temporary item
let item={}
let item.word=substitute(line,'.*\('.a:base.'\S*\).*','\1',"")
let item.buffers=bufname(bufnr)
let item.related=substitute(line,'.*\s\('.opp.'\S\S*\).*','\1',"")
call add(res,item)
endif
endfor
endfor
call sort(res)
" Here all results are sorted in res, but we need to merge them
let ret=[]
let curitem={}
let curitem.word=res[0].word
let curitem.related=[]
let curitem.buffers=[]
for it in res
if curitem.word==it.word
" Merge results
if index(curitem.related,it.related) <0
call add(curitem.related,it.related)
endif
if index(curitem.buffers,it.buffers) <0
call add(curitem.buffers,it.buffers)
endif
else
" Create the definitive item
let resitem={}
let resitem.word=curitem.word
let resitem.info=opp=='+'?"Projects":"Contexts"
let resitem.info.=": ".join(curitem.related, ", ")
\."\nBuffers: ".join(curitem.buffers, ", ")
call add(ret,resitem)
" Init new item from it
let curitem.word=it.word
let curitem.related=[it.related]
let curitem.buffers=[it.buffers]
endif
endfor
return ret
endif
endfun
" Restore context {{{1 " Restore context {{{1
let &cpo = s:save_cpo let &cpo = s:save_cpo
let &cpo = s:save_cpo
" Modeline {{{1

View File

@@ -1,133 +0,0 @@
" File: todo.txt.vim
" Description: Todo.txt sorting plugin
" Author: David Beniamine <david@beniamine.net>
" Licence: Vim licence
" Website: http://github.com/dbeniamine/todo.txt.vim
" Version: 0.6
" vim: ts=4 sw=4 :help tw=78 cc=80
" These two variables are parameters for the successive calls the vim sort
" '' means no flags
" '! i' means reverse and ignore case
" for more information on flags, see :help sort
if (! exists("g:Todo_txt_first_level_sort_mode"))
let g:Todo_txt_first_level_sort_mode='i'
endif
if (! exists("g:Todo_txt_second_level_sort_mode"))
let g:Todo_txt_second_level_sort_mode='i'
endif
if (! exists("g:Todo_txt_third_level_sort_mode"))
let g:Todo_txt_third_level_sort_mode='i'
endif
" Sort todo by (first) context
if !hasmapto("<localleader>sc",'n')
noremap <localleader>sc :call Todo_txt_HierarchicalSort('@', '', 1)<CR>
endif
if !hasmapto("<localleader>scp",'n')
noremap <localleader>scp :call Todo_txt_HierarchicalSort('@', '+', 1)<CR>
endif
" Sort todo by (first) project
if !hasmapto("<localleader>sp",'n')
noremap <localleader>sp :call Todo_txt_HierarchicalSort('+', '',1)<CR>
endif
if !hasmapto("<localleader>spc",'n')
noremap <localleader>spc :call Todo_txt_HierarchicalSort('+', '@',0)<CR>
endif
" This is a Hierarchical sort designed for todo.txt todo lists, however it
" might be used for other files types
" At the first level, lines are sorted by the word right after the first
" occurence of a:symbol, there must be no space between the symbol and the
" word. At the second level, the same kind of sort is done based on
" a:symbolsub, is a:symbol==' ', the second sort doesn't occurs
" Therefore, according to todo.txt syntaxt, if
" a:symbol is a '+' it sort by the first project
" a:symbol is an '@' it sort by the first context
" The last level of sort is done directly on the line, so according to
" todo.txt syntax, it means by priority. This sort is done if and only if the
" las argument is not 0
function! Todo_txt_HierarchicalSort(symbol, symbolsub, dolastsort)
if v:statusmsg =~ '--No lines in buffer--'
"Empty buffer do nothing
return
endif
"if the sort modes doesn't start by '!' it must start with a space
let l:sortmode=Todo_txt_InsertSpaceIfNeeded(g:Todo_txt_first_level_sort_mode)
let l:sortmodesub=Todo_txt_InsertSpaceIfNeeded(g:Todo_txt_second_level_sort_mode)
let l:sortmodefinal=Todo_txt_InsertSpaceIfNeeded(g:Todo_txt_third_level_sort_mode)
" Count the number of lines
let l:position= getpos(".")
execute "silent normal g\<c-g>"
let l:linecount=str2nr(split(v:statusmsg)[7])
" Get all the groups names
let l:groups=GetGroups(a:symbol,0,l:linecount)
" Sort by groups
execute 'sort'.l:sortmode.' /.\{-}\ze'.a:symbol.'/'
for l:g in l:groups
" Find the beginning of the group
execute '/'.a:symbol.l:g.'.*$'
let l:groupBegin=getpos(".")[1]
" Find the end of the group
silent normal N
let l:groupEnd=getpos(".")[1]
" I'm too lazy to sort one groups of one line
if(l:groupEnd==l:groupBegin)
continue
endif
if( a:symbolsub!='')
" Sort by subgroups
let l:subgroups=GetGroups(a:symbolsub,l:groupBegin,l:groupEnd)
" Go before the first line of the group
" Sort the group using the second symbol
for l:sg in l:subgroups
" Find the beginning of the subgroup
execute '/'.a:symbol.l:g.'.*'.a:symbolsub.l:sg.'.*$\|'.a:symbolsub.l:sg.'.*'.a:symbol.l:g.'.*$'
let l:subgroupBegin=getpos(".")[1]
" Find the end of the subgroup
silent normal N
let l:subgroupEnd=getpos(".")[1]
" Sort by priority
if a:dolastsort
execute l:subgroupBegin.','.l:subgroupEnd.'sort'.l:sortmodefinal
endif
endfor
else
" Sort by priority
if a:dolastsort
execute l:groupBegin.','.l:groupEnd.'sort'.l:sortmodefinal
endif
endif
endfor
" Restore the cursor position
call setpos('.', position)
endfunction
" Returns the list of groups starting by a:symbol between lines a:begin and
" a:end
function! GetGroups(symbol,begin, end)
let l:curline=a:begin
let l:groups=[]
while l:curline <= a:end
let l:curproj=strpart(matchstr(getline(l:curline),a:symbol.'\a*'),1)
if l:curproj != "" && index(l:groups,l:curproj) == -1
let l:groups=add(l:groups , l:curproj)
endif
let l:curline += 1
endwhile
return l:groups
endfunction
" Insert a space if needed (the first char isn't '!' or ' ') in front of
" sort parameters
function! Todo_txt_InsertSpaceIfNeeded(str)
let l:c=strpart(a:str,1,1)
if( l:c != '!' && l:c !=' ')
return " ".a:str
endif
retur a:str
endfunction

View File

@@ -1,46 +1,53 @@
" 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 " vim: ts=4 sw=4 :help tw=78 cc=80
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,TodoDueToday,TodoOverDueDate
syntax match TodoPriorityB '^([bB])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityB '^([bB])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
syntax match TodoPriorityC '^([cC])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityC '^([cC])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
syntax match TodoPriorityD '^([dD])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityD '^([dD])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
syntax match TodoPriorityE '^([eE])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityE '^([eE])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
syntax match TodoPriorityF '^([fF])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityF '^([fF])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
syntax match TodoPriorityG '^([gG])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityG '^([gG])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
syntax match TodoPriorityH '^([hH])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityH '^([hH])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
syntax match TodoPriorityI '^([iI])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityI '^([iI])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
syntax match TodoPriorityJ '^([jJ])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityJ '^([jJ])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
syntax match TodoPriorityK '^([kK])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityK '^([kK])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
syntax match TodoPriorityL '^([lL])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityL '^([lL])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
syntax match TodoPriorityM '^([mM])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityM '^([mM])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
syntax match TodoPriorityN '^([nN])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityN '^([nN])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
syntax match TodoPriorityO '^([oO])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityO '^([oO])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
syntax match TodoPriorityP '^([pP])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityP '^([pP])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
syntax match TodoPriorityQ '^([qQ])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityQ '^([qQ])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
syntax match TodoPriorityR '^([rR])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityR '^([rR])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
syntax match TodoPriorityS '^([sS])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityS '^([sS])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
syntax match TodoPriorityT '^([tT])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityT '^([tT])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
syntax match TodoPriorityU '^([uU])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityU '^([uU])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
syntax match TodoPriorityV '^([vV])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityV '^([vV])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
syntax match TodoPriorityW '^([wW])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityW '^([wW])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
syntax match TodoPriorityX '^([xX])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityX '^([xX])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
syntax match TodoPriorityY '^([yY])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityY '^([yY])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
syntax match TodoPriorityZ '^([zZ])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityZ '^([zZ])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
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:\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
let s:todayDate=strftime('%Y\-%m\-%d')
"TODO: Figure out how to allow stop the following line being highlighted inside TodoDone
"execute 'syntax match TodoDueToday /\v\c<(due:)@4<=' . s:todayDate . '/ contains=NONE contained'
execute 'syntax match TodoDueToday /\v\c<due:' . s:todayDate . '/ 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
@@ -48,5 +55,125 @@ highlight default link TodoPriorityC type
highlight default link TodoDate PreProc highlight default link TodoDate PreProc
highlight default link TodoProject Special highlight default link TodoProject Special
highlight default link TodoContext Special highlight default link TodoContext Special
highlight default link TodoDueToday Todo
function! todo#GetDateRegexForPastDates(...)
" Build a RegExp to match all dates prior to a reference date.
"
" Optionally accepts a (year, month, day) for the date, otherwise assumes the
" reference date is the current date.
"
" In the end, the RegExp will look something like:
" =todo#GetDateRegexForPastDates(2017, 09, 15)
" \v(([01]\d{3}|200\d|201[0-6])\-\d{2}\-\d{2}|(2017\-(0[0-8])\-\d{2})|(2017\-09\-0\d)|(2017\-09\-1[0-4]))
"
" We split the RegExp into a few alternation groups:
" 1. All dates prior to 2000, dates before this are not supported
" 2. All previous decades for the reference date century
" 3. The current decade up to the year prior to the reference year
" 4. All months for the reference year up to the end of the previous month
" 5. Days of the month part 1.
" 6. Days of the month part 2.
"
" Will not work on reference dates past 2099, or before 2000.
"
" Invalid months and days are not checked, i.e. 2015-14-67 will match.
"
" Years must be 4 digits.
"
" Get the reference date
let l:day=strftime("%d")
let l:month=strftime("%m")
let l:year=strftime("%Y")
if a:0 >= 1
let l:year=a:1
endif
if a:0 >= 2
let l:month=a:2
endif
if a:0 >= 3
let l:day=a:3
endif
" Use very magic mode, and start an alternation
let l:overdueRex = '\v('
" PART 1: 0000-1999
" This sucker is static and won't change to year 3000. I'm not coding for the year 3000.
let l:overdueRex = l:overdueRex . '([01]\d{3}'
" PART 2. All previous decades for the reference date century
" i.e. for 2017: "200\d", for 2035: "20[0-2]\d"
" for 2000: skip
let l:decade = strpart(l:year, 2, 1) " i.e. the 1 from 2017
if l:decade > 0
let l:overdueRex = l:overdueRex . '|20'
if l:decade > 1
let l:overdueRex = l:overdueRex . '[0-' . (l:decade - 1) . ']'
else
let l:overdueRex = l:overdueRex . '0'
endif
let l:overdueRex = l:overdueRex . '\d'
endif
" PART 3: This decade, to previous year
" i.e. for 2017: "201[0-6]", for 2035: "203[0-4]", for 2000: skip
let l:y = strpart(l:year, 3, 1) " Last digit of the year, i.e. 7 for 2017
if l:y > 0
if l:y > 1
let l:overdueRex = l:overdueRex . '|20' . l:decade . '[0-' . (l:y - 1) . ']'
else
let l:overdueRex = l:overdueRex . '|20' . l:decade . '0'
endif
endif
let l:overdueRex = l:overdueRex . ')\-\d{2}\-\d{2}|'
" PART 4: All months to the end of the previous month
" i.e. for a date of 2017-09-07, "2017-(0[1-8])-\d{2}"
" for 2017-11-30: "2017-(0\d|1[0-1])-\d{2}"
" for 2017-01-20: skip
" This only applies if the reference date is not in January
if l:month > 1
let l:overdueRex = l:overdueRex . '(' . l:year . '\-(0'
if l:month > 10
let l:overdueRex = l:overdueRex . '\d|1'
endif
let l:y = strpart(printf('%02d', l:month), 1, 1) " Second digit of the month
let l:overdueRex = l:overdueRex . '[0-' . (l:y - 1) . '])\-\d{2})|'
endif
" PART 5. Days of the month part 1.
" i.e. for 2017-09-07: skip
" for 2017-12-29: "2017-12-[0-1]\d"
let l:y = strpart(printf('%02d', l:day), 0, 1) " First digit of the day
if l:y > 0
if l:y > 1
let l:overdueRex = l:overdueRex . '(' . l:year . '\-' . printf('%02d', l:month) . '\-[0-' . (l:y - 1) . ']\d)|'
else
let l:overdueRex = l:overdueRex . '(' . l:year . '\-' . printf('%02d', l:month) . '\-0\d)|'
endif
endif
" PART 6. Days of the month part 2.
" i.e. for 2017-09-07: "2017-09-0[0-6]"
" for 2017-12-29: "2017-12-2[0-8]"
let l:y = strpart(printf('%02d', l:day), 0, 1) " First digit of the day
let l:overdueRex = l:overdueRex . '(' . l:year . '\-' . printf('%02d', l:month) . '\-' . l:y
let l:y = strpart(printf('%02d', l:day), 1, 1) " Last digit of the day
if l:y > 0
let l:overdueRex = l:overdueRex . '[0-' . (l:y - 1) . ']'
else
let l:overdueRex = l:overdueRex . '0'
endif
let l:overdueRex = l:overdueRex . ')'
let l:overdueRex = l:overdueRex . ')'
return l:overdueRex
endfunction
execute 'syntax match TodoOverDueDate /\v\c<due:' . todo#GetDateRegexForPastDates() . '>/'
highlight default link TodoOverDueDate Error
let b:current_syntax = "todo" let b:current_syntax = "todo"