From 81ce844d7989a922481acd92bbcf38656a2779e1 Mon Sep 17 00:00:00 2001 From: John Florian Date: Thu, 10 Dec 2009 18:39:24 -0500 Subject: [PATCH] Feature - #307 vim support for taskrc - Added support for syntax highlighting of taskrc within vim. --- ChangeLog | 1 + scripts/vim/README | 34 ++++++++++++++------------- scripts/vim/ftdetect/task.vim | 12 ++++++---- scripts/vim/syntax/taskrc.vim | 43 +++++++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 20 deletions(-) create mode 100644 scripts/vim/syntax/taskrc.vim diff --git a/ChangeLog b/ChangeLog index 0e5243485..9465eedf5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -28,6 +28,7 @@ + Fixed bug that was causing the 'completed' report to sort incorrectly. + Fixed bug #347 which used only a lowercase "all" to confirm multiple changes instead of an uppercase "All" like the "Yes" answer. + + Added feature #307 that provides vim with syntax highlighting for taskrc. ------ old releases ------------------------------ diff --git a/scripts/vim/README b/scripts/vim/README index 8250ca3aa..4397eef34 100644 --- a/scripts/vim/README +++ b/scripts/vim/README @@ -2,21 +2,21 @@ Configure VIM for Syntax Highlighting of Task Data -The task data files (pending.data, completed.data and undo.data) as well as -edits made via commands like "task 1 edit" can be color-highlighted if you -happen to use VIM as your preferred text editor. Eventually this will happen -automatically in newer versions of VIM, but for now you have to do a little -bit of file shuffling. +The task data files (pending.data, completed.data and undo.data), +configuration file (.taskrc) as well as edits made via commands like "task 1 +edit" can be color-highlighted if you happen to use VIM as your preferred text +editor. Eventually this will happen automatically in newer versions of VIM, +but for now you have to do a little bit of file shuffling. Prerequisites For this to work, you need to first have syntax highlighting enabled when you -use VIM. This happens to be the default for most VIM installations, but it is -usually quite simple if that doesn't happen to be so in your case. Rather than -repeat the excellent VIM documentation here, please see the appropriate VIM -documentation itself. Generally this can be made seen by starting vim/gvim and -issuing the following command: +use VIM. This happens to be the default for most VIM installations, but it is +usually quite simple if that doesn't happen to be so in your case. Rather +than repeat the excellent VIM documentation here, please see the appropriate +VIM documentation itself. Generally this can be made seen by starting +vim/gvim and issuing the following command: :help syntax @@ -27,18 +27,20 @@ You may prefer instead to read the help online at: Configuring VIM to Understand Task Data Once you have VIM's syntax highlighting enabled and working with other file -types properly, configuring it for use with task is simple. You simply need to -copy some files that came with task into your home directory so that you have: +types properly, configuring it for use with task is simple. You simply need +to copy some files that came with task into your home directory so that you +have: ~/.vim/ftdetect/task.vim ~/.vim/syntax/taskdata.vim ~/.vim/syntax/taskedit.vim + ~/.vim/syntax/taskrc.vim -The source of these files varies depending on how you installed task. If you +The source of these files varies depending on how you installed task. If you installed task via a regular package (rpm or deb) you can find these files in -/usr/share/doc/task-VERSION/scripts/vim/. If you built task yourself from the +/usr/share/doc/task-VERSION/scripts/vim/. If you built task yourself from the tarball (using the default configure options), these will be in -/usr/local/share/doc/task-VERSION/scripts/vim/ instead. So you should be able +/usr/local/share/doc/task-VERSION/scripts/vim/ instead. So you should be able to do one of the following: cp -av /usr/share/doc/task-VERSION/scripts/vim/* ~/.vim/ @@ -49,7 +51,7 @@ or You should then be ready to go. --- -All three above mentioned files are +All four above mentioned files are Copyright 2009 John Florian diff --git a/scripts/vim/ftdetect/task.vim b/scripts/vim/ftdetect/task.vim index 5bb843833..084ed4f1a 100644 --- a/scripts/vim/ftdetect/task.vim +++ b/scripts/vim/ftdetect/task.vim @@ -1,7 +1,8 @@ -" Vim support file to detect task data files and single task edits +" Vim support file to detect Task Warrior data and configuration files and +" single task edits " " Maintainer: John Florian -" Updated: Wed Jul 8 19:45:55 EDT 2009 +" Updated: Thu Dec 10 18:28:26 EST 2009 " " Copyright 2009 John Florian " @@ -9,10 +10,13 @@ " For the full text of this license, see COPYING. -" for the raw data files +" Task Warrior data files au BufRead,BufNewFile {pending,completed,undo}.data set filetype=taskdata -" for 'task 42 edit' +" Task Warrior configuration file +au BufRead,BufNewFile .taskrc set filetype=taskrc + +" Task Warrior handling of 'task 42 edit' au BufRead,BufNewFile *.task set filetype=taskedit " vim:noexpandtab diff --git a/scripts/vim/syntax/taskrc.vim b/scripts/vim/syntax/taskrc.vim new file mode 100644 index 000000000..5d9714245 --- /dev/null +++ b/scripts/vim/syntax/taskrc.vim @@ -0,0 +1,43 @@ +" Vim syntax file +" Language: support for editing task configuration file +" Maintainer: John Florian +" Updated: Wed Nov 25 12:19:43 EST 2009 +" +" Copyright 2009 John Florian +" +" This file is available under the GNU Public License version 2 or later. +" For the full text of this license, see COPYING. + + +" For version 5.x: Clear all syntax items. +" For version 6.x: Quit when a syntax file was already loaded. +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +syn match taskrcVal ".\{-}$" contains=taskrcComment +syn match taskrcEqual "=" +syn match taskrcKey "^\s*.\{-}="he=e-1 contains=taskrcEqual + +syn keyword taskrcGoodKey locking curses confirmation next bulk nag dateformat weekstart displayweeknumber due defaultwidth editor monthsperline + +syn match taskrcGoodKey "color\(\.\(overdue\|due\|pri\.\([HML]\|none\)\|active\|tagged\|recurring\|header\|footnote\|\(\(tag\|project\|keyword\)\.\S\{-}\)\)\)\?="he=e-1 +syn match taskrcGoodKey "data\.location" +syn match taskrcGoodKey "default\.\(command\|project\|priority\)" +syn match taskrcGoodKey "echo\.command" +syn match taskrcGoodKey "report\.\S\{-}\.\(description\|columns\|labels\|sort\|filter\)="he=e-1 +syn match taskrcGoodKey "shadow\.\(file\|command\|notify\)" + +syn match taskrcComment "#.*$" + +" The default methods for highlighting. Can be overridden later. +hi def link taskrcComment Comment +hi def link taskrcKey Statement +hi def link taskrcVal String +hi def link taskrcGoodKey Function + +let b:current_syntax = "taskrc" + +" vim:noexpandtab