Add new features from freitass master such as increase/decreas priority,
another multilvel sort from @matjon and the done.txt file.

Conflicts:
	README.markdown
	doc/todo.txt
This commit is contained in:
David Beniamine
2015-02-01 20:54:07 +01:00
6 changed files with 137 additions and 28 deletions

View File

@@ -20,11 +20,24 @@ a nice two level sorting function designed for todo.txt files (see section
## 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 This plugin gives syntax highlighting to [todo.txt](http://todotxt.com/) files. It also defines a few mappings, to help with editing these files:
mappings, to help with edition of these files:
`<LocalLeader>-s` : Sort the file `<LocalLeader>-s` : Sort the file
`<LocalLeader>-s+` : Sort the file on +Projects
`<LocalLeader>-s@` : Sort the file on @Contexts
`<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 `<LocalLeader>-d` : Insert the current date
`date<tab>` : (Insert mode) Insert the current date `date<tab>` : (Insert mode) Insert the current date
@@ -33,9 +46,9 @@ mappings, to help with edition of these files:
`<LocalLeader>-X` : Mark all tasks as completed `<LocalLeader>-X` : Mark all tasks as completed
`<LocalLeader>-D` : Remove completed tasks `<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. If you want the help installed, run ":helptags ~/.vim/doc" inside vim after having copied the files.
Then you will be able to get the commands help with: :h todo.txt Then you will be able to get the commands help with: :h todo.txt
## New features ## New features

View File

@@ -1,13 +0,0 @@
(A) 2011-05-30 Map commands to add, rm, ls, pri, depri etc @ftplugin
(A) 2011-06-06 Check file syntax @syntax
(B) 2011-05-31 Start documentation @doc
(C) 2011-06-01 Improve syntax file @syntax
x 2014-04-27 2011-05-30 Contact main project for reference
x 2011-05-30 Create README.markdown to be published in github @doc
x 2011-05-30 Implement colorized priorities @syntax
x 2011-05-30 Implement filetype detection @ftdetect
x 2011-05-30 Sort lines per priority @ftplugin
x 2011-05-31 Highlight date, project and context of tasks with no priority @syntax
x 2011-05-31 Stop breaking lines automatically @ftplugin
x 2011-06-06 Easier date input @ftplugin
x 2011-06-06 Implement foldings @ftplugin

View File

@@ -5,6 +5,10 @@ COMMANDS *todo-commands*
`<LocalLeader>-s` : Sort the file by priority `<LocalLeader>-s` : Sort the file by priority
`<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>-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
@@ -13,6 +17,16 @@ 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
`<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 `<LocalLeader>-d` : Insert the current date
`date<tab>` : (Insert mode) Insert the current date `date<tab>` : (Insert mode) Insert the current date
@@ -22,7 +36,7 @@ COMMANDS *todo-commands*
`<LocalLeader>-X` : Mark all tasks as completed `<LocalLeader>-X` : Mark all tasks as completed
`<LocalLeader>-D` : Remove completed tasks `<LocalLeader>-D` : Move completed tasks to done.txt
<LocalLeader> is \ by default, so <leader>-s means you type \s <LocalLeader> is \ by default, so <leader>-s means you type \s
@@ -40,4 +54,5 @@ Defaults values are:
g:Todo_txt_first_level_sort_mode="i" g:Todo_txt_first_level_sort_mode="i"
g:Todo_txt_second_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

View File

@@ -1,9 +1,10 @@
" 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: Leandro Freitas <freitass@gmail.com>
" Licence: Vim licence " License: Vim license
" Website: http://github.com/freitass/todo.txt.vim " Website: http://github.com/freitass/todo.txt-vim
" Version: 0.1 " Version: 0.1
autocmd BufNewFile,BufRead [Tt]odo.txt set filetype=todo autocmd BufNewFile,BufRead [Tt]odo.txt set filetype=todo
autocmd BufNewFile,BufRead [Dd]one.txt set filetype=todo

View File

@@ -1,8 +1,8 @@
" 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: Leandro Freitas <freitass@gmail.com>
" Licence: Vim licence " License: Vim license
" Website: http://github.com/freitass/todo.txt.vim " Website: http://github.com/freitass/todo.txt-vim
" Version: 0.4 " Version: 0.4
" Save context {{{1 " Save context {{{1
@@ -16,7 +16,7 @@ set cpo&vim
setlocal textwidth=0 setlocal textwidth=0
setlocal wrapmargin=0 setlocal wrapmargin=0
" Functions {{{! " Functions {{{1
function! s:TodoTxtRemovePriority() function! s:TodoTxtRemovePriority()
:s/^(\w)\s\+//ge :s/^(\w)\s\+//ge
endfunction endfunction
@@ -47,8 +47,33 @@ function! TodoTxtMarkAllAsDone()
function! TodoTxtMarkAllAsDone() function! TodoTxtMarkAllAsDone()
:g!/^x /:call TodoTxtMarkAsDone() :g!/^x /:call TodoTxtMarkAsDone()
endfunction 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() 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) call s:AppendToFile(l:done_file, l:completed)
endfunction endfunction
@@ -57,6 +82,74 @@ if !hasmapto("<localleader>s",'n')
if !hasmapto("<localleader>s",'n') if !hasmapto("<localleader>s",'n')
nnoremap <script> <silent> <buffer> <localleader>s :sort<CR> nnoremap <script> <silent> <buffer> <localleader>s :sort<CR>
endif endif
if !hasmapto("<LocalLeader>s@",'n')
nnoremap <script> <silent> <buffer> <LocalLeader>s@ :sort /.\{-}\ze@/ <CR>
endif
if !hasmapto("<LocalLeader>s+",'n')
nnoremap <script> <silent> <buffer> <LocalLeader>s+ :sort /.\{-}\ze+/ <CR>
endif
" Increment and Decrement The Priority
:set nf=octal,hex,alpha
function! TodoTxtPrioritizeIncrease()
normal! 0f)h
endfunction
function! TodoTxtPrioritizeDecrease()
normal! 0f)h
endfunction
function! TodoTxtPrioritizeAdd (priority)
" Need to figure out how to only do this if the first visible letter in a line is not (
:call TodoTxtPrioritizeAddAction(a:priority)
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",'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",'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",'v')
vnoremap <script> <silent> <buffer> <LocalLeader>c :call TodoTxtPrioritizeAdd('C')<CR>
endif
" Insert date {{{2 " Insert date {{{2
if !hasmapto("date<Tab>",'i') if !hasmapto("date<Tab>",'i')

View File

@@ -1,8 +1,8 @@
" File: todo.txt.vim " File: todo.txt.vim
" Description: Todo.txt syntax settings " Description: Todo.txt syntax settings
" Author: Leandro Freitas <freitass@gmail.com> " Author: Leandro Freitas <freitass@gmail.com>
" Licence: Vim licence " License: Vim license
" Website: http://github.com/freitass/todo.txt.vim " Website: http://github.com/freitass/todo.txt-vim
" Version: 0.3 " Version: 0.3
if exists("b:current_syntax") if exists("b:current_syntax")
@@ -37,8 +37,8 @@ syntax match TodoPriorityX '^([xX])\s.\+$' contains=TodoDate,Todo
syntax match TodoPriorityY '^([yY])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityY '^([yY])\s.\+$' contains=TodoDate,TodoProject,TodoContext
syntax match TodoPriorityZ '^([zZ])\s.\+$' contains=TodoDate,TodoProject,TodoContext syntax match TodoPriorityZ '^([zZ])\s.\+$' contains=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 TodoProject ' +[^[:blank:]]\+' contains=NONE syntax match TodoProject '\(^\|\W\)+[^[:blank:]]\+' contains=NONE
syntax match TodoContext ' @[^[: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 TodoDone Comment highlight default link TodoDone Comment