Compare commits
94 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35810c388d | ||
|
|
311761e327 | ||
|
|
71505569c0 | ||
|
|
6d1d2d035a | ||
|
|
491c3c7fba | ||
|
|
70b05c2c76 | ||
|
|
a778ef5590 | ||
|
|
03fe8bb167 | ||
|
|
aa618973e2 | ||
|
|
7b9c9815a4 | ||
|
|
57d45200c8 | ||
|
|
484c12771e | ||
|
|
f77215ca80 | ||
|
|
849a7d5f61 | ||
|
|
0e2b110903 | ||
|
|
aad48b0231 | ||
|
|
81e64682d0 | ||
|
|
303ab65237 | ||
|
|
c2eb67f1a6 | ||
|
|
85c215b4cc | ||
|
|
3e3251f8b5 | ||
|
|
0863e1434e | ||
|
|
ca8ae307d3 | ||
|
|
95d97151c5 | ||
|
|
1cdb39032f | ||
|
|
f3c5e7b892 | ||
|
|
1e3a5e58ae | ||
|
|
89570cbaef | ||
|
|
a21fd1198c | ||
|
|
7515fde8ae | ||
|
|
4548961329 | ||
|
|
8dd24d0b68 | ||
|
|
e2a02d4f30 | ||
|
|
595fc0b49e | ||
|
|
a612ebeaf1 | ||
|
|
17a2345675 | ||
|
|
e13eb4bb9c | ||
|
|
d769f12710 | ||
|
|
2535cf2ece | ||
|
|
eb7f7cb8f4 | ||
|
|
87a6c371dd | ||
|
|
29a6ea4b1d | ||
|
|
03501dfe42 | ||
|
|
fc0b4c3272 | ||
|
|
b87c7dd98d | ||
|
|
7232106f45 | ||
|
|
6e1bcc0e1a | ||
|
|
03f5575363 | ||
|
|
2e2d39daee | ||
|
|
a03d01e58e | ||
|
|
81c2772905 | ||
|
|
b6d5dc6bb9 | ||
|
|
f9a007ac58 | ||
|
|
45bfb325ae | ||
|
|
081d9d2e3a | ||
|
|
4d819f888b | ||
|
|
b3d9e18b08 | ||
|
|
a98711da91 | ||
|
|
0a917143c5 | ||
|
|
cc281c47eb | ||
|
|
c13a277e2a | ||
|
|
421916b25d | ||
|
|
8da977113b | ||
|
|
2a04312e8d | ||
|
|
85b2e86b73 | ||
|
|
1e465dd931 | ||
|
|
79e4d352a2 | ||
|
|
ddbcdd823f | ||
|
|
77cfafb9f0 | ||
|
|
fbc45c5c8c | ||
|
|
6c5a37e6c6 | ||
|
|
25a63d5ecd | ||
|
|
04210abd70 | ||
|
|
649f962211 | ||
|
|
b1ed8608d1 | ||
|
|
f30ac979a1 | ||
|
|
40faa56012 | ||
|
|
51c821b5da | ||
|
|
6c073cdb42 | ||
|
|
e508140f90 | ||
|
|
d0080e66f9 | ||
|
|
e071156b8d | ||
|
|
1f8b706d8e | ||
|
|
0e3c5cb2b6 | ||
|
|
32188000f9 | ||
|
|
1cc11c56ad | ||
|
|
639fcd85a2 | ||
|
|
b8a5bd64ca | ||
|
|
95ed508741 | ||
|
|
05b5be07d2 | ||
|
|
08fcb4ccdb | ||
|
|
e817f5eca8 | ||
|
|
2d83ed8dc2 | ||
|
|
52e1527e9b |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
*.swp
|
||||
doc/tags
|
||||
*.pyc
|
||||
|
||||
@@ -28,8 +28,26 @@
|
||||
|
||||
## Release notes
|
||||
|
||||
Since v0.7.3, `TodoComplete` is replaced by `todo#Complete`, you might need to
|
||||
update your vimrc (see [completion](#completion)).
|
||||
+ 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
|
||||
|
||||
@@ -132,8 +150,8 @@ like this behavior, you can set the default done.txt name:
|
||||
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
|
||||
" 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:
|
||||
@@ -145,7 +163,7 @@ adding the next lines to your vimrc:
|
||||
au filetype todo imap <buffer> @ @<C-X><C-O>
|
||||
|
||||
|
||||
The `todo#complete` function is designed to complete projects (starting by `+`)
|
||||
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).
|
||||
|
||||
@@ -196,7 +214,7 @@ prevent this behavior, add the following line to your vimrc
|
||||
+ `<LocalLeader>s` : Sort the file by priority
|
||||
+ `<LocalLeader>s+` : Sort the file on `+Projects`
|
||||
+ `<LocalLeader>s@` : Sort the file on `@Contexts`
|
||||
+ `<LocalLeader>s@` : Sort the file on due dates
|
||||
+ `<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
|
||||
@@ -204,6 +222,19 @@ prevent this behavior, add the following line to your vimrc
|
||||
+ `<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
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
" Author: David Beniamine <david@beniamine.net>
|
||||
" Licence: Vim licence
|
||||
" Website: http://github.com/dbeniamine/todo.txt.vim
|
||||
" Version: 0.7.3
|
||||
" vim: ts=4 sw=4 :help tw=78 cc=80
|
||||
|
||||
" These two variables are parameters for the successive calls the vim sort
|
||||
@@ -23,6 +22,14 @@ 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
|
||||
|
||||
@@ -35,7 +42,7 @@ function! todo#PrioritizeDecrease()
|
||||
endfunction
|
||||
|
||||
function! todo#PrioritizeAdd (priority)
|
||||
let oldpos=getcurpos()
|
||||
let oldpos=todo#GetCurpos()
|
||||
let line=getline('.')
|
||||
if line !~ '^([A-F])'
|
||||
:call todo#PrioritizeAddAction(a:priority)
|
||||
@@ -55,7 +62,11 @@ function! todo#RemovePriority()
|
||||
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
|
||||
|
||||
@@ -130,29 +141,76 @@ function! todo#Sort()
|
||||
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 /+[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()
|
||||
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]
|
||||
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
|
||||
execute ':'.l:first
|
||||
execute ':d'.l:diff
|
||||
silent normal gg
|
||||
silent normal P
|
||||
" 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
|
||||
@@ -179,16 +237,28 @@ function! todo#HierarchicalSort(symbol, symbolsub, dolastsort)
|
||||
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>"
|
||||
" 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
|
||||
@@ -217,6 +287,9 @@ function! todo#HierarchicalSort(symbol, symbolsub, dolastsort)
|
||||
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
|
||||
@@ -231,7 +304,7 @@ function! GetGroups(symbol,begin, end)
|
||||
function! GetGroups(symbol,begin, end)
|
||||
let l:curline=a:begin
|
||||
let l:groups=[]
|
||||
while l:curline <= a:end
|
||||
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)
|
||||
@@ -254,7 +327,7 @@ endfunction
|
||||
" Completion {{{1
|
||||
|
||||
" Simple keyword completion on all buffers {{{2
|
||||
function! TodoKeywordComplete(base)
|
||||
function! TodoKeywordComplete(base)
|
||||
" Search for matches
|
||||
let res = []
|
||||
for bufnr in range(1,bufnr('$'))
|
||||
@@ -270,6 +343,25 @@ function! TodoKeywordComplete(base)
|
||||
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)
|
||||
@@ -290,7 +382,7 @@ fun! todo#Complete(findstart, base)
|
||||
let res = []
|
||||
for bufnr in range(1,bufnr('$'))
|
||||
let lines=getbufline(bufnr,1,"$")
|
||||
for line in lines
|
||||
for line in lines
|
||||
if line =~ " ".a:base
|
||||
" init temporary item
|
||||
let item={}
|
||||
@@ -304,10 +396,7 @@ fun! todo#Complete(findstart, base)
|
||||
call sort(res)
|
||||
" Here all results are sorted in res, but we need to merge them
|
||||
let ret=[]
|
||||
if res != []
|
||||
let curitem={}
|
||||
let curitem.word=res[0].word
|
||||
let curitem.related=[]
|
||||
if res != []
|
||||
let curitem=TodoCopyTempItem(res[0])
|
||||
for it in res
|
||||
if curitem.word==it.word
|
||||
@@ -318,19 +407,14 @@ fun! todo#Complete(findstart, base)
|
||||
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, ", ")
|
||||
else
|
||||
" Add to list
|
||||
call TodoAddToCompletionList(ret,curitem,opp)
|
||||
" Init new item from it
|
||||
let curitem.word=it.word
|
||||
let curitem.related=[it.related]
|
||||
" 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
|
||||
|
||||
123
autoload/todo/txt.vim
Normal file
123
autoload/todo/txt.vim
Normal 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
|
||||
34
doc/todo.txt
34
doc/todo.txt
@@ -31,6 +31,25 @@ Table of Contents *TodoTxt-Contents* ~
|
||||
===============================================================================
|
||||
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|).
|
||||
|
||||
@@ -205,7 +224,7 @@ prevent this behavior, add the following line to your vimrc
|
||||
|
||||
`<LocalLeader>s@` : Sort the file on @Contexts
|
||||
|
||||
`<LocalLeader>s@` : Sort the file on due dates
|
||||
`<LocalLeader>sd` : Sort the file on due dates
|
||||
|
||||
`<LocalLeader>sc` : Sort the file by context then by priority
|
||||
|
||||
@@ -218,6 +237,19 @@ prevent this behavior, add the following line to your vimrc
|
||||
`<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
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
" Author: David Beniamine <david@beniamine.net>, Leandro Freitas <freitass@gmail.com>
|
||||
" License: Vim license
|
||||
" Website: http://github.com/dbeniamine/todo.txt-vim
|
||||
" Version: 0.7.2
|
||||
" vim: ts=4 sw=4 :help tw=78 cc=80
|
||||
|
||||
autocmd BufNewFile,BufRead [Tt]odo.txt set filetype=todo
|
||||
autocmd BufNewFile,BufRead [Tt]odo-\d\\\{4\}-\d\\\{2\}-\d\\\{2\}.txt set filetype=todo
|
||||
|
||||
@@ -3,13 +3,18 @@
|
||||
" Author: David Beniamine <David@Beniamine.net>, Leandro Freitas <freitass@gmail.com>
|
||||
" License: Vim license
|
||||
" Website: http://github.com/dbeniamine/todo.txt-vim
|
||||
" Version: 0.7.2
|
||||
" vim: ts=4 sw=4 :help tw=78 cc=80
|
||||
|
||||
" Save context {{{1
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
if exists("g:Todo_txt_loaded")
|
||||
finish
|
||||
else
|
||||
let g:Todo_txt_loaded=0.8.1
|
||||
endif
|
||||
|
||||
" General options {{{1
|
||||
" 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
|
||||
@@ -49,12 +54,15 @@ if !exists("g:Todo_txt_do_not_map")
|
||||
noremap <script> <silent> <buffer> <localleader>d :call todo#PrependDate()<CR>
|
||||
|
||||
" Mark done {{{2
|
||||
noremap <script> <silent> <buffer> <localleader>x :call todo#ToggleMarkAsDone('')<CR>
|
||||
noremap <script> <silent> <buffer> <Plug>DoToggleMarkAsDone :call todo#ToggleMarkAsDone('')<CR>
|
||||
\:call repeat#set("\<Plug>DoToggleMarkAsDone")<CR>
|
||||
nmap <localleader>x <Plug>DoToggleMarkAsDone
|
||||
" noremap <script> <silent> <buffer> <localleader>x :call todo#ToggleMarkAsDone('')<CR>
|
||||
|
||||
" Mark done {{{2
|
||||
noremap <script> <silent> <buffer> <localleader>C :call todo#ToggleMarkAsDone('Cancelled')<CR>
|
||||
|
||||
|
||||
noremap <script> <silent> <buffer> <Plug>DoCancel :call todo#ToggleMarkAsDone('Cancelled')<CR>
|
||||
\:call repeat#set("\<Plug>DoCancel")<CR>
|
||||
nmap <localleader>C <Plug>DoCancel
|
||||
|
||||
" Mark all done {{{2
|
||||
noremap <script> <silent> <buffer> <localleader>X :call todo#MarkAllAsDone()<CR>
|
||||
@@ -96,4 +104,3 @@ endfunction
|
||||
|
||||
" Restore context {{{1
|
||||
let &cpo = s:save_cpo
|
||||
" Modeline {{{1
|
||||
|
||||
179
syntax/todo.vim
179
syntax/todo.vim
@@ -3,44 +3,49 @@
|
||||
" Author: David Beniamine <David@Beniamine.net>,Leandro Freitas <freitass@gmail.com>
|
||||
" License: Vim license
|
||||
" Website: http://github.com/dbeniamine/todo.txt-vim
|
||||
" Version: 0.7.2
|
||||
" vim: ts=4 sw=4 :help tw=78 cc=80
|
||||
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
syntax match TodoDone '^[xX]\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||
syntax match TodoPriorityA '^([aA])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||
syntax match TodoPriorityB '^([bB])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||
syntax match TodoPriorityC '^([cC])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||
syntax match TodoPriorityD '^([dD])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||
syntax match TodoPriorityE '^([eE])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||
syntax match TodoPriorityF '^([fF])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||
syntax match TodoPriorityG '^([gG])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||
syntax match TodoPriorityH '^([hH])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||
syntax match TodoPriorityI '^([iI])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||
syntax match TodoPriorityJ '^([jJ])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||
syntax match TodoPriorityK '^([kK])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||
syntax match TodoPriorityL '^([lL])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||
syntax match TodoPriorityM '^([mM])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||
syntax match TodoPriorityN '^([nN])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||
syntax match TodoPriorityO '^([oO])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||
syntax match TodoPriorityP '^([pP])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||
syntax match TodoPriorityQ '^([qQ])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||
syntax match TodoPriorityR '^([rR])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||
syntax match TodoPriorityS '^([sS])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||
syntax match TodoPriorityT '^([tT])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||
syntax match TodoPriorityU '^([uU])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||
syntax match TodoPriorityV '^([vV])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||
syntax match TodoPriorityW '^([wW])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||
syntax match TodoPriorityX '^([xX])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||
syntax match TodoPriorityY '^([yY])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||
syntax match TodoPriorityZ '^([zZ])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext
|
||||
syntax match TodoPriorityA '^([aA])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
|
||||
syntax match TodoPriorityB '^([bB])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
|
||||
syntax match TodoPriorityC '^([cC])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
|
||||
syntax match TodoPriorityD '^([dD])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
|
||||
syntax match TodoPriorityE '^([eE])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
|
||||
syntax match TodoPriorityF '^([fF])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
|
||||
syntax match TodoPriorityG '^([gG])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
|
||||
syntax match TodoPriorityH '^([hH])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
|
||||
syntax match TodoPriorityI '^([iI])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
|
||||
syntax match TodoPriorityJ '^([jJ])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
|
||||
syntax match TodoPriorityK '^([kK])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
|
||||
syntax match TodoPriorityL '^([lL])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
|
||||
syntax match TodoPriorityM '^([mM])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
|
||||
syntax match TodoPriorityN '^([nN])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
|
||||
syntax match TodoPriorityO '^([oO])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
|
||||
syntax match TodoPriorityP '^([pP])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
|
||||
syntax match TodoPriorityQ '^([qQ])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
|
||||
syntax match TodoPriorityR '^([rR])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
|
||||
syntax match TodoPriorityS '^([sS])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
|
||||
syntax match TodoPriorityT '^([tT])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
|
||||
syntax match TodoPriorityU '^([uU])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
|
||||
syntax match TodoPriorityV '^([vV])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
|
||||
syntax match TodoPriorityW '^([wW])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
|
||||
syntax match TodoPriorityX '^([xX])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
|
||||
syntax match TodoPriorityY '^([yY])\s.\+$' contains=TodoKey,TodoDate,TodoProject,TodoContext,TodoDueToday,TodoOverDueDate
|
||||
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 TodoKey '\S*\S:\S\S*' contains=TodoDate
|
||||
syntax match TodoProject '\(^\|\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
|
||||
highlight default link TodoKey Special
|
||||
highlight default link TodoDone Comment
|
||||
@@ -50,5 +55,125 @@ highlight default link TodoPriorityC type
|
||||
highlight default link TodoDate PreProc
|
||||
highlight default link TodoProject 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"
|
||||
|
||||
Reference in New Issue
Block a user