Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: reStructuredText Documentation Format |
| 3 | " Maintainer: Nikolai Weibull <source@pcppopper.org> |
| 4 | " URL: http://www.pcppopper.org/vim/syntax/pcp/rst/ |
| 5 | " Latest Revision: 2004-05-13 |
| 6 | " arch-tag: 6fae09da-d5d4-49d8-aec1-e49008ea21e6 |
| 7 | |
| 8 | if version < 600 |
| 9 | syntax clear |
| 10 | elseif exists("b:current_syntax") |
| 11 | finish |
| 12 | endif |
| 13 | |
| 14 | " todo |
| 15 | syn keyword rstTodo contained FIXME TODO XXX NOTE |
| 16 | |
| 17 | syn case ignore |
| 18 | |
| 19 | " comments |
| 20 | syn region rstComment matchgroup=rstComment start="^\.\.\%( \%([a-z0-9_.-]\+::\)\@!\|$\)" end="^\s\@!" contains=rstTodo |
| 21 | |
| 22 | syn cluster rstCruft contains=rstFootnoteLabel,rstCitationLabel,rstSubstitutionLabel,rstInline,rstHyperlinks,rstInternalTarget |
| 23 | |
| 24 | " blocks |
| 25 | " syn region rstBlock matchgroup=rstDelimiter start=":\@<!:$" skip="^$" end="^\s\@!" contains=@rstCruft |
| 26 | syn region rstBlock matchgroup=rstDelimiter start="::$" skip="^$" end="^\s\@!" |
| 27 | syn region rstDoctestBlock matchgroup=rstDelimiter start="^>>>\s" end="^$" |
| 28 | |
| 29 | " tables |
| 30 | " TODO: these may actually be a bit too complicated to match correctly and |
| 31 | " should perhaps be removed. Whon really needs it anyway? |
| 32 | syn region rstTable transparent start="^\n\s*+[-=+]\+" end="^$" contains=rstTableLines,@rstCruft |
| 33 | syn match rstTableLines contained "^\s*[|+=-]\+$" |
| 34 | syn region rstSimpleTable transparent start="^\n\s*\%(=\+\s\+\)\%(=\+\s*\)\+$" end="^$" contains=rstSimpleTableLines,@rstCruft |
| 35 | syn match rstSimpleTableLines contained "^\s*\%(=\+\s\+\)\%(=\+\s*\)\+$" |
| 36 | |
| 37 | " footnotes |
| 38 | syn region rstFootnote matchgroup=rstDirective start="^\.\. \[\%([#*]\|[0-9]\+\|#[a-z0-9_.-]\+\)\]\s" end="^\s\@!" contains=@rstCruft |
| 39 | syn match rstFootnoteLabel "\[\%([#*]\|[0-9]\+\|#[a-z0-9_.-]\+\)\]_" |
| 40 | |
| 41 | " citations |
| 42 | syn region rstCitation matchgroup=rstDirective start="^\.\. \[[a-z0-9_.-]\+\]\s" end="^\s\@!" contains=@rstCruft |
| 43 | syn match rstCitationLabel "\[[a-z0-9_.-]\+\]_" |
| 44 | |
| 45 | " directives |
| 46 | syn region rstDirectiveBody matchgroup=rstDirective start="^\.\. [a-z0-9_.-]\+::" end="^\s\@!" |
| 47 | |
| 48 | " substitutions |
| 49 | syn region rstSubstitution matchgroup=rstDirective start="^\.\. |[a-z0-9_.-]|\s[a-z0-9_.-]\+::\s" end="^\s\@!" contains=@rstCruft |
| 50 | syn match rstSubstitutionLabel "|[a-z0-9_.-]|" |
| 51 | |
| 52 | " inline markup |
| 53 | syn match rstInline "\*\{1,2}\S\%([^*]*\S\)\=\*\{1,2}" |
| 54 | syn match rstInline "`\{1,2}\S\%([^`]*\S\)\=`\{1,2}" |
| 55 | |
| 56 | " hyperlinks |
| 57 | syn region rstHyperlinks matchgroup=RstDirective start="^\.\. _[a-z0-9_. -]\+:\s" end="^\s\@!" contains=@rstCruft |
| 58 | |
| 59 | syn match rstHyperlinksLabel "`\S\%([^`]*\S\)\=`__\=\>" |
| 60 | syn match rstHyperlinksLabel "\w\+__\=\>" |
| 61 | |
| 62 | " internal targets |
| 63 | syn match rstInternalTarget "_`\S\%([^`]*\S\)\=`" |
| 64 | |
| 65 | " lists |
| 66 | syn match rstListItem "^:\%(\w\+\s*\)\+:" |
| 67 | syn match rstListItem "^\s*[-*+]\s\+" |
| 68 | |
| 69 | syn sync minlines=50 |
| 70 | |
| 71 | " Define the default highlighting. |
| 72 | " For version 5.7 and earlier: only when not done already |
| 73 | " For version 5.8 and later: only when an item doesn't have highlighting yet |
| 74 | if version >= 508 || !exists("did_rst_syn_inits") |
| 75 | if version < 508 |
| 76 | let did_rst_syn_inits = 1 |
| 77 | command -nargs=+ HiLink hi link <args> |
| 78 | else |
| 79 | command -nargs=+ HiLink hi def link <args> |
| 80 | endif |
| 81 | |
| 82 | HiLink rstTodo Todo |
| 83 | HiLink rstComment Comment |
| 84 | HiLink rstDelimiter Delimiter |
| 85 | HiLink rstBlock String |
| 86 | HiLink rstDoctestBlock PreProc |
| 87 | HiLink rstTableLines Delimiter |
| 88 | HiLink rstSimpleTableLines rstTableLines |
| 89 | HiLink rstFootnote String |
| 90 | HiLink rstFootnoteLabel Identifier |
| 91 | HiLink rstCitation String |
| 92 | HiLink rstCitationLabel Identifier |
| 93 | HiLink rstDirective Keyword |
| 94 | HiLink rstDirectiveBody Type |
| 95 | HiLink rstSubstitution String |
| 96 | HiLink rstSubstitutionLabel Identifier |
| 97 | HiLink rstHyperlinks String |
| 98 | HiLink rstHyperlinksLabel Identifier |
| 99 | HiLink rstListItem Identifier |
| 100 | hi def rstInline term=italic cterm=italic gui=italic |
| 101 | hi def rstInternalTarget term=italic cterm=italic gui=italic |
| 102 | delcommand HiLink |
| 103 | endif |
| 104 | |
| 105 | let b:current_syntax = "rst" |
| 106 | |
| 107 | " vim: set sts=2 sw=2: |