summaryrefslogtreecommitdiff
path: root/runtime/syntax
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/syntax')
-rw-r--r--runtime/syntax/maxima.vim274
-rw-r--r--runtime/syntax/rst.vim217
2 files changed, 421 insertions, 70 deletions
diff --git a/runtime/syntax/maxima.vim b/runtime/syntax/maxima.vim
new file mode 100644
index 000000000..ca982d7a4
--- /dev/null
+++ b/runtime/syntax/maxima.vim
@@ -0,0 +1,274 @@
+" Vim syntax file
+" Language: Maxima (symbolic algebra program)
+" Maintainer: Robert Dodier (robert.dodier@gmail.com)
+" Last Change: April 6, 2006
+" Version: 1
+" Adapted mostly from xmath.vim
+" Number formats adapted from r.vim
+"
+" 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 sync lines=1000
+
+" parenthesis sanity checker
+syn region maximaZone matchgroup=Delimiter start="(" matchgroup=Delimiter end=")" transparent contains=ALLBUT,maximaError,maximaBraceError,maximaCurlyError
+syn region maximaZone matchgroup=Delimiter start="{" matchgroup=Delimiter end="}" transparent contains=ALLBUT,maximaError,maximaBraceError,maximaParenError
+syn region maximaZone matchgroup=Delimiter start="\[" matchgroup=Delimiter end="]" transparent contains=ALLBUT,maximaError,maximaCurlyError,maximaParenError
+syn match maximaError "[)\]}]"
+syn match maximaBraceError "[)}]" contained
+syn match maximaCurlyError "[)\]]" contained
+syn match maximaParenError "[\]}]" contained
+syn match maximaComma "[\[\](),;]"
+syn match maximaComma "\.\.\.$"
+
+" A bunch of useful maxima keywords
+syn keyword maximaConditional if then else elseif and or not
+syn keyword maximaRepeat do for thru
+
+" ---------------------- BEGIN LIST OF ALL FUNCTIONS (EXCEPT KEYWORDS) ----------------------
+syn keyword maximaFunc abasep abs absboxchar absint acos acosh acot acoth acsc
+syn keyword maximaFunc acsch activate activecontexts addcol additive addrow adim
+syn keyword maximaFunc adjoint af aform airy algebraic algepsilon algexact algsys
+syn keyword maximaFunc alg_type alias aliases allbut all_dotsimp_denoms allroots allsym
+syn keyword maximaFunc alphabetic antid antidiff antisymmetric append appendfile
+syn keyword maximaFunc apply apply1 apply2 applyb1 apropos args array arrayapply
+syn keyword maximaFunc arrayinfo arraymake arrays asec asech asin asinh askexp
+syn keyword maximaFunc askinteger asksign assoc assoc_legendre_p assoc_legendre_q assume
+syn keyword maximaFunc assume_pos assume_pos_pred assumescalar asymbol asympa at atan
+syn keyword maximaFunc atan2 atanh atensimp atom atomgrad atrig1 atvalue augcoefmatrix
+syn keyword maximaFunc av backsubst backtrace bashindices batch batchload bc2 bdvac
+syn keyword maximaFunc berlefact bern bernpoly bessel besselexpand bessel_i bessel_j
+syn keyword maximaFunc bessel_k bessel_y beta bezout bffac bfhzeta bfloat bfloatp
+syn keyword maximaFunc bfpsi bfpsi0 bftorat bftrunc bfzeta bimetric binomial block
+syn keyword maximaFunc bothcoef box boxchar break breakup bug_report build_info buildq
+syn keyword maximaFunc burn cabs canform canten carg cartan catch cauchysum cbffac
+syn keyword maximaFunc cdisplay cf cfdisrep cfexpand cflength cframe_flag cgeodesic
+syn keyword maximaFunc changename changevar charpoly checkdiv check_overlaps christof
+syn keyword maximaFunc clear_rules closefile closeps cmetric cnonmet_flag coeff
+syn keyword maximaFunc coefmatrix cograd col collapse columnvector combine commutative
+syn keyword maximaFunc comp2pui compfile compile compile_file components concan concat
+syn keyword maximaFunc conj conjugate conmetderiv cons constant constantp cont2part
+syn keyword maximaFunc content context contexts contortion contract contragrad coord
+syn keyword maximaFunc copylist copymatrix cos cosh cosnpiflag cot coth covdiff
+syn keyword maximaFunc covect create_list csc csch csetup ctaylor ctaypov ctaypt
+syn keyword maximaFunc ctayswitch ctayvar ct_coords ct_coordsys ctorsion_flag ctransform
+syn keyword maximaFunc ctrgsimp current_let_rule_package dblint deactivate debugmode
+syn keyword maximaFunc declare declare_translated declare_weight decsym
+syn keyword maximaFunc default_let_rule_package defcon define define_variable defint
+syn keyword maximaFunc defmatch defrule deftaylor del delete deleten delta demo
+syn keyword maximaFunc demoivre denom dependencies depends derivabbrev derivdegree
+syn keyword maximaFunc derivlist derivsubst describe desolve determinant detout
+syn keyword maximaFunc diagmatrix diagmatrixp diagmetric diff dim dimension direct
+syn keyword maximaFunc disolate disp dispcon dispflag dispform dispfun display
+syn keyword maximaFunc display2d display_format_internal disprule dispterms distrib
+syn keyword maximaFunc divide divsum doallmxops domain domxexpt domxmxops domxnctimes
+syn keyword maximaFunc dontfactor doscmxops doscmxplus dot0nscsimp dot0simp dot1simp
+syn keyword maximaFunc dotassoc dotconstrules dotdistrib dotexptsimp dotident dotscrules
+syn keyword maximaFunc dotsimp dpart dscalar %e echelon %edispflag eigenvalues
+syn keyword maximaFunc eigenvectors eighth einstein eivals eivects ele2comp
+syn keyword maximaFunc ele2polynome ele2pui elem eliminate elliptic_e elliptic_ec
+syn keyword maximaFunc elliptic_eu elliptic_f elliptic_kc elliptic_pi ematrix %emode
+syn keyword maximaFunc endcons entermatrix entertensor entier %enumer equal equalp erf
+syn keyword maximaFunc erfflag errcatch error errormsg error_size error_syms
+syn keyword maximaFunc %e_to_numlog euler ev eval evenp every evflag evfun evundiff
+syn keyword maximaFunc example exp expand expandwrt expandwrt_denom expandwrt_factored
+syn keyword maximaFunc explose expon exponentialize expop express expt exptdispflag
+syn keyword maximaFunc exptisolate exptsubst extdiff extract_linear_equations ezgcd
+syn keyword maximaFunc facexpand factcomb factlim factor factorflag factorial factorout
+syn keyword maximaFunc factorsum facts false fast_central_elements fast_linsolve
+syn keyword maximaFunc fasttimes fb feature featurep features fft fib fibtophi fifth
+syn keyword maximaFunc filename_merge file_search file_search_demo file_search_lisp
+syn keyword maximaFunc file_search_maxima file_type fillarray findde first fix flatten
+syn keyword maximaFunc flipflag float float2bf floatnump flush flush1deriv flushd
+syn keyword maximaFunc flushnd forget fortindent fortran fortspaces fourcos fourexpand
+syn keyword maximaFunc fourier fourint fourintcos fourintsin foursimp foursin fourth
+syn keyword maximaFunc fpprec fpprintprec frame_bracket freeof fullmap fullmapl
+syn keyword maximaFunc fullratsimp fullratsubst funcsolve functions fundef funmake funp
+syn keyword maximaFunc gamma %gamma gammalim gauss gcd gcdex gcfactor gdet genfact
+syn keyword maximaFunc genindex genmatrix gensumnum get getchar gfactor gfactorsum
+syn keyword maximaFunc globalsolve go gradef gradefs gramschmidt grind grobner_basis
+syn keyword maximaFunc gschmit hach halfangles hermite hipow hodge horner i0 i1
+syn keyword maximaFunc *read-base* ic1 ic2 icc1 icc2 ic_convert ichr1 ichr2 icounter
+syn keyword maximaFunc icurvature ident idiff idim idummy idummyx ieqn ieqnprint ifb
+syn keyword maximaFunc ifc1 ifc2 ifg ifgi ifr iframe_bracket_form iframes ifri ift
+syn keyword maximaFunc igeodesic_coords igeowedge_flag ikt1 ikt2 ilt imagpart imetric
+syn keyword maximaFunc inchar indexed_tensor indices inf %inf infeval infinity infix
+syn keyword maximaFunc inflag infolists init_atensor init_ctensor inm inmc1 inmc2
+syn keyword maximaFunc innerproduct in_netmath inpart inprod inrt integerp integrate
+syn keyword maximaFunc integrate_use_rootsof integration_constant_counter interpolate
+syn keyword maximaFunc intfaclim intopois intosum intpolabs intpolerror intpolrel
+syn keyword maximaFunc invariant1 invariant2 inverse_jacobi_cd inverse_jacobi_cn
+syn keyword maximaFunc inverse_jacobi_cs inverse_jacobi_dc inverse_jacobi_dn
+syn keyword maximaFunc inverse_jacobi_ds inverse_jacobi_nc inverse_jacobi_nd
+syn keyword maximaFunc inverse_jacobi_ns inverse_jacobi_sc inverse_jacobi_sd
+syn keyword maximaFunc inverse_jacobi_sn invert is ishow isolate isolate_wrt_times
+syn keyword maximaFunc isqrt itr j0 j1 jacobi jacobi_cd jacobi_cn jacobi_cs jacobi_dc
+syn keyword maximaFunc jacobi_dn jacobi_ds jacobi_nc jacobi_nd jacobi_ns jacobi_sc
+syn keyword maximaFunc jacobi_sd jacobi_sn jn kdels kdelta keepfloat kill killcontext
+syn keyword maximaFunc kinvariant kostka kt labels lambda laplace lassociative last
+syn keyword maximaFunc lc2kdt lc_l lcm lc_u ldefint ldisp ldisplay leinstein length
+syn keyword maximaFunc let letrat let_rule_packages letrules letsimp levi_civita lfg
+syn keyword maximaFunc lfreeof lg lgtreillis lhospitallim lhs liediff limit limsubst
+syn keyword maximaFunc linear linechar linel linenum linsolve linsolve_params
+syn keyword maximaFunc linsolvewarn listarith listarray listconstvars listdummyvars
+syn keyword maximaFunc list_nc_monomials listoftens listofvars listp lmxchar load
+syn keyword maximaFunc loadfile loadprint local log logabs logarc logconcoeffp
+syn keyword maximaFunc logcontract logexpand lognegint lognumer logsimp lopow
+syn keyword maximaFunc lorentz_gauge lpart lratsubst lriem lriemann lsum ltreillis
+syn keyword maximaFunc m1pbranch macroexpansion mainvar make_array makebox makefact
+syn keyword maximaFunc makegamma makelist make_random_state make_transform map mapatom
+syn keyword maximaFunc maperror maplist matchdeclare matchfix matrix matrix_element_add
+syn keyword maximaFunc matrix_element_mult matrix_element_transpose matrixmap matrixp
+syn keyword maximaFunc mattrace max maxapplydepth maxapplyheight maxnegex maxposex
+syn keyword maximaFunc maxtayorder member min %minf minfactorial minor mod
+syn keyword maximaFunc mode_check_errorp mode_checkp mode_check_warnp mode_declare
+syn keyword maximaFunc mode_identity modulus mon2schur mono monomial_dimensions
+syn keyword maximaFunc multi_elem multinomial multi_orbit multiplicative multiplicities
+syn keyword maximaFunc multi_pui multsym multthru myoptions nc_degree ncexpt ncharpoly
+syn keyword maximaFunc negdistrib negsumdispflag newcontext newdet newton niceindices
+syn keyword maximaFunc niceindicespref ninth nm nmc noeval nolabels nonmetricity
+syn keyword maximaFunc nonscalar nonscalarp noun noundisp nounify nouns np npi
+syn keyword maximaFunc nptetrad nroots nterms ntermst nthroot ntrig num numberp numer
+syn keyword maximaFunc numerval numfactor nusum obase oddp ode2 op openplot_curves
+syn keyword maximaFunc operatorp opproperties opsubst optimize optimprefix optionset
+syn keyword maximaFunc orbit ordergreat ordergreatp orderless orderlessp outative
+syn keyword maximaFunc outchar outermap outofpois packagefile pade part part2cont
+syn keyword maximaFunc partfrac partition partpol partswitch permanent permut petrov
+syn keyword maximaFunc pfeformat pi pickapart piece playback plog plot2d plot2d_ps
+syn keyword maximaFunc plot3d plot_options poisdiff poisexpt poisint poislim poismap
+syn keyword maximaFunc poisplus poissimp poisson poissubst poistimes poistrim polarform
+syn keyword maximaFunc polartorect polynome2ele posfun potential powerdisp powers
+syn keyword maximaFunc powerseries pred prederror primep print printpois printprops
+syn keyword maximaFunc prodhack prodrac product programmode prompt properties props
+syn keyword maximaFunc propvars pscom psdraw_curve psexpand psi pui pui2comp pui2ele
+syn keyword maximaFunc pui2polynome pui_direct puireduc put qput qq quad_qag quad_qagi
+syn keyword maximaFunc quad_qags quad_qawc quad_qawf quad_qawo quad_qaws quanc8 quit
+syn keyword maximaFunc qunit quotient radcan radexpand radsubstflag random rank
+syn keyword maximaFunc rassociative rat ratalgdenom ratchristof ratcoef ratdenom
+syn keyword maximaFunc ratdenomdivide ratdiff ratdisrep rateinstein ratepsilon ratexpand
+syn keyword maximaFunc ratfac ratmx ratnumer ratnump ratp ratprint ratriemann ratsimp
+syn keyword maximaFunc ratsimpexpons ratsubst ratvars ratweight ratweights ratweyl
+syn keyword maximaFunc ratwtlvl read readonly realonly realpart realroots rearray
+syn keyword maximaFunc rectform recttopolar rediff refcheck rem remainder remarray
+syn keyword maximaFunc rembox remcomps remcon remcoord remfun remfunction remlet
+syn keyword maximaFunc remove remrule remsym remvalue rename reset residue resolvante
+syn keyword maximaFunc resolvante_alternee1 resolvante_bipartite resolvante_diedrale
+syn keyword maximaFunc resolvante_klein resolvante_klein3 resolvante_produit_sym
+syn keyword maximaFunc resolvante_unitaire resolvante_vierer rest resultant return
+syn keyword maximaFunc reveal reverse revert revert2 rhs ric ricci riem riemann
+syn keyword maximaFunc rinvariant risch rmxchar rncombine %rnum_list romberg rombergabs
+syn keyword maximaFunc rombergit rombergmin rombergtol room rootsconmode rootscontract
+syn keyword maximaFunc rootsepsilon round row run_testsuite save savedef savefactors
+syn keyword maximaFunc scalarmatrixp scalarp scalefactors scanmap schur2comp sconcat
+syn keyword maximaFunc scsimp scurvature sec sech second setcheck setcheckbreak
+syn keyword maximaFunc setelmx set_plot_option set_random_state setup_autoload
+syn keyword maximaFunc set_up_dot_simplifications setval seventh sf show showcomps
+syn keyword maximaFunc showratvars showtime sign signum similaritytransform simpsum
+syn keyword maximaFunc simtran sin sinh sinnpiflag sixth solve solvedecomposes
+syn keyword maximaFunc solveexplicit solvefactors solve_inconsistent_error solvenullwarn
+syn keyword maximaFunc solveradcan solvetrigwarn somrac sort sparse spherical_bessel_j
+syn keyword maximaFunc spherical_bessel_y spherical_hankel1 spherical_hankel2
+syn keyword maximaFunc spherical_harmonic splice sqfr sqrt sqrtdispflag sstatus
+syn keyword maximaFunc stardisp status string stringout sublis sublis_apply_lambda
+syn keyword maximaFunc sublist submatrix subst substinpart substpart subvarp sum
+syn keyword maximaFunc sumcontract sumexpand sumhack sumsplitfact supcontext symbolp
+syn keyword maximaFunc symmetric symmetricp system tan tanh taylor taylordepth
+syn keyword maximaFunc taylorinfo taylor_logexpand taylor_order_coefficients taylorp
+syn keyword maximaFunc taylor_simplifier taylor_truncate_polynomials taytorat tcl_output
+syn keyword maximaFunc tcontract tellrat tellsimp tellsimpafter tensorkill tentex tenth
+syn keyword maximaFunc tex %th third throw time timer timer_devalue timer_info
+syn keyword maximaFunc tldefint tlimit tlimswitch todd_coxeter to_lisp totaldisrep
+syn keyword maximaFunc totalfourier totient tpartpol tr trace trace_options
+syn keyword maximaFunc transcompile translate translate_file transpose transrun
+syn keyword maximaFunc tr_array_as_ref tr_bound_function_applyp treillis treinat
+syn keyword maximaFunc tr_file_tty_messagesp tr_float_can_branch_complex
+syn keyword maximaFunc tr_function_call_default triangularize trigexpand trigexpandplus
+syn keyword maximaFunc trigexpandtimes triginverses trigrat trigreduce trigsign trigsimp
+syn keyword maximaFunc tr_numer tr_optimize_max_loop tr_semicompile tr_state_vars true
+syn keyword maximaFunc trunc truncate tr_warn_bad_function_calls tr_warn_fexpr
+syn keyword maximaFunc tr_warnings_get tr_warn_meval tr_warn_mode tr_warn_undeclared
+syn keyword maximaFunc tr_warn_undefined_variable tr_windy ttyoff ueivects ufg ug
+syn keyword maximaFunc ultraspherical undiff uniteigenvectors unitvector unknown unorder
+syn keyword maximaFunc unsum untellrat untimer untrace uric uricci uriem uriemann
+syn keyword maximaFunc use_fast_arrays uvect values vect_cross vectorpotential
+syn keyword maximaFunc vectorsimp verb verbify verbose weyl with_stdout writefile
+syn keyword maximaFunc xgraph_curves xthru zerobern zeroequiv zeromatrix zeta zeta%pi
+syn match maximaOp "[\*\/\+\-\#\!\~\^\=\:\<\>\@]"
+" ---------------------- END LIST OF ALL FUNCTIONS (EXCEPT KEYWORDS) ----------------------
+
+
+syn case match
+
+" Labels (supports maxima's goto)
+syn match maximaLabel "^\s*<[a-zA-Z_][a-zA-Z0-9%_]*>"
+
+" String and Character constants
+" Highlight special characters (those which have a backslash) differently
+syn match maximaSpecial contained "\\\d\d\d\|\\."
+syn region maximaString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=maximaSpecial
+syn match maximaCharacter "'[^\\]'"
+syn match maximaSpecialChar "'\\.'"
+
+" number with no fractional part or exponent
+syn match maximaNumber /\<\d\+\>/
+" floating point number with integer and fractional parts and optional exponent
+syn match maximaFloat /\<\d\+\.\d*\([BbDdEeSs][-+]\=\d\+\)\=\>/
+" floating point number with no integer part and optional exponent
+syn match maximaFloat /\<\.\d\+\([BbDdEeSs][-+]\=\d\+\)\=\>/
+" floating point number with no fractional part and optional exponent
+syn match maximaFloat /\<\d\+[BbDdEeSs][-+]\=\d\+\>/
+
+" Comments:
+" maxima supports /* ... */ (like C)
+syn keyword maximaTodo contained TODO Todo DEBUG
+syn region maximaCommentBlock start="/\*" end="\*/" contains=maximaString,maximaTodo
+
+" synchronizing
+syn sync match maximaSyncComment grouphere maximaCommentBlock "/*"
+syn sync match maximaSyncComment groupthere NONE "*/"
+
+" Define the default highlighting.
+" For version 5.7 and earlier: only when not done already
+" For version 5.8 and later: only when an item doesn't have highlighting yet
+if version >= 508 || !exists("did_maxima_syntax_inits")
+ if version < 508
+ let did_maxima_syntax_inits = 1
+ command -nargs=+ HiLink hi link <args>
+ else
+ command -nargs=+ HiLink hi def link <args>
+ endif
+
+ HiLink maximaBraceError maximaError
+ HiLink maximaCmd maximaStatement
+ HiLink maximaCurlyError maximaError
+ HiLink maximaFuncCmd maximaStatement
+ HiLink maximaParenError maximaError
+
+ " The default methods for highlighting. Can be overridden later
+ HiLink maximaCharacter Character
+ HiLink maximaComma Function
+ HiLink maximaCommentBlock Comment
+ HiLink maximaConditional Conditional
+ HiLink maximaError Error
+ HiLink maximaFunc Delimiter
+ HiLink maximaOp Delimiter
+ HiLink maximaLabel PreProc
+ HiLink maximaNumber Number
+ HiLink maximaFloat Float
+ HiLink maximaRepeat Repeat
+ HiLink maximaSpecial Type
+ HiLink maximaSpecialChar SpecialChar
+ HiLink maximaStatement Statement
+ HiLink maximaString String
+ HiLink maximaTodo Todo
+
+ delcommand HiLink
+endif
+
+let b:current_syntax = "maxima"
diff --git a/runtime/syntax/rst.vim b/runtime/syntax/rst.vim
index 70ec47ed5..6e24251ff 100644
--- a/runtime/syntax/rst.vim
+++ b/runtime/syntax/rst.vim
@@ -1,7 +1,7 @@
" Vim syntax file
" Language: reStructuredText documentation format
-" Maintainer: Nikolai Weibull <nikolai+work.vim@bitwi.se>
-" Latest Revision: 2006-03-26
+" Maintainer: Nikolai Weibull <now@bitwi.se>
+" Latest Revision: 2006-04-09
if exists("b:current_syntax")
finish
@@ -10,90 +10,167 @@ endif
let s:cpo_save = &cpo
set cpo&vim
-syn keyword rstTodo contained FIXME TODO XXX NOTE
-
syn case ignore
-syn region rstComment start='^\.\.\%( \%([a-z0-9_.-]\+::\)\@!\|$\)'
- \ end='^\s\@!' contains=rstTodo
+" FIXME: The problem with these two is that Vim doesn’t seem to like
+" matching across line boundaries.
+"
+" syn match rstSections /^.*\n[=`:.'"~^_*+#-]\+$/
-syn cluster rstCruft contains=rstFootnoteLabel,rstCitationLabel,
- \ rstSubstitutionLabel,rstInline,
- \ rstHyperlinks,rstInternalTarget
+" syn match rstTransition /^\s*[=`:.'"~^_*+#-]\{4,}\s*$/
-syn region rstBlock matchgroup=rstDelimiter
- \ start='::$' skip='^$' end='^\s\@!'
-syn region rstDoctestBlock matchgroup=rstDelimiter
- \ start='^>>>\s' end='^$'
+syn cluster rstCruft contains=rstEmphasis,rstStrongEmphasis,
+ \ rstInterpretedText,rstInlineLiteral,rstSubstitutionReference,
+ \ rstInlineInternalTargets,rstFootnoteReference,rstHyperlinkReference
-" TODO: these may actually be a bit too complicated to match correctly and
-" should perhaps be removed. We won't really needs it anyway?
-syn region rstTable transparent start='^\n\s*+[-=+]\+' end='^$'
- \ contains=rstTableLines,@rstCruft
-syn match rstTableLines contained '^\s*[|+=-]\+$'
-syn region rstSimpleTable transparent
- \ start='^\n\%(\s*\)\@>\%(\%(=\+\)\@>\%(\s\+\)\@>\)\%(\%(\%(=\+\)\@>\%(\s*\)\@>\)\+\)\@>$'
- \ end='^$'
- \ contains=rstSimpleTableLines,@rstCruft
-syn match rstSimpleTableLines contained display
- \ '^\%(\s*\)\@>\%(\%(=\+\)\@>\%(\s\+\)\@>\)\%(\%(\%(=\+\)\@>\%(\s*\)\@>\)\+\)\@>$'
+syn region rstLiteralBlock matchgroup=rstDelimiter
+ \ start='::\_s*\n\ze\z(\s\+\)' skip='^$' end='^\z1\@!'
+ \ contains=@NoSpell
-syn region rstFootnote matchgroup=rstDirective
- \ start='^\.\. \[\%([#*]\|[0-9]\+\|#[a-z0-9_.-]\+\)\]\s'
- \ end='^\s\@!' contains=@rstCruft
-syn match rstFootnoteLabel '\[\%([#*]\|[0-9]\+\|#[a-z0-9_.-]\+\)\]_'
+syn region rstQuotedLiteralBlock matchgroup=rstDelimiter
+ \ start="::\_s*\n\ze\z([!\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]\)"
+ \ end='^\z1\@!' contains=@NoSpell
-syn region rstCitation matchgroup=rstDirective
- \ start='^\.\. \[[a-z0-9_.-]\+\]\s'
- \ end='^\s\@!' contains=@rstCruft
-syn match rstCitationLabel '\[[a-z0-9_.-]\+\]_'
+syn region rstDoctestBlock oneline display matchgroup=rstDelimiter
+ \ start='^>>>\s' end='^$'
-syn region rstDirectiveBody matchgroup=rstDirective
- \ start='^\.\. [a-z0-9_.-]\+::'
- \ end='^\s\@!'
+syn region rstTable transparent start='^\n\s*+[-=+]\+' end='^$'
+ \ contains=rstTableLines,@rstCruft
+syn match rstTableLines contained display '|\|+\%(=\+\|-\+\)\='
-syn region rstSubstitution matchgroup=rstDirective
- \ start='^\.\. |[a-z0-9_.-]|\s[a-z0-9_.-]\+::\s'
- \ end='^\s\@!' contains=@rstCruft
-syn match rstSubstitutionLbl '|[a-z0-9_.-]|'
+syn region rstSimpleTable transparent
+ \ start='^\n\%(\s*\)\@>\%(\%(=\+\)\@>\%(\s\+\)\@>\)\%(\%(\%(=\+\)\@>\%(\s*\)\@>\)\+\)\@>$'
+ \ end='^$'
+ \ contains=rstSimpleTableLines,@rstCruft
+syn match rstSimpleTableLines contained display
+ \ '^\%(\s*\)\@>\%(\%(=\+\)\@>\%(\s\+\)\@>\)\%(\%(\%(=\+\)\@>\%(\s*\)\@>\)\+\)\@>$'
+syn match rstSimpleTableLines contained display
+ \ '^\%(\s*\)\@>\%(\%(-\+\)\@>\%(\s\+\)\@>\)\%(\%(\%(-\+\)\@>\%(\s*\)\@>\)\+\)\@>$'
-syn match rstInline '\*\{1,2}\S\%([^*]*\S\)\=\*\{1,2}'
-syn match rstInline '`\{1,2}\S\%([^`]*\S\)\=`\{1,2}'
+syn cluster rstDirectives contains=rstFootnote,rstCitation,
+ \ rstHyperlinkTarget,rstExDirective
-syn region rstHyperlinks matchgroup=RstDirective
- \ start='^\.\. _[a-z0-9_. -]\+:\s'
- \ end='^\s\@!' contains=@rstCruft
+syn match rstExplicitMarkup '^\.\.\s'
+ \ nextgroup=@rstDirectives,rstComment,rstSubstitutionDefinition
-syn match rstHyperlinksLabel '`\S\%([^`]*\S\)\=`__\=\>'
-syn match rstHyperlinksLabel '\w\+__\=\>'
+let s:ReferenceName = '[[:alnum:]]\+\%([_.-][[:alnum:]]\+\)*'
-syn match rstInternalTarget '_`\S\%([^`]*\S\)\=`'
-
-syn match rstListItem '^:\w\+\%(\s\+\w\+\)*:'
-syn match rstListItem '^\s*[-*+]\s\+'
+syn keyword rstTodo contained FIXME TODO XXX NOTE
+execute 'syn region rstComment contained' .
+ \ ' start=/.*/'
+ \ ' end=/^\s\@!/ contains=rstTodo'
+
+execute 'syn region rstFootnote contained matchgroup=rstDirective' .
+ \ ' start=+\[\%(\d\+\|#\%(' . s:ReferenceName . '\)\=\|\*\)\]\_s+' .
+ \ ' skip=+^$+' .
+ \ ' end=+^\s\@!+ contains=@rstCruft,@NoSpell'
+
+execute 'syn region rstCitation contained matchgroup=rstDirective' .
+ \ ' start=+\[' . s:ReferenceName . '\]\_s+' .
+ \ ' skip=+^$+' .
+ \ ' end=+^\s\@!+ contains=@rstCruft,@NoSpell'
+
+syn region rstHyperlinkTarget contained matchgroup=rstDirective
+ \ start='_\%(_\|[^:\\]*\%(\\.[^:\\]*\)*\):\_s' skip=+^$+ end=+^\s\@!+
+
+syn region rstHyperlinkTarget contained matchgroup=rstDirective
+ \ start='_`[^`\\]*\%(\\.[^`\\]*\)*`:\_s' skip=+^$+ end=+^\s\@!+
+
+syn region rstHyperlinkTarget matchgroup=rstDirective
+ \ start=+^__\_s+ skip=+^$+ end=+^\s\@!+
+
+execute 'syn region rstExDirective contained matchgroup=rstDirective' .
+ \ ' start=+' . s:ReferenceName . '::\_s+' .
+ \ ' skip=+^$+' .
+ \ ' end=+^\s\@!+ contains=@rstCruft'
+
+execute 'syn match rstSubstitutionDefinition contained' .
+ \ ' /|' . s:ReferenceName . '|\_s\+/ nextgroup=@rstDirectives'
+
+function! s:DefineOneInlineMarkup(name, start, middle, end, char_left, char_right)
+ execute 'syn region rst' . a:name .
+ \ ' start=+' . a:char_left . '\zs' . a:start .
+ \ '[^[:space:]' . a:char_right . a:start[strlen(a:start) - 1] . ']+' .
+ \ a:middle .
+ \ ' end=+\S' . a:end . '\ze\%($\|\s\|[''")\]}>/:.,;!?\\-]\)+'
+endfunction
+
+function! s:DefineInlineMarkup(name, start, middle, end)
+ let middle = a:middle != "" ?
+ \ (' skip=+\\\\\|\\' . a:middle . '+') :
+ \ ""
+
+ call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, "'", "'")
+ call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '"', '"')
+ call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '(', ')')
+ call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '\[', '\]')
+ call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '{', '}')
+ call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '<', '>')
+
+ call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '\%(^\|\s\|[/:]\)', '')
+
+ execute 'syn match rst' . a:name .
+ \ ' +\%(^\|\s\|[''"([{</:]\)\zs' . a:start .
+ \ '[^[:space:]' . a:start[strlen(a:start) - 1] . ']'
+ \ a:end . '\ze\%($\|\s\|[''")\]}>/:.,;!?\\-]\)+'
+
+ execute 'hi def link rst' . a:name . 'Delimiter' . ' rst' . a:name
+endfunction
+
+call s:DefineInlineMarkup('Emphasis', '\*', '\*', '\*')
+call s:DefineInlineMarkup('StrongEmphasis', '\*\*', '\*', '\*\*')
+call s:DefineInlineMarkup('InterpretedTextOrHyperlinkReference', '`', '`', '`_\{0,2}')
+call s:DefineInlineMarkup('InlineLiteral', '``', "", '``')
+call s:DefineInlineMarkup('SubstitutionReference', '|', '|', '|_\{0,2}')
+call s:DefineInlineMarkup('InlineInternalTargets', '_`', '`', '`')
+
+" TODO: Can’t remember why these two can’t be defined like the ones above.
+execute 'syn match rstFootnoteReference contains=@NoSpell' .
+ \ ' +\[\%(\d\+\|#\%(' . s:ReferenceName . '\)\=\|\*\)\]_+'
+
+execute 'syn match rstCitationReference contains=@NoSpell' .
+ \ ' +\[' . s:ReferenceName . '\]_+'
+
+execute 'syn match rstHyperlinkReference' .
+ \ ' /\<' . s:ReferenceName . '__\=/'
+
+syn match rstStandaloneHyperlink contains=@NoSpell
+ \ "\<\%(\%(\%(https\=\|file\|ftp\|gopher\)://\|\%(mailto\|news\):\)[^[:space:]'\"<>]\+\|www[[:alnum:]_-]*\.[[:alnum:]_-]\+\.[^[:space:]'\"<>]\+\)[[:alnum:]/]"
+
+" TODO: Use better syncing. I don’t know the specifics of syncing well enough,
+" though.
syn sync minlines=50
-hi def link rstTodo Todo
-hi def link rstComment Comment
-hi def link rstDelimiter Delimiter
-hi def link rstBlock String
-hi def link rstDoctestBlock PreProc
-hi def link rstTableLines Delimiter
-hi def link rstSimpleTableLines rstTableLines
-hi def link rstFootnote String
-hi def link rstFootnoteLabel Identifier
-hi def link rstCitation String
-hi def link rstCitationLabel Identifier
-hi def link rstDirective Keyword
-hi def link rstDirectiveBody Type
-hi def link rstSubstitution String
-hi def link rstSubstitutionLbl Identifier
-hi def link rstHyperlinks String
-hi def link rstHyperlinksLabel Identifier
-hi def link rstListItem Identifier
-hi def rstInline term=italic cterm=italic gui=italic
-hi def rstInternalTarget term=italic cterm=italic gui=italic
+hi def link rstTodo Todo
+hi def link rstComment Comment
+"hi def link rstSections Type
+"hi def link rstTransition Type
+hi def link rstLiteralBlock String
+hi def link rstQuotedLiteralBlock String
+hi def link rstDoctestBlock PreProc
+hi def link rstTableLines rstDelimiter
+hi def link rstSimpleTableLines rstTableLines
+hi def link rstExplicitMarkup rstDirective
+hi def link rstDirective Keyword
+hi def link rstFootnote String
+hi def link rstCitation String
+hi def link rstHyperlinkTarget String
+hi def link rstExDirective String
+hi def link rstSubstitutionDefinition rstDirective
+hi def link rstDelimiter Delimiter
+" TODO: I dunno...
+hi def rstEmphasis term=italic cterm=italic gui=italic
+hi def link rstStrongEmphasis Special
+"term=bold cterm=bold gui=bold
+hi def link rstInterpretedTextOrHyperlinkReference Identifier
+hi def link rstInlineLiteral String
+hi def link rstSubstitutionReference PreProc
+hi def link rstInlineInternalTargets Identifier
+hi def link rstFootnoteReference Identifier
+hi def link rstCitationReference Identifier
+hi def link rstHyperLinkReference Identifier
+hi def link rstStandaloneHyperlink Identifier
let b:current_syntax = "rst"