[Wheat-developer] vim syntax file for Wheat
Status: Pre-Alpha
Brought to you by:
mark_lentczner
|
From: Kragen S. <ksi...@co...> - 2005-04-05 02:25:53
|
This does a reasonable job of syntax-highlighting Wheat code in Vim. It even handles some of the hard stuff, like multiline strings, multiline comments, nested multiline strings, and nested multiline comments. It also allows Vim to do a reasonable job of folding Wheat code according to syntax, and makes the #, *, and ^] commands do pretty much the right thing. (It doesn't, sadly, make ctags do the right thing.) For whatever reason, syncing on comments and handling of the "." character seem a little flaky. Where should things like this go inside the source repository? And where on the web site? " Vim syntax file " Language: Wheat " Maintainer: Kragen Sitaker <kr...@po...> " Last Change: 2005-04-04 " Location: http://wheatfarm.org/wheat.vim " Remark: Incomplete but better than nothing. setlocal iskeyword+=- syn keyword Conditional if else syn keyword Repeat while syn keyword Keyword return syn keyword Boolean true false syn match Number "[0-9]\+" syn match Float "\.[0-9]\+" syn match Float "[0-9]\+\.[0-9]*" syn match Delimiter "[:;]" " what to do with #, \, and $? Or .? " Clearly [:*+-/%]= is too restrictive, but I don't actually know Wheat's " grammar well enough to know what the grammar for new in-place operators is. syn match Operator "!\|!!\|?\|??\|->\|&&\|||\|[*+-/%]=\?\|:=\|[!=]=\|\~" syn match Constant "???\|!!!" syn match Identifier "[-a-zA-Z][-a-zA-Z0-9]*" syn match Identifier "'[^']*'" syn match Comment "``.*" syn region wheatBlockComment start="``(" end="``)" contains=wheatBlockComment fold hi def link wheatBlockComment Comment " For folding, we define these separately from the other delimiters. To use " this, :set foldmethod=syntax and move around doing zo, zc, and maybe zm and " zr. syn region wheatSexpr matchgroup=Delimiter start="{" end="}" contains=ALL fold syn region wheatSexpr matchgroup=Delimiter start="\[" end="]" contains=ALL fold syn region wheatSexpr matchgroup=Delimiter start="(" end=")" contains=ALL fold syn region String start=+"+ end=+"+ skip=+\\"+ fold syn region wheatString start=+""(+ end=+"")+ contains=wheatString fold hi def link wheatString string " TODO: " ellipses? " more operators " Should we really treat !!! as a constant? Incidentally the !!/!!! ambiguity " confuses Vim. " Filetype autodetection. My .vimrc says: " " au BufRead,BufNewFile *.ws setf wheat " au! Syntax wheat source $HOME/wheat.vim " Should probably also do something along the lines of: " if did_filetype() " finish " endif " if getline(1) =~ '^wheat(version:' " setf wheat " endif |