From 1b49ec094c15a2a5ed5c47ef0e87967479178fb1 Mon Sep 17 00:00:00 2001 From: durcheinandr Date: Mon, 25 May 2015 23:57:26 +0200 Subject: [PATCH] here we go --- .gitignore | 2 + README.markdown | 41 +++++++++ doc/todo.txt | 32 +++++++ done.txt | 13 +++ ftdetect/todo.vim | 10 +++ ftplugin/todo.vim | 222 ++++++++++++++++++++++++++++++++++++++++++++++ syntax/todo.vim | 52 +++++++++++ todo.txt | 1 + 8 files changed, 373 insertions(+) create mode 100644 .gitignore create mode 100644 README.markdown create mode 100644 doc/todo.txt create mode 100644 done.txt create mode 100644 ftdetect/todo.vim create mode 100644 ftplugin/todo.vim create mode 100644 syntax/todo.vim create mode 100644 todo.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57e15c5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.swp +doc/tags diff --git a/README.markdown b/README.markdown new file mode 100644 index 0000000..f44c29f --- /dev/null +++ b/README.markdown @@ -0,0 +1,41 @@ +### Quick install + + git clone git://github.com/freitass/todo.txt-vim.git + cd todo.txt-vim + cp -R * ~/.vim + + +This plugin gives syntax highlighting to [todo.txt](http://todotxt.com/) files. It also defines a few mappings, to help with editing these files: + +`-s` : Sort the file + +`-s+` : Sort the file on +Projects + +`-s@` : Sort the file on @Contexts + +`-sd` : Sort @_sched entries by due-date + +`-j` : Lower the priority of the current line + +`-k` : Increase the priority of the current line + +`-a` : Add the priority (A) to the current line + +`-b` : Add the priority (B) to the current line + +`-c` : Add the priority (C) to the current line + +`-d` : Insert the current date + +`date` : (Insert mode) Insert the current date + +Removed bindings: + +`-x` : Mark task as done (inserts current date as completion date) + +`-X` : Mark all tasks as completed + +`-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 diff --git a/doc/todo.txt b/doc/todo.txt new file mode 100644 index 0000000..5a52250 --- /dev/null +++ b/doc/todo.txt @@ -0,0 +1,32 @@ +*todo.txt* + +============================================================================== +COMMANDS *todo-commands* + +`-s` : Sort the file + +`-s+` : Sort the file on +Projects + +`-s@` : Sort the file on @Contexts + +`-j` : Lower the priority of the current line + +`-k` : Increase the priority of the current line + +`-a` : Add the priority (A) to the current line + +`-b` : Add the priority (B) to the current line + +`-c` : Add the priority (C) to the current line + +`-d` : Insert the current date + +`date` : (Insert mode) Insert the current date + +`-x` : Mark task as done (inserts current date as completion date) + +`-X` : Mark all tasks as completed + +`-D` : Move completed tasks to done.txt + + is \ by default, so -s means you type \s diff --git a/done.txt b/done.txt new file mode 100644 index 0000000..a3e8325 --- /dev/null +++ b/done.txt @@ -0,0 +1,13 @@ +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 +x 2014-04-27 2011-05-30 Contact main project for reference +x 2014-11-01 2011-05-30 Map commands to add, rm, ls, pri, depri etc @ftplugin +x 2014-11-01 2011-05-31 Start documentation @doc +x 2014-11-01 2011-06-01 Improve syntax file @syntax +x 2014-11-01 2011-06-06 Check file syntax @syntax diff --git a/ftdetect/todo.vim b/ftdetect/todo.vim new file mode 100644 index 0000000..a12a122 --- /dev/null +++ b/ftdetect/todo.vim @@ -0,0 +1,10 @@ +" File: todo.txt.vim +" Description: Todo.txt filetype detection +" Author: Leandro Freitas +" 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 + diff --git a/ftplugin/todo.vim b/ftplugin/todo.vim new file mode 100644 index 0000000..efb7518 --- /dev/null +++ b/ftplugin/todo.vim @@ -0,0 +1,222 @@ +" File: todo.txt.vim +" Description: Todo.txt filetype detection +" Author: Leandro Freitas +" License: Vim license +" Website: http://github.com/freitass/todo.txt-vim +" Version: 0.4 + +" Save context {{{1 +let s:save_cpo = &cpo +set cpo&vim + +" 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 +" created or edited. +setlocal textwidth=0 +setlocal wrapmargin=0 + +" Functions {{{1 +function! s:TodoTxtRemovePriority() + :s/^(\w)\s\+//ge +endfunction + +function! TodoTxtPrependDate() + normal! 0"=strftime("%Y-%m-%d ") P +endfunction + +function! TodoTxtMarkAsDone() + call s:TodoTxtRemovePriority() + call TodoTxtPrependDate() + normal! Ix +endfunction + +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() + " 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 + +function! TodoTxtToggleComplete() + if getline('.') =~ '^x' + s/\v^x [0-9-]+ +// + else + exec "s/^/x " . strftime('%Y-%m-%d') . " /" + endif +endfunction + +" Mappings {{{1 +" Sort tasks {{{2 +if !hasmapto("s",'n') + nnoremap