X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/halibut/blobdiff_plain/116b7f38b11fec85341412bd57501030ec599228..0dfaac7284d7f1a54e957bba4a881d93328c1630:/misc/halibut.vim diff --git a/misc/halibut.vim b/misc/halibut.vim index 984ac63..49b2380 100644 --- a/misc/halibut.vim +++ b/misc/halibut.vim @@ -1,16 +1,21 @@ " Vim syntax file " Language: Halibut " Maintainer: Jacob Nevins -" URL: FIXME +" URL: http://www.chiark.greenend.org.uk/~sgtatham/halibut/ " Filenames: *.but -" Version: $Id: halibut.vim,v 1.2 2004/04/01 01:12:21 jtn Exp $ +" Version: $Id: halibut.vim,v 1.12 2004/07/16 12:54:59 jacob Exp $ -" I'm not proud of this. Every time I tangle with vim's syntax highlighting -" I come away unsatisfied. Nevertheless, it seems to work. +" I've never been entirely comfortable with vim's syntax highlighting +" facilities, so this may have all sorts of nasty loose ends, corner cases +" etc, but it works for me. " I have no idea if it's compatible with vim <6.1. " Based on docs in Halibut CVS 2004-03-31 +" FIXME: +" - sync - last blank line, \quote, \lcont +" - add "display" etc for speed? + " Rune from vim 6.1 help " For version 5.x: Clear all syntax items " For version 6.x: Quit when a syntax file was already loaded @@ -31,12 +36,14 @@ syn match butIllegalChar "\\" " Simple-minded fallback to highlight any command we don't recognise, " and assume it has textual arguments. -" XXX highlights all of "\date)." -syn match butCmdGeneric "\\\(\S\&[^{}\\]\)\+" nextgroup=butTextArg -" was: [A-Za-z0-9#]\+ +" (matches current iscmd() in input.c; there are some oddballs which +" don't fit this handled specially below) +syn match butCmdGeneric "\\[A-Za-z0-9]\+" nextgroup=butTextArg syn cluster butText contains=butLiteral,@butCmd,butTodo +" The special one-character "commands". +" XXX might want to split up? Can all these appear in \k{...}? syn match butLiteral "\\[-{}_.\\]" " This isn't specific to Halibut, but is often useful. @@ -53,21 +60,23 @@ syn region butQLEmph matchgroup=butCmdSpecific start="\\e\_s\@=" matchgroup=NO syn match butQLEmphInv "\S\@=[^bi]" contained " Paragraph level comment -- might need to come before inline comment. -syn region butCommentPara start="\\#\_s\@=" end="^\s*$" contains=butTodo +syn region butCommentPara start="\\#" end="^\s*$" contains=butTodo " Inline comments -- nested braces are honoured. -syn region butComment matchgroup=Comment start="\\#{" end="}" contains=butCommentBrace,butTodo -syn region butCommentBrace start="{" end="}" contains=butCommentBrace,butTodo contained transparent +syn region butComment matchgroup=Comment start="\\#{" skip="\\}" end="}" contains=butCommentBrace,butTodo +syn region butCommentBrace start="{" skip="\\}" end="}" contains=butCommentBrace,butTodo contained transparent " Section headings - a bit hairy. Order wrt rest of file is important. -syn match butCmdSpecific "\\\(S\d\|[CAHSU]\)" nextgroup=butIdentArgH +syn match butCmdSpecific "\\\(S\d\|[CAHS]\)" nextgroup=butIdentArgH " butIdentArgH -> butTextArgH? -> this, which highlights the rest of the para: syn region butTextHeading start="" end="^\s*$" contained contains=@butText +" Unadorned headings +syn match butCmdSpecific "\\U\_s\@=" nextgroup=butTextHeading " ...and overall title -syn match butCmdSpecific "\\title" nextgroup=butTextHeading +syn match butCmdSpecific "\\title\_s\@=" nextgroup=butTextHeading -" Bulleted lists -syn match butCmdSpecific "\\\(b\|n\|dd\)" nextgroup=butIdentArg +" Bulleted lists -- arguments optional +syn match butCmdSpecific "\\\(b\|n\|dd\)[^A-Za-z0-9]\@=" nextgroup=butIdentArg " Config syn match butCmdSpecific "\\cfg{\@=" nextgroup=butCfgArg @@ -82,20 +91,21 @@ syn match butCmdSpecific "\\define{\@=" nextgroup=butIdentArg " Specific inline commands " (Some of these are defined out of paranoia about clashes with code quotes.) +" Indexing -- invisible entries. (includes \I\c, \I\cw; \I\e left; no \q, \cq) +syn match butCmdSpecific "\\I\(\\cw\|\\c\)\={\@=" nextgroup=butIndexArg " Formatting. syn match butCmdSpecific "\\e{\@=" nextgroup=butEmphArg syn match butCmdSpecific "\\c{\@=" nextgroup=butTextArg syn match butCmdSpecific "\\cw{\@=" nextgroup=butTextArg +syn match butCmdSpecific "\\cq{\@=" nextgroup=butTextArg syn match butCmdSpecific "\\W{\@=" nextgroup=butHyperArg -" Indexing -- invisible entries. -syn match butCmdSpecific "\\I{\@=" nextgroup=butIndexArg " Xref commands syn match butCmdSpecific "\\[kK]{\@=" nextgroup=butIdentArg " Unicode literal -- a bit special. -syn match butLiteral "\\u\x*" nextgroup=butTextArg +syn match butLiteral "\\u\x\{,4}" nextgroup=butTextArg " Command cluster. -syn cluster butCmd contains=butCmdGeneric,butCmdSpecific,ButComment +syn cluster butCmd contains=butCmdGeneric,butCmdSpecific,butComment,butQuoteLit,butQLEmph,butCommentPara,butLiteral " Types of argument. XXX is this cluster still useful? syn cluster butArgument contains=butTextArg,butIdentArg,butEmphArgmbutCfgArg,butIdentArgH,butTextArgH @@ -113,9 +123,9 @@ syn region butHyperArg matchgroup=butDelimiter start="{" skip="\\}" end="}" cont " Specific hack for \I{} syn region butIndexArg matchgroup=butDelimiter start="{" skip="\\}" end="}" contained contains=@butText " Specific hack for \IM{}{}... -syn region butIMArg matchgroup=butDelimited start="{" skip="\\}" end="}" contained nextgroup=butIMArg contains=@butText +syn region butIMArg matchgroup=butDelimiter start="{" skip="\\}" end="}" contained nextgroup=butIMArg contains=@butText " Default argument (due to being last). -syn region butTextArg matchgroup=butDelimiter start="{" skip="\\}" end="}" nextgroup=@butArgument contained contains=@butText +syn region butTextArg matchgroup=butDelimiter start="{" skip="\\}" end="}" nextgroup=@butArgument contained contains=@butText transparent " Rune from vim 6.1 help if version >= 508 || !exists("did_halibut_syn_inits")