2 Commits
v0.7 ... v0.7.1

Author SHA1 Message Date
David Beniamine
4da3c4ae12 Small bug fixes
FIX: Typo in sort function
FIX: Keyword completion
CHG: Sort done.txt by completion date
2015-07-05 16:41:58 +02:00
David Beniamine
e7dee69733 fix bad links in readme 2015-07-05 15:06:03 +02:00
3 changed files with 38 additions and 8 deletions

View File

@@ -4,8 +4,8 @@
This plugin is a fork of [freitass This plugin is a fork of [freitass
todo.txt](https://github.com/freitass/todo.txt-vim). It add severals functionalities including a [hierarchical sort](#sort), a todo.txt](https://github.com/freitass/todo.txt-vim). It add severals functionalities including a [hierarchical sort](#sort), a
[complete](#complete) function, some stuff to handle [due dates](#due_dates) [complete](#completion) function, some stuff to handle [due dates](#due-dates)
and others stuff see [new features](#new_features). and others stuff see [new features](#new-features).
Freitass announced on october 30th 2014 that he is not going to merge his version. Freitass announced on october 30th 2014 that he is not going to merge his version.
@@ -95,7 +95,7 @@ adding the next lines to your vimrc:
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.
@@ -125,3 +125,6 @@ sorted by at the beginning of the file, the rest of the file is not modified.
`<LocalLeader>x` is a toggle which allow you to unmark a task as done. `<LocalLeader>x` is a toggle which allow you to unmark a task as done.
Syntax highlighting for couples key:value Syntax highlighting for couples key:value
If the current buffer is a done.txt file, the basic sort sorts on completion
date.

View File

@@ -86,7 +86,7 @@ COMPLETION *todo-complete*
The TodoComplete function is designed to complete projects (starting by '+') The TodoComplete function is designed to complete projects (starting by '+')
and context (starting by '@'). If you use it on a regular word, it will do a and context (starting by '@'). If you use it on a regular word, it will do a
normal buffer completion. normal keyword completion (on all buffers).
If you try to complete a project, it will propose all projects in all open If you try to complete a project, it will propose all projects in all open
buffers and for each of them, it will show their context and the name of the buffers and for each of them, it will show their context and the name of the
buffers in which they appears in the preview window. buffers in which they appears in the preview window.

View File

@@ -3,7 +3,7 @@
" Author: David Beniamine <David@Beniamine.net>, 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.7 " Version: 0.7.1
" Save context {{{1 " Save context {{{1
let s:save_cpo = &cpo let s:save_cpo = &cpo
@@ -79,9 +79,15 @@ 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'
ssort /+[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 endif
endfunction endfunction
@@ -269,6 +275,24 @@ function! TodoFoldText()
\ . (v:foldend - v:foldstart + 1) \ . (v:foldend - v:foldstart + 1)
\ . ' Completed tasks ' \ . ' Completed tasks '
endfunction endfunction
" Simple keyword completion on all buffers
function! TodoKeywordComplete(base)
" Search for matchs
let res = []
for bufnr in range(1,bufnr('$'))
let lines=getbufline(bufnr,1,"$")
for line in lines
if line =~ a:base
" init temporary item
let item={}
let item.word=substitute(line,'.*\('.a:base.'\S*\).*','\1',"")
call add(res,item)
endif
endfor
endfor
return res
endfunction
" Intelligent completion for projects and Contexts " Intelligent completion for projects and Contexts
fun! TodoComplete(findstart, base) fun! TodoComplete(findstart, base)
@@ -279,6 +303,9 @@ fun! TodoComplete(findstart, base)
let start -= 1 let start -= 1
endwhile endwhile
return start return start
else
if a:base !~ '^+' && a:base !~ '^@'
return TodoKeywordComplete(a:base)
endif endif
" Opposite sign " Opposite sign
let opp=a:base=~'+'?'@':'+' let opp=a:base=~'+'?'@':'+'