Merge branch 'master' of https://github.com/freitass/todo.txt-vim
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:
@@ -20,11 +20,24 @@ a nice two level sorting function designed for todo.txt files (see section
|
||||
|
||||
## 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 edition of 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:
|
||||
|
||||
`<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
|
||||
|
||||
`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>-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
|
||||
|
||||
## New features
|
||||
|
||||
13
Todo.txt
13
Todo.txt
@@ -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
|
||||
17
doc/todo.txt
17
doc/todo.txt
@@ -5,6 +5,10 @@ COMMANDS *todo-commands*
|
||||
|
||||
`<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>-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>-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
|
||||
@@ -22,7 +36,7 @@ COMMANDS *todo-commands*
|
||||
|
||||
`<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
|
||||
|
||||
@@ -40,4 +54,5 @@ Defaults values are:
|
||||
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
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
" File: todo.txt.vim
|
||||
" Description: Todo.txt filetype detection
|
||||
" Author: Leandro Freitas <freitass@gmail.com>
|
||||
" Licence: Vim licence
|
||||
" Website: http://github.com/freitass/todo.txt.vim
|
||||
" License: Vim license
|
||||
" Website: http://github.com/freitass/todo.txt-vim
|
||||
" Version: 0.1
|
||||
|
||||
autocmd BufNewFile,BufRead [Tt]odo.txt set filetype=todo
|
||||
autocmd BufNewFile,BufRead [Dd]one.txt set filetype=todo
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
" File: todo.txt.vim
|
||||
" Description: Todo.txt filetype detection
|
||||
" Author: Leandro Freitas <freitass@gmail.com>
|
||||
" Licence: Vim licence
|
||||
" Website: http://github.com/freitass/todo.txt.vim
|
||||
" License: Vim license
|
||||
" Website: http://github.com/freitass/todo.txt-vim
|
||||
" Version: 0.4
|
||||
|
||||
" Save context {{{1
|
||||
@@ -16,7 +16,7 @@ set cpo&vim
|
||||
setlocal textwidth=0
|
||||
setlocal wrapmargin=0
|
||||
|
||||
" Functions {{{!
|
||||
" Functions {{{1
|
||||
function! s:TodoTxtRemovePriority()
|
||||
:s/^(\w)\s\+//ge
|
||||
endfunction
|
||||
@@ -47,8 +47,33 @@ function! TodoTxtMarkAllAsDone()
|
||||
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()
|
||||
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
|
||||
|
||||
@@ -57,6 +82,74 @@ if !hasmapto("<localleader>s",'n')
|
||||
if !hasmapto("<localleader>s",'n')
|
||||
nnoremap <script> <silent> <buffer> <localleader>s :sort<CR>
|
||||
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
|
||||
if !hasmapto("date<Tab>",'i')
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
" File: todo.txt.vim
|
||||
" Description: Todo.txt syntax settings
|
||||
" Author: Leandro Freitas <freitass@gmail.com>
|
||||
" Licence: Vim licence
|
||||
" Website: http://github.com/freitass/todo.txt.vim
|
||||
" License: Vim license
|
||||
" Website: http://github.com/freitass/todo.txt-vim
|
||||
" Version: 0.3
|
||||
|
||||
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 TodoPriorityZ '^([zZ])\s.\+$' contains=TodoDate,TodoProject,TodoContext
|
||||
syntax match TodoDate '\d\{2,4\}-\d\{2\}-\d\{2\}' contains=NONE
|
||||
syntax match TodoProject ' +[^[:blank:]]\+' contains=NONE
|
||||
syntax match TodoContext ' @[^[:blank:]]\+' contains=NONE
|
||||
syntax match TodoProject '\(^\|\W\)+[^[:blank:]]\+' contains=NONE
|
||||
syntax match TodoContext '\(^\|\W\)@[^[:blank:]]\+' contains=NONE
|
||||
|
||||
" Other priority colours might be defined by the user
|
||||
highlight default link TodoDone Comment
|
||||
|
||||
Reference in New Issue
Block a user