[Bps-public-commit] SD branch, master, updated. 653cbdcbb615a279daf151c926a3f743be986604
spang at bestpractical.com
spang at bestpractical.com
Mon Aug 17 14:38:24 EDT 2009
The branch, master has been updated
via 653cbdcbb615a279daf151c926a3f743be986604 (commit)
from fab3b2841bee6a0520ce75d1aaa4f29f5bb17edd (commit)
Summary of changes:
contrib/sdticket.vim | 75 ++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 63 insertions(+), 12 deletions(-)
- Log -----------------------------------------------------------------
commit 653cbdcbb615a279daf151c926a3f743be986604
Author: Christine Spang <spang at bestpractical.com>
Date: Mon Aug 17 19:34:30 2009 +0100
Some improvements to the vim syntax file
* Grab what to highlight on for milestones, components, and statuses
from the output of 'sd settings'.
* Don't misinterpret the comment section as a column.
* Recommend a better autocommand check that detects re-editing
after errors as well.
diff --git a/contrib/sdticket.vim b/contrib/sdticket.vim
index 49e8d26..84c9bff 100644
--- a/contrib/sdticket.vim
+++ b/contrib/sdticket.vim
@@ -2,20 +2,21 @@
" SD Ticket Syntax File
" Maintainer: Yo-An Lin < cornelius.howl at gmail.com >
" URL: http://www.vim.org/scripts/script.php?script_id=2614
-" Last Change: 09 Apr 21 04/21/2009
-" Version: 0.1
+" Last Change: 08/17/2009
+" Version: 0.2
" Intro:
"
-" This syntax file is for ticket summary file of SD (peer-to-peer bug
-" tracking system)
-" http://syncwith.us/
+" This syntax file is for ticket create/update template of SD (a
+" peer-to-peer bug tracking system)
+" http://syncwith.us/
"
" Usage:
-" To let vim known the editing file is SD ticket
-" add the below settings to your .vimrc
+" To let vim know the editing file is an SD ticket, add the following to
+" your .vimrc and copy or link this file to your vim syntax directory
+" (usually ~/.vim/syntax):
"
" au BufNewFile,BufRead *
-" \ if getline(1) =~ "required ticket metadata" |
+" \ if getline(1) =~ '\(required ticket metadata\)\|\(errors in this ticket\)' |
" \ setf sdticket |
" \ endif
"
@@ -28,11 +29,57 @@ elseif exists("b:current_syntax")
finish
endif
+" takes the string output of 'sd settings', offsets for the start and end of
+" the JSON value of a setting not including the [], and returns a list of the
+" elements with the quotes stripped
+func! s:ConvertSubstrToList(str, start, end)
+ return map(
+ \ split(
+ \ strpart(
+ \ a:str, a:start, a:end - a:start,
+ \ ),
+ \ ',',
+ \ ),
+ \ "substitute( v:val, '\"', '', 'g' )",
+ \ )
+endfunc
+
syn region sdHeader start="^===" end="===$"
-syn region sdColumn start="^\w\+" end=":"
+syn region sdComment start="^#" end="$"
+syn region sdColumn start="^\w\+:\@=" end=":"
+
+" try to get the valid statuses, components, milestones etc. from the settings
+" for the current sd replica
+" assumes SD_REPO is set and sd command is sd, otherwise will fall back to
+" defaults
+let s:settings = system("sd settings")
+
+if s:settings =~ 'not found'
+ " user is running some wrapper script; use sd defaults
+ syn keyword sdStatus new open closed stalled rejected
+ syn keyword sdComponent core ui docs tests
+ syn keyword sdMilestone alpha beta 1.0
+else
+ " parse the settings we found and setup syntax for them
+ let s:milestones_offset = matchend(s:settings, "milestones: [")
+ let s:closing_bracket_offset = match(s:settings, "]", s:milestones_offset)
+ let s:milestones = s:ConvertSubstrToList(s:settings, s:milestones_offset, s:closing_bracket_offset)
-syn keyword sdStatus new open close
-syn keyword sdComponent core
+ let s:components_offset = matchend(s:settings, "components: [")
+ let s:closing_bracket_offset = match(s:settings, "]", s:components_offset)
+ let s:components = s:ConvertSubstrToList(s:settings, s:components_offset, s:closing_bracket_offset)
+
+ let s:statuses_offset = matchend(s:settings, "statuses: [")
+ let s:closing_bracket_offset = match(s:settings, "]", s:statuses_offset)
+ let s:statuses = s:ConvertSubstrToList(s:settings, s:statuses_offset, s:closing_bracket_offset)
+
+ for s:list in [s:milestones, s:components, s:statuses]
+ for s:group in ['sdMilestone', 'sdComponent', 'sdStatus']
+ let s:syntax = 'syn keyword ' . s:group . ' ' . join(s:list)
+ exec s:syntax
+ endfor
+ endfor
+endif
if version >= 508 || !exists("did_sdticket_syn_inits")
if version < 508
@@ -44,8 +91,12 @@ if version >= 508 || !exists("did_sdticket_syn_inits")
" The default highlighting.
HiLink sdHeader Comment
- HiLink sdColumn Identifier
+ HiLink sdComment Comment
+ HiLink sdColumn Label
+ " do we want these to be different colours?
HiLink sdStatus Type
+ HiLink sdMilestone Type
+ HiLink sdComponent Type
delcommand HiLink
endif
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list