Feature - #307 vim support for taskrc

- Added support for syntax highlighting of taskrc within vim.
This commit is contained in:
John Florian 2009-12-10 18:39:24 -05:00
parent 0780919c2e
commit 81ce844d79
4 changed files with 70 additions and 20 deletions

View file

@ -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

View file

@ -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 <jflorian@doubledog.org>
" 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

View file

@ -0,0 +1,43 @@
" Vim syntax file
" Language: support for editing task configuration file
" Maintainer: John Florian <jflorian@doubledog.org>
" 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