Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a103f1429 | ||
|
|
9f87eec204 | ||
|
|
53ad73ebda | ||
|
|
68a32427ab | ||
|
|
4da3c4ae12 | ||
|
|
e7dee69733 | ||
|
|
73ba0effca | ||
|
|
cf10a3b0b8 | ||
|
|
e49cc7d595 | ||
|
|
7bca6726ea | ||
|
|
eb5ece482d | ||
|
|
eb6d973887 | ||
|
|
84c815bb21 | ||
|
|
1b49ec094c |
@@ -2,9 +2,14 @@
|
|||||||
|
|
||||||
## 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
|
||||||
function for context and projects (see section 1.4).
|
functionalities including a [hierarchical sort](#sort), a
|
||||||
|
[complete](#completion) function, some stuff to handle [due
|
||||||
|
dates](#due-dates), a more [flexible file naming](#flexible-file-naming), and
|
||||||
|
others stuff see [new features](#new-features).
|
||||||
|
|
||||||
|
Freitass announced on october 30th 2014 that he is not going to merge his version.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
@@ -14,10 +19,17 @@ function for context and projects (see section 1.4).
|
|||||||
cd todo.txt-vim
|
cd todo.txt-vim
|
||||||
cp -r ./* ~/.vim
|
cp -r ./* ~/.vim
|
||||||
|
|
||||||
|
|
||||||
|
If you want the help installed, run `:helptags ~/.vim/doc` inside vim after
|
||||||
|
having copied the files. Then you will be able to get the commands help with:
|
||||||
|
`:h todo.txt`
|
||||||
|
|
||||||
### Pathogen install
|
### Pathogen install
|
||||||
|
|
||||||
git clone https://github.com/dbeniamine/todo.txt-vim.git ~/.vim/bundle/todo.txt-vim
|
git clone https://github.com/dbeniamine/todo.txt-vim.git ~/.vim/bundle/todo.txt-vim
|
||||||
|
|
||||||
|
Then from vim: `:Helptags` to update the doc
|
||||||
|
|
||||||
## Features included in Freitass version
|
## Features included in Freitass version
|
||||||
|
|
||||||
This plugin gives syntax highlighting to [todo.txt](http://todotxt.com/) files. It also defines a few mappings, to help with editing these files:
|
This plugin gives syntax highlighting to [todo.txt](http://todotxt.com/) files. It also defines a few mappings, to help with editing these files:
|
||||||
@@ -48,11 +60,10 @@ This plugin gives syntax highlighting to [todo.txt](http://todotxt.com/) files.
|
|||||||
|
|
||||||
`<leader>-D` : Move completed tasks to done.txt
|
`<leader>-D` : Move completed tasks to done.txt
|
||||||
|
|
||||||
If you want the help installed, run ":helptags ~/.vim/doc" inside vim after having copied the files.
|
|
||||||
Then you will be able to get the commands help with: :h todo.txt
|
|
||||||
|
|
||||||
## New features
|
## New features
|
||||||
|
|
||||||
|
### Sort
|
||||||
|
|
||||||
This fork provides a hierarchical sorting function designed to do by project
|
This fork provides a hierarchical sorting function designed to do by project
|
||||||
and/or by context sorts and a priority sort.
|
and/or by context sorts and a priority sort.
|
||||||
|
|
||||||
@@ -67,7 +78,7 @@ see :help sort
|
|||||||
let g:Todo_txt_first_level_sort_mode="! i"
|
let g:Todo_txt_first_level_sort_mode="! i"
|
||||||
let g:Todo_txt_second_level_sort_mode="i"
|
let g:Todo_txt_second_level_sort_mode="i"
|
||||||
|
|
||||||
Also `<LocalLeader>x` is a toggle which allow you to unmark a task as done.
|
### Completion
|
||||||
|
|
||||||
We also provide a nice complete function for project and context, to use it
|
We also provide a nice complete function for project and context, to use it
|
||||||
add the following lines to your vimrc:
|
add the following lines to your vimrc:
|
||||||
@@ -79,16 +90,71 @@ You can also start automatically the completion when entering '+' or '@' by
|
|||||||
adding the next lines to your vimrc:
|
adding the next lines to your vimrc:
|
||||||
|
|
||||||
" Auto complete projects
|
" Auto complete projects
|
||||||
au filetype todo imap + +<C-X><C-O>
|
au filetype todo imap <buffer> + +<C-X><C-O>
|
||||||
|
|
||||||
" Auto complete contexts
|
" Auto complete contexts
|
||||||
au filetype todo imap @ @<C-X><C-O>
|
au filetype todo imap <buffer> @ @<C-X><C-O>
|
||||||
|
|
||||||
The TodoComplete function is designed to complete projects (starting by '+')
|
The TodoComplete function is designed to complete projects (starting by '+')
|
||||||
and context (starting by '@'). If you use it on a regular word, it will do a
|
and context (starting by '@'). If you use it on a regular word, it will do a
|
||||||
normal buffer completion.
|
normal keyword completion (on all buffers).
|
||||||
If you try to complete a project, it will propose all projects in all open
|
If you try to complete a project, it will propose all projects in all open
|
||||||
buffers and for each of them, it will show their context and the name of the
|
buffers and for each of them, it will show their context and the name of the
|
||||||
buffers in which they appears in the preview window.
|
buffers in which they appears in the preview window.
|
||||||
TodoCompelte does the same thing for context except that it gives in the
|
TodoCompelte does the same thing for context except that it gives in the
|
||||||
preview the list of projects existing in each existing contexts.
|
preview the list of projects existing in each existing contexts.
|
||||||
|
|
||||||
|
### Due dates
|
||||||
|
|
||||||
|
I've integrated the [work from
|
||||||
|
durcheinandr](https://github.com/durcheinandr/todo.txt-vim/) concerning due
|
||||||
|
dates + some little improvements:
|
||||||
|
|
||||||
|
Accorrding to the todo.txt rules, one can define due dates using `due:date` or
|
||||||
|
`DUE:date` or any other `key:value` combination. This plugins handle dates at
|
||||||
|
the format `YYYY-MM-DD` and the key `due` can be spell using any combination
|
||||||
|
of lower and upper case letters. The following mappings are provided:
|
||||||
|
|
||||||
|
`<leader>-sd` : Sort the file by due-date. Entries with a due date appears
|
||||||
|
sorted by at the beginning of the file, the rest of the file is not modified.
|
||||||
|
|
||||||
|
`due:` : (Insert mode) Insert `due:` followed by the current date
|
||||||
|
|
||||||
|
`DUE:` : (Insert mode) Insert `DUE:` followed by the current date
|
||||||
|
|
||||||
|
### Flexible File naming
|
||||||
|
|
||||||
|
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, 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. If you don't
|
||||||
|
like this behavior, you can set the default done.txt name:
|
||||||
|
|
||||||
|
let g:TodoTxtForceDoneName='done.txt'
|
||||||
|
|
||||||
|
### Others
|
||||||
|
|
||||||
|
`<LocalLeader>x` is a toggle which allow you to unmark a task as done.
|
||||||
|
|
||||||
|
Syntax highlighting for couples key:value
|
||||||
|
|
||||||
|
If the current buffer is a done.txt file, the basic sort sorts on completion
|
||||||
|
date.
|
||||||
|
|||||||
75
doc/todo.txt
75
doc/todo.txt
@@ -9,6 +9,8 @@ COMMANDS *todo-commands*
|
|||||||
|
|
||||||
`<LocalLeader>s@` : Sort the file on @Contexts
|
`<LocalLeader>s@` : Sort the file on @Contexts
|
||||||
|
|
||||||
|
`<LocalLeader>s@` : Sort the file on due dates
|
||||||
|
|
||||||
`<LocalLeader>sc` : Sort the file by context then by priority
|
`<LocalLeader>sc` : Sort the file by context then by priority
|
||||||
|
|
||||||
`<LocalLeader>scp` : Sort the file by context, project then by priority
|
`<LocalLeader>scp` : Sort the file by context, project then by priority
|
||||||
@@ -17,6 +19,9 @@ COMMANDS *todo-commands*
|
|||||||
|
|
||||||
`<LocalLeader>spc` : Sort the file by project, context then by priority
|
`<LocalLeader>spc` : Sort the file by project, context then by priority
|
||||||
|
|
||||||
|
`<leader>-sd` : Sort the file by due-date. Entries with a due date appears
|
||||||
|
sorted by at the beginning of the file, the rest of the file is not modified.
|
||||||
|
|
||||||
`<LocalLeader>j` : Lower the priority of the current line
|
`<LocalLeader>j` : Lower the priority of the current line
|
||||||
|
|
||||||
`<LocalLeader>k` : Increase the priority of the current line
|
`<LocalLeader>k` : Increase the priority of the current line
|
||||||
@@ -31,14 +36,18 @@ 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)
|
||||||
|
|
||||||
`<LocalLeader>X` : Mark all tasks as completed
|
`<LocalLeader>X` : Mark all tasks as completed
|
||||||
|
|
||||||
`<LocalLeader>D` : Move completed tasks to done.txt
|
`<LocalLeader>D` : Move completed tasks to done file, see |todo-flexibleFileNaming|
|
||||||
|
|
||||||
<LocalLeader> is \ by default, so <leader>-s means you type \s
|
`<LocalLeader>` is \ by default, so ̀`<LocaLeader>-s` means you type \s
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
CONFIGURATION *todo-configuration*
|
CONFIGURATION *todo-configuration*
|
||||||
@@ -51,34 +60,74 @@ 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 help :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
|
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:
|
||||||
|
>
|
||||||
" Use TodoComplete as the omni complete for todo files
|
" Use TodoComplete as the omni complete for todo files
|
||||||
au filetype todo setlocal omnifunc=TodoComplete
|
au filetype todo setlocal omnifunc=TodoComplete
|
||||||
|
<
|
||||||
|
|
||||||
You can also start automatically the completion when entering '+' or '@' by
|
You can also start automatically the completion when entering '+' or '@' by
|
||||||
adding the next lines to your vimrc:
|
adding the next lines to your vimrc:
|
||||||
|
>
|
||||||
|
" Auto complete projects
|
||||||
|
au filetype todo imap <buffer> + +<C-X><C-O>
|
||||||
|
|
||||||
" Auto complete projects
|
" Auto complete contexts
|
||||||
au filetype todo imap + +<C-X><C-O>
|
au filetype todo imap <buffer> @ @<C-X><C-O>
|
||||||
" Auto complete contexts
|
<
|
||||||
au filetype todo imap @ @<C-X><C-O>
|
To force completed task to be moved to a file independently from the current
|
||||||
|
file name, add the following to your vimrc:
|
||||||
|
>
|
||||||
|
let g:TodoTxtForceDoneName='done.txt'
|
||||||
|
<
|
||||||
|
For more explanations, see |todo-flexibleFileNaming|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
COMPLETION *todo-complete*
|
COMPLETION *todo-complete*
|
||||||
|
|
||||||
The TodoComplete function is designed to complete projects (starting by '+')
|
The TodoComplete function is designed to complete projects (starting by '+')
|
||||||
and context (starting by '@'). If you use it on a regular word, it will do a
|
and context (starting by '@'). If you use it on a regular word, it will do a
|
||||||
normal buffer completion.
|
normal keyword completion (on all buffers).
|
||||||
If you try to complete a project, it will propose all projects in all open
|
If you try to complete a project, it will propose all projects in all open
|
||||||
buffers and for each of them, it will show their context and the name of the
|
buffers and for each of them, it will show their context and the name of the
|
||||||
buffers in which they appears in the preview window.
|
buffers in which they appears in the preview window.
|
||||||
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.
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
FLEXIBLE FILE NAMING *todo-flexibleFileNaming*
|
||||||
|
|
||||||
|
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, 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. If you don't
|
||||||
|
like this behavior, you can set the default done.txt name:
|
||||||
|
>
|
||||||
|
let g:TodoTxtForceDoneName='done.txt'
|
||||||
|
<
|
||||||
|
|||||||
@@ -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
|
" Version: 0.7.2
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
@@ -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.2
|
||||||
|
|
||||||
" Save context {{{1
|
" Save context {{{1
|
||||||
let s:save_cpo = &cpo
|
let s:save_cpo = &cpo
|
||||||
@@ -39,7 +39,6 @@ function! TodoTxtUnMarkAsDone()
|
|||||||
:s/\s*x\s*\d\{4}-\d\{1,2}-\d\{1,2}\s*//g
|
:s/\s*x\s*\d\{4}-\d\{1,2}-\d\{1,2}\s*//g
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! TodoTxtMarkAsDone()
|
|
||||||
function! TodoTxtMarkAsDone()
|
function! TodoTxtMarkAsDone()
|
||||||
call TodoTxtPrependDate()
|
call TodoTxtPrependDate()
|
||||||
normal! Ix
|
normal! Ix
|
||||||
@@ -66,7 +65,13 @@ endfunction
|
|||||||
|
|
||||||
function! TodoTxtRemoveCompleted()
|
function! TodoTxtRemoveCompleted()
|
||||||
" Check if we can write to done.txt before proceeding.
|
" Check if we can write to done.txt before proceeding.
|
||||||
let l:target_dir = expand('%:p:h')
|
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','')
|
||||||
|
fi
|
||||||
|
let l:done_file = l:target_dir.'/'.l:done
|
||||||
echo "Writing to ".l:done_file
|
echo "Writing to ".l:done_file
|
||||||
if !filewritable(l:done_file) && !filewritable(l:target_dir)
|
if !filewritable(l:done_file) && !filewritable(l:target_dir)
|
||||||
echoerr "Can't write to file 'done.txt'"
|
echoerr "Can't write to file 'done.txt'"
|
||||||
@@ -80,9 +85,35 @@ endfunction
|
|||||||
|
|
||||||
function! TodoTxtSort()
|
function! TodoTxtSort()
|
||||||
" vim :sort is usually stable
|
" vim :sort is usually stable
|
||||||
" we sort first on contexts, then on projects and then on priority
|
" we sort first on contexts, then on projects and then on priority
|
||||||
:sort /@[a-zA-Z]*/ r
|
if expand('%')=~'done.*.txt'
|
||||||
:sort /+[a-zA-Z]*/ r
|
silent! %s/\(x\s*\d\{4}\)-\(\d\{2}\)-\(\d\{2}\)/\1\2\3/g
|
||||||
|
sort n /^x\s*/
|
||||||
|
silent! %s/\(x\s*\d\{4}\)\(\d\{2}\)/\1-\2-/g
|
||||||
|
else
|
||||||
|
sort /@[a-zA-Z]*/ r
|
||||||
|
sort /+[a-zA-Z]*/ r
|
||||||
|
sort /\v\([A-Z]\)/ r
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! TodoTxtSortDue()
|
||||||
|
silent! %s/\([dD][uU][eE]:\d\{4}\)-\(\d\{2}\)-\(\d\{2}\)/\1\2\3/g
|
||||||
|
" Sort adding entries with due dates add the beginning
|
||||||
|
sort n /[dD][uU][eE]:/
|
||||||
|
" Count the number of lines
|
||||||
|
silent normal gg
|
||||||
|
execute "/[dD][uU][eE]:"
|
||||||
|
let l:first=getpos(".")[1]
|
||||||
|
silent normal N
|
||||||
|
let l:last=getpos(".")[1]
|
||||||
|
let l:diff=l:last-l:first+1
|
||||||
|
" Put the sorted lines at the beginning of the file
|
||||||
|
execute ':'.l:first
|
||||||
|
execute ':d'.l:diff
|
||||||
|
silent normal gg
|
||||||
|
silent normal P
|
||||||
|
silent! %s/\([dD][uU][eE]:\d\{4}\)\(\d\{2}\)/\1-\2-/g
|
||||||
" TODO: add time sorting (YYYY-MM-DD HH:MM)
|
" TODO: add time sorting (YYYY-MM-DD HH:MM)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -182,6 +213,14 @@ if !hasmapto("date<Tab>",'i')
|
|||||||
if !hasmapto("date<Tab>",'i')
|
if !hasmapto("date<Tab>",'i')
|
||||||
inoremap <script> <silent> <buffer> date<Tab> <C-R>=strftime("%Y-%m-%d")<CR>
|
inoremap <script> <silent> <buffer> date<Tab> <C-R>=strftime("%Y-%m-%d")<CR>
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if !hasmapto("due:",'i')
|
||||||
|
inoremap <script> <silent> <buffer> due: due:<C-R>=strftime("%Y-%m-%d")<CR>
|
||||||
|
endif
|
||||||
|
|
||||||
|
if !hasmapto("DUE:",'i')
|
||||||
|
inoremap <script> <silent> <buffer> DUE: DUE:<C-R>=strftime("%Y-%m-%d")<CR>
|
||||||
|
endif
|
||||||
|
|
||||||
if !hasmapto("<localleader>d",'n')
|
if !hasmapto("<localleader>d",'n')
|
||||||
nnoremap <script> <silent> <buffer> <localleader>d :call TodoTxtPrependDate()<CR>
|
nnoremap <script> <silent> <buffer> <localleader>d :call TodoTxtPrependDate()<CR>
|
||||||
@@ -209,6 +248,11 @@ if !hasmapto("<localleader>D",'n')
|
|||||||
if !hasmapto("<localleader>D",'n')
|
if !hasmapto("<localleader>D",'n')
|
||||||
nnoremap <script> <silent> <buffer> <localleader>D :call TodoTxtRemoveCompleted()<CR>
|
nnoremap <script> <silent> <buffer> <localleader>D :call TodoTxtRemoveCompleted()<CR>
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" Sort by due: date {{{2
|
||||||
|
if !hasmapto("<localleader>sd".'n')
|
||||||
|
nnoremap <script> <silent> <buffer> <localleader>sd :call TodoTxtSortDue()<CR>
|
||||||
|
endif
|
||||||
|
|
||||||
" Folding {{{1
|
" Folding {{{1
|
||||||
" Options {{{2
|
" Options {{{2
|
||||||
@@ -237,6 +281,24 @@ function! TodoFoldText()
|
|||||||
\ . (v:foldend - v:foldstart + 1)
|
\ . (v:foldend - v:foldstart + 1)
|
||||||
\ . ' Completed tasks '
|
\ . ' Completed tasks '
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Simple keyword completion on all buffers
|
||||||
|
function! TodoKeywordComplete(base)
|
||||||
|
" Search for matchs
|
||||||
|
let res = []
|
||||||
|
for bufnr in range(1,bufnr('$'))
|
||||||
|
let lines=getbufline(bufnr,1,"$")
|
||||||
|
for line in lines
|
||||||
|
if line =~ a:base
|
||||||
|
" init temporary item
|
||||||
|
let item={}
|
||||||
|
let item.word=substitute(line,'.*\('.a:base.'\S*\).*','\1',"")
|
||||||
|
call add(res,item)
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endfor
|
||||||
|
return res
|
||||||
|
endfunction
|
||||||
|
|
||||||
" Intelligent completion for projects and Contexts
|
" Intelligent completion for projects and Contexts
|
||||||
fun! TodoComplete(findstart, base)
|
fun! TodoComplete(findstart, base)
|
||||||
@@ -247,6 +309,9 @@ fun! TodoComplete(findstart, base)
|
|||||||
let start -= 1
|
let start -= 1
|
||||||
endwhile
|
endwhile
|
||||||
return start
|
return start
|
||||||
|
else
|
||||||
|
if a:base !~ '^+' && a:base !~ '^@'
|
||||||
|
return TodoKeywordComplete(a:base)
|
||||||
endif
|
endif
|
||||||
" Opposite sign
|
" Opposite sign
|
||||||
let opp=a:base=~'+'?'@':'+'
|
let opp=a:base=~'+'?'@':'+'
|
||||||
@@ -267,6 +332,7 @@ fun! TodoComplete(findstart, base)
|
|||||||
endfor
|
endfor
|
||||||
call sort(res)
|
call sort(res)
|
||||||
" Here all results are sorted in res, but we need to merge them
|
" Here all results are sorted in res, but we need to merge them
|
||||||
|
let ret=[]
|
||||||
if res != []
|
if res != []
|
||||||
let curitem={}
|
let curitem={}
|
||||||
let curitem.word=res[0].word
|
let curitem.word=res[0].word
|
||||||
@@ -294,6 +360,7 @@ fun! TodoComplete(findstart, base)
|
|||||||
let curitem.related=[it.related]
|
let curitem.related=[it.related]
|
||||||
let curitem.buffers=[it.buffers]
|
let curitem.buffers=[it.buffers]
|
||||||
endif
|
endif
|
||||||
|
endfor
|
||||||
endif
|
endif
|
||||||
return ret
|
return ret
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -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.2
|
||||||
" 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
|
||||||
@@ -32,7 +32,7 @@ if !hasmapto("<localleader>sp",'n')
|
|||||||
noremap <localleader>sp :call Todo_txt_HierarchicalSort('+', '',1)<CR>
|
noremap <localleader>sp :call Todo_txt_HierarchicalSort('+', '',1)<CR>
|
||||||
endif
|
endif
|
||||||
if !hasmapto("<localleader>spc",'n')
|
if !hasmapto("<localleader>spc",'n')
|
||||||
noremap <localleader>spc :call Todo_txt_HierarchicalSort('+', '@',0)<CR>
|
noremap <localleader>spc :call Todo_txt_HierarchicalSort('+', '@',1)<CR>
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" This is a Hierarchical sort designed for todo.txt todo lists, however it
|
" This is a Hierarchical sort designed for todo.txt todo lists, however it
|
||||||
@@ -63,42 +63,39 @@ function! Todo_txt_HierarchicalSort(symbol, symbolsub, dolastsort)
|
|||||||
let l:linecount=str2nr(split(v:statusmsg)[7])
|
let l:linecount=str2nr(split(v:statusmsg)[7])
|
||||||
|
|
||||||
" Get all the groups names
|
" Get all the groups names
|
||||||
let l:groups=GetGroups(a:symbol,0,l:linecount)
|
let l:groups=GetGroups(a:symbol,1,l:linecount)
|
||||||
|
|
||||||
" Sort by groups
|
" Sort by groups
|
||||||
execute 'sort'.l:sortmode.' /.\{-}\ze'.a:symbol.'/'
|
execute 'sort'.l:sortmode.' /.\{-}\ze'.a:symbol.'/'
|
||||||
for l:g in l:groups
|
for l:g in l:groups
|
||||||
|
let l:pat=a:symbol.l:g.'.*$'
|
||||||
|
normal gg
|
||||||
" Find the beginning of the group
|
" Find the beginning of the group
|
||||||
execute '/'.a:symbol.l:g.'.*$'
|
let l:groupBegin=search(l:pat,'c')
|
||||||
let l:groupBegin=getpos(".")[1]
|
|
||||||
" Find the end of the group
|
" Find the end of the group
|
||||||
silent normal N
|
let l:groupEnd=search(l:pat,'b')
|
||||||
let l:groupEnd=getpos(".")[1]
|
|
||||||
|
|
||||||
" I'm too lazy to sort one groups of one line
|
" I'm too lazy to sort groups of one line
|
||||||
if(l:groupEnd==l:groupBegin)
|
if(l:groupEnd==l:groupBegin)
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
if a:dolastsort
|
||||||
if( a:symbolsub!='')
|
if( a:symbolsub!='')
|
||||||
" Sort by subgroups
|
" Sort by subgroups
|
||||||
let l:subgroups=GetGroups(a:symbolsub,l:groupBegin,l:groupEnd)
|
let l:subgroups=GetGroups(a:symbolsub,l:groupBegin,l:groupEnd)
|
||||||
" Go before the first line of the group
|
" Go before the first line of the group
|
||||||
" Sort the group using the second symbol
|
" Sort the group using the second symbol
|
||||||
for l:sg in l:subgroups
|
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
|
" 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=search(l:pat,'c')
|
||||||
let l:subgroupBegin=getpos(".")[1]
|
|
||||||
" Find the end of the subgroup
|
" Find the end of the subgroup
|
||||||
silent normal N
|
let l:subgroupEnd=search(l:pat,'b')
|
||||||
let l:subgroupEnd=getpos(".")[1]
|
|
||||||
" Sort by priority
|
" Sort by priority
|
||||||
if a:dolastsort
|
|
||||||
execute l:subgroupBegin.','.l:subgroupEnd.'sort'.l:sortmodefinal
|
execute l:subgroupBegin.','.l:subgroupEnd.'sort'.l:sortmodefinal
|
||||||
endif
|
|
||||||
endfor
|
endfor
|
||||||
else
|
else
|
||||||
" Sort by priority
|
" Sort by priority
|
||||||
if a:dolastsort
|
|
||||||
execute l:groupBegin.','.l:groupEnd.'sort'.l:sortmodefinal
|
execute l:groupBegin.','.l:groupEnd.'sort'.l:sortmodefinal
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -1,46 +1,48 @@
|
|||||||
" File: todo.txt.vim
|
" File: todo.txt.vim
|
||||||
" Description: Todo.txt syntax settings
|
" Description: Todo.txt syntax settings
|
||||||
" Author: Leandro Freitas <freitass@gmail.com>, David Beniamine <David@Beniamine.net>
|
" Author: David Beniamine <David@Beniamine.net>,Leandro Freitas <freitass@gmail.com>
|
||||||
" License: Vim license
|
" License: Vim license
|
||||||
" Website: http://github.com/dbeniamine/todo.txt-vim
|
" Website: http://github.com/dbeniamine/todo.txt-vim
|
||||||
" Version: 0.6
|
" Version: 0.7.2
|
||||||
|
|
||||||
if exists("b:current_syntax")
|
if exists("b:current_syntax")
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
syntax match TodoDone '^[xX]\s.\+$' contains=TodoDate,TodoProject,TodoContext
|
syntax match TodoDone '^[xX]\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||||
syntax match TodoPriorityA '^([aA])\s.\+$' contains=TodoDate,TodoProject,TodoContext
|
syntax match TodoPriorityA '^([aA])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||||
syntax match TodoPriorityB '^([bB])\s.\+$' contains=TodoDate,TodoProject,TodoContext
|
syntax match TodoPriorityB '^([bB])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||||
syntax match TodoPriorityC '^([cC])\s.\+$' contains=TodoDate,TodoProject,TodoContext
|
syntax match TodoPriorityC '^([cC])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||||
syntax match TodoPriorityD '^([dD])\s.\+$' contains=TodoDate,TodoProject,TodoContext
|
syntax match TodoPriorityD '^([dD])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||||
syntax match TodoPriorityE '^([eE])\s.\+$' contains=TodoDate,TodoProject,TodoContext
|
syntax match TodoPriorityE '^([eE])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||||
syntax match TodoPriorityF '^([fF])\s.\+$' contains=TodoDate,TodoProject,TodoContext
|
syntax match TodoPriorityF '^([fF])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||||
syntax match TodoPriorityG '^([gG])\s.\+$' contains=TodoDate,TodoProject,TodoContext
|
syntax match TodoPriorityG '^([gG])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||||
syntax match TodoPriorityH '^([hH])\s.\+$' contains=TodoDate,TodoProject,TodoContext
|
syntax match TodoPriorityH '^([hH])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||||
syntax match TodoPriorityI '^([iI])\s.\+$' contains=TodoDate,TodoProject,TodoContext
|
syntax match TodoPriorityI '^([iI])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||||
syntax match TodoPriorityJ '^([jJ])\s.\+$' contains=TodoDate,TodoProject,TodoContext
|
syntax match TodoPriorityJ '^([jJ])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||||
syntax match TodoPriorityK '^([kK])\s.\+$' contains=TodoDate,TodoProject,TodoContext
|
syntax match TodoPriorityK '^([kK])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||||
syntax match TodoPriorityL '^([lL])\s.\+$' contains=TodoDate,TodoProject,TodoContext
|
syntax match TodoPriorityL '^([lL])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||||
syntax match TodoPriorityM '^([mM])\s.\+$' contains=TodoDate,TodoProject,TodoContext
|
syntax match TodoPriorityM '^([mM])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||||
syntax match TodoPriorityN '^([nN])\s.\+$' contains=TodoDate,TodoProject,TodoContext
|
syntax match TodoPriorityN '^([nN])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||||
syntax match TodoPriorityO '^([oO])\s.\+$' contains=TodoDate,TodoProject,TodoContext
|
syntax match TodoPriorityO '^([oO])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||||
syntax match TodoPriorityP '^([pP])\s.\+$' contains=TodoDate,TodoProject,TodoContext
|
syntax match TodoPriorityP '^([pP])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||||
syntax match TodoPriorityQ '^([qQ])\s.\+$' contains=TodoDate,TodoProject,TodoContext
|
syntax match TodoPriorityQ '^([qQ])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||||
syntax match TodoPriorityR '^([rR])\s.\+$' contains=TodoDate,TodoProject,TodoContext
|
syntax match TodoPriorityR '^([rR])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||||
syntax match TodoPriorityS '^([sS])\s.\+$' contains=TodoDate,TodoProject,TodoContext
|
syntax match TodoPriorityS '^([sS])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||||
syntax match TodoPriorityT '^([tT])\s.\+$' contains=TodoDate,TodoProject,TodoContext
|
syntax match TodoPriorityT '^([tT])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||||
syntax match TodoPriorityU '^([uU])\s.\+$' contains=TodoDate,TodoProject,TodoContext
|
syntax match TodoPriorityU '^([uU])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||||
syntax match TodoPriorityV '^([vV])\s.\+$' contains=TodoDate,TodoProject,TodoContext
|
syntax match TodoPriorityV '^([vV])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||||
syntax match TodoPriorityW '^([wW])\s.\+$' contains=TodoDate,TodoProject,TodoContext
|
syntax match TodoPriorityW '^([wW])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||||
syntax match TodoPriorityX '^([xX])\s.\+$' contains=TodoDate,TodoProject,TodoContext
|
syntax match TodoPriorityX '^([xX])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||||
syntax match TodoPriorityY '^([yY])\s.\+$' contains=TodoDate,TodoProject,TodoContext
|
syntax match TodoPriorityY '^([yY])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||||
syntax match TodoPriorityZ '^([zZ])\s.\+$' contains=TodoDate,TodoProject,TodoContext
|
syntax match TodoPriorityZ '^([zZ])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||||
syntax match TodoDate '\d\{2,4\}-\d\{2\}-\d\{2\}' contains=NONE
|
syntax match TodoDate '\d\{2,4\}-\d\{2\}-\d\{2\}' contains=NONE
|
||||||
|
syntax match TodoKey '\S*\S:\S\S*' contains=TodoDate
|
||||||
syntax match TodoProject '\(^\|\W\)+[^[:blank:]]\+' contains=NONE
|
syntax match TodoProject '\(^\|\W\)+[^[:blank:]]\+' contains=NONE
|
||||||
syntax match TodoContext '\(^\|\W\)@[^[:blank:]]\+' contains=NONE
|
syntax match TodoContext '\(^\|\W\)@[^[:blank:]]\+' contains=NONE
|
||||||
|
|
||||||
" Other priority colours might be defined by the user
|
" Other priority colours might be defined by the user
|
||||||
|
highlight default link TodoKey Special
|
||||||
highlight default link TodoDone Comment
|
highlight default link TodoDone Comment
|
||||||
highlight default link TodoPriorityA Identifier
|
highlight default link TodoPriorityA Identifier
|
||||||
highlight default link TodoPriorityB statement
|
highlight default link TodoPriorityB statement
|
||||||
|
|||||||
Reference in New Issue
Block a user