[chuck-users] VIM users

Martin Ahnelöv operagasten at gmail.com
Wed Oct 31 06:13:09 EDT 2007


ons 2007-10-31 klockan 02:13 +0100 skrev eduard aylon:
> Excuseme I didn't quite understand you cause I didn't know anyone was  
> working on it and I  now see you've been doing some work there. I  
> think they both do sort of the same.
> 
> I'll keep myself updated on that link,

Well, actually, your seems to have just a tiny bit more features than
the one currently on the wiki, and you seems to know what you're doing
(I'm just copying and modifying blindly), so I think you should replace
the one on the wiki with this one. If you want to.

I'm attaching a new version of the one you sent in your first post, but
with added support for the new "<--"-comments (line 126 and 129), and
highlighting for +=>, and similar (however, it's also highlighting +=^.
Is this correct, kassen, spencer, ge?) (line 187).

One thing, though:

For the markup of the complex numbers I'm using this regex: 
"\(%\|#\)\ze(". That'll make the # or % coloured if it's followed by a
"(" (which is uncoloured). This makes the highlight look like the
example-code in Perry, Ge and Rebeccas paper
http://soundlab.cs.princeton.edu/publications/uana_icmc2007.pdf .
What do you think?

Cheers,
Gasten
-------------- next part --------------
" Vim syntax file
" Language:	CHUCK
" Adapted by Eduard Aylon <eduard.aylon at gmail.com> from the c.vim syntax file from Bram Moolenar <Bram at vim.org>

" Last Update: 27/10/07
" NOTE: in order to obtain syntax highlighting in Chuck programs just follow the
"       steps below or in case you don't have root privileges follow Graham Percival's tip : 
"	1. copy this file into /usr/share/vim/vim62/syntax.
"	2. add the following line in /usr/share/vim/vim62/filetype.vim, 
"       
"		au BufNewFile,BufRead *.ck          setf ck
"		

" NOTE: Tip from Graham Percival for those who cannot write to /usr/share/  (lacking
" root privileges),  enter these commands:
    "     $ echo "syntax on" >> ~/.vimrc
    "     $ mkdir ~/.vim
    "     $ mkdir ~/.vim/syntax
    "     $ cp ck.vim ~/.vim/syntax/
    "     $ echo "if exists(\"did_load_filetypes\")
    "           finish
    "         endif
    "         augroup filetypedetect
    "          au! BufNewFile,BufRead *.ck setf ck
    "          augroup END" >> ~/.vim/filetype.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

" Read the C syntax to start with
" This should be changed as there are many features in the C-language which are not
" present in CHUCK
"if version < 600
"  so <sfile>:p:h/c.vim
"else
"  runtime! syntax/c.vim
"  unlet b:current_syntax
"endif

"----------------------------------------------------------------------------------------------
syn keyword	cTodo		contained TODO FIXME XXX

" cCommentGroup allows adding matches for special things in comments
syn cluster	cCommentGroup	contains=cTodo

"----------------------------------------------------------------------------------------------

"catch errors caused by wrong parenthesis and brackets
" also accept <% for {, %> for }, <: for [ and :> for ] (C99)
syn cluster	cParenGroup	contains=cParenError,cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String, at cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cBitField,cCommentSkip,cOctalZero,cCppOut,cCppOut2,cCppSkip,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom
if exists("c_no_bracket_error")
  syn region	cParen		transparent start='(' end=')' contains=ALLBUT, at cParenGroup,cCppParen,cCppString
  " cCppParen: same as cParen but ends at end-of-line; used in cDefine
  syn region	cCppParen	transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT, at cParenGroup,cParen,cString
  syn match	cParenError	display ")"
  syn match	cErrInParen	display contained "[{}]\|<%\|%>"
else
  syn region	cParen		transparent start='(' end=')' contains=ALLBUT, at cParenGroup,cCppParen,cErrInBracket,cCppBracket,cCppString
  " cCppParen: same as cParen but ends at end-of-line; used in cDefine
  syn region	cCppParen	transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT, at cParenGroup,cErrInBracket,cParen,cBracket,cString
  syn match	cParenError	display "[\])]"
  syn match	cErrInParen	display contained "[\]{}]\|<%\|%>"
  syn region	cBracket	transparent start='\[\|<:' end=']\|:>' contains=ALLBUT, at cParenGroup,cErrInParen,cCppParen,cCppBracket,cCppString
  " cCppBracket: same as cParen but ends at end-of-line; used in cDefine
  syn region	cCppBracket	transparent start='\[\|<:' skip='\\$' excludenl end=']\|:>' end='$' contained contains=ALLBUT, at cParenGroup,cErrInParen,cParen,cBracket,cString
  syn match	cErrInBracket	display contained "[);{}]\|<%\|%>"
endif

"----------------------------------------------------------------------------------------------

"integer number, or floating point number without a dot and with "f".
syn case ignore
syn match	cNumbers	display transparent "\<\d\|\.\d" contains=cNumber,cFloat
" Same, but without octal error (for comments)
"syn match	cNumbersCom	display contained transparent "\<\d\|\.\d" contains=cNumber,cFloat
"syn match	cNumber		display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>"
syn match	cFloat		display contained "\d\+"
"Floating point number with leading dot:
syn match	cFloat		display contained ".\d\+"
"Floating point number with endding dot:
syn match	cFloat		display contained "\d\.\+"
"floating point number, with dot: 
syn match	cFloat		display contained "\d\+\.\d+"

" numbers below are not yet available in Chuck
""hex number
""syn match	cNumber		display contained "0x\x\+\(u\=l\{0,2}\|ll\=u\)\>"
"" Flag the first zero of an octal number as something special
""syn match	cOctal		display contained "0\o\+\(u\=l\{0,2}\|ll\=u\)\>" contains=cOctalZero
""syn match	cOctalZero	display contained "\<0"
""floating point number, with dot, optional exponent
"syn match	cFloat		display contained "\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\="
""floating point number, starting with a dot, optional exponent
"syn match	cFloat		display contained "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
""floating point number, without dot, with exponent
"syn match	cFloat		display contained "\d\+e[-+]\=\d\+[fl]\=\>"
"if !exists("c_no_c99")
"  "hexadecimal floating point number, optional leading digits, with dot, with exponent
"  syn match	cFloat		display contained "0x\x*\.\x\+p[-+]\=\d\+[fl]\=\>"
"  "hexadecimal floating point number, with leading digits, optional dot, with exponent
"  syn match	cFloat		display contained "0x\x\+\.\=p[-+]\=\d\+[fl]\=\>"
"endif

"----------------------------------------------------------------------------------------------

" cCommentGroup allows adding matches for special things in comments
syn cluster     cCommentGroup   contains=cTodo

if exists("c_comment_strings")
  " A comment can contain cString, cCharacter and cNumber.
  " But a "*/" inside a cString in a cComment DOES end the comment!  So we
  " need to use a special type of cString: cCommentString, which also ends on
  " "*/", and sees a "*" at the start of the line as comment again.
  " Unfortunately this doesn't very well work for // type of comments :-(
  syntax match	cCommentSkip	contained "^\s*\*\($\|\s\+\)"
  syntax region cCommentString	contained start=+L\=\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end=+\*/+me=s-1 contains=cSpecial,cCommentSkip
  syntax region cComment2String	contained start=+L\=\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end="$" contains=cSpecial
  syntax region  cCommentL	start="\(//\|<--\)" skip="\(//\|<--\)$" end="$" keepend contains=@cCommentGroup,cComment2String,cCharacter,cNumbersCom,cSpaceError
  syntax region cComment	matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cCommentString,cCharacter,cNumbersCom,cSpaceError
else
  syn region	cCommentL	start="\(//\|<--\)" skip="\(//\|<--\)$" end="$" keepend contains=@cCommentGroup,cSpaceError
  syn region	cComment	matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cSpaceError
endif
" keep a // comment separately, it terminates a preproc. conditional
syntax match	cCommentError	display "\*/"
syntax match	cCommentStartError display "/\*"me=e-1 contained

"----------------------------------------------------------------------------------------------

" String and Character constants
" Highlight special characters (those which have a backslash) differently
syn match	cSpecial	display contained "\\\(x\x\+\|\o\{1,3}\|.\|$\)"
if !exists("c_no_utf")
  syn match	cSpecial	display contained "\\\(u\x\{4}\|U\x\{8}\)"
endif
if exists("c_no_cformat")
  syn region	cString		start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial
  " cCppString: same as cString, but ends at end of line
  syn region	cCppString	start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial
else
  syn match	cFormat		display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlL]\|ll\)\=\([diuoxXDOUfeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained
  syn match	cFormat		display "%%" contained
  syn region	cString		start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat
  " cCppString: same as cString, but ends at end of line
  syn region	cCppString	start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat
endif
"----------------------------------------------------------------------------------------------



" CHUCK extentions
syn keyword ckConditional 	if else switch switch
syn keyword ckRepeat		for until while do repeat
syn keyword cString		string
syn keyword ckStatement	        new goto break return continue this
syn match   ckSpork 	        "\s*spork\s*\~\s*"
syn keyword ckLoop		until
syn keyword ckNow               now 
syn keyword ckType              dur time Shred UGen Event Object 
syn keyword ckType              void int float same complex polar
syn match   ckTime		"\::\(samp\|ms\|second\|minute\|hour\|day\|week\)\s*"
syn keyword ckTime		samp ms second minute hour day week 
"syn keyword ckOperator		and bitor or xor compl bitand and_eq or_eq xor_eq not not_eq
syn match ckCast               "\s*\$\s*\(int\|float\|polar\|complex\)\s*"
syn keyword ckClass		class fun function 
syn keyword ckStorageClass	static const
syn keyword ckAccess		public protected private pure
syn keyword ckUgen		Gain Noise CNoise Impulse Step Phasor SinOsc PulseOsc TriOsc SqrOsc SawOsc HalfRect FullRect ZeroX DelayP SndBuf Pan2 Mix2 Gen5 Gen7 Gen9 Gen10 Gen17 CurveTable WarpTable Dyno LiSa
syn keyword ckSDK               bandedWG blowbotl BlowHole Bowed Brass Clarinet Flute Mandolin ModalBar Moog Saxofony Shakers Sitar StifKarp VoicForm FM BeeThree FMVoices HevyMetl PercFlut Rhodey TubeBell Wurley Delay DelayA DelayL Echo Envelope ADSR BiQuad Filter OnePole TwoPole OneZero TwoZero PoleZero JCRev NRev PRCRev Chorus Modulate PitShift SubNoise WvIn WvOut WaveLoop Blit BlitSquare BlitSaw LPF HPF BPF BRF ResonZ FilterBasic
syn keyword ckAnalysis		UAna UAnaBlob Windowing FFT IFFT DCT IDCT
syn keyword ckFeatures		Centroid Flux RMS RollOff
syn keyword ckBoolean		true false maybe
syn keyword ckShreds            me Machine
syn keyword ckInheritance       subClass extends 
syn keyword ckIO                dac adc blackhole 
syn keyword ckNetwork           netin netout
syn keyword ckCommunication     MidiIn MidiOut MidiMsg OscRecv OscEvent OscSend Hid HidIn HidMsg KBHit
syn keyword ckConstant 		pi null NULL
syn match   ckOperator          "\s*\(+\|-\|/\|*\|\s*\)=\(>\|<\|\^\)\s*"          
syn match   ckReference         "\s*@\s*=\(>\|<\)\s*"          

"----------------------------------------------------------------------------------------------
"complex numbers

"(4, 4)
syn match   ckComplex		"\s*\(\#\|%\)\s*(\s*\d\+\s*\,\s*\d\+\s*)\s*"
"(4., 4.)
syn match   ckComplex		"\s*\(\#\|%\)\s*(\s*\d\+\.\s*\,\s*\d\+\.\s*)\s*"
"(4.44, 4.44)
syn match   ckComplex		"\s*\(\#\|%\)\s*(\s*\d\.\d\+\s*\,\s*\d\.\d\+\s*)\s*"
"(44.44, 44.44)
syn match   ckComplex		"\s*\(\#\|%\)\s*(\s*\d\+\.\d\+\s*\,\s*\d\+\.\d\+\s*)\s*"
"(4., 4.4)
syn match   ckComplex		"\s*\(\#\|%\)\s*(\s*\d\+\.\s*\,\s*\d\+\.\d\+\s*)\s*"
"(4., 4)
syn match   ckComplex		"\s*\(\#\|%\)\s*(\s*\d\+\.\s*\,\s*\d\+\s*)\s*"
"(.4, .4)
syn match   ckComplex		"\s*\(\#\|%\)\s*(\s*\.\d\+\s*\,\s*\.\d\+\s*)\s*"
"(.4, 4)
syn match   ckComplex		"\s*\(\#\|%\)\s*(\s*\.\d\+\s*\,\s*\d\+\s*)\s*"
"(4, .4)
syn match   ckComplex		"\s*\(\#\|%\)\s*(\s*\d\+\s*\,\s*\.\d\+\s*)\s*"
"(4.4, 4)
syn match   ckComplex		"\s*\(\#\|%\)\s*(\s*\d\+\.\d\+\s*\,\s*\d\+\s*)\s*"
"(4, 4.)
syn match   ckComplex		"\s*\(\#\|%\)\s*(\s*\d\+\s*\,\s*\d\+\.\s*)\s*"
"(4, 4.4)
syn match   ckComplex		"\s*\(\#\|%\)\s*(\s*\d\+\s*\,\s*\d\+\.\d\+\s*)\s*"


" The minimum and maximum operators in GNU C++
syn match cppMinMax "[<>]?"

" Default highlighting
if version >= 508 || !exists("did_cpp_syntax_inits")
  if version < 508
    let did_cpp_syntax_inits = 1
    command -nargs=+ HiLink hi link <args>
  else
    command -nargs=+ HiLink hi def link <args>
  endif

  HiLink ckCommunication        Special
  HiLink ckNetwork              Special
  HiLink cCommentL		cComment
  HiLink cCommentStart		cComment
  HiLink cComment 		Comment
  HiLink cCppString             cString
  HiLink cString		String
  HiLink ckClass		Conditional
  HiLink ckStorageClass		StorageClass
  HiLink ckLoop			Repeat
  HiLink ckAccess		ckStatement
  HiLink ckUgen                 ckType
  HiLink ckSDK                  ckType
  HiLink ckStatement		Statement
  HiLink ckConditional		Conditional
  HiLink ckRepeat		Repeat
  HiLink ckSpork		Statement
  HiLink ckCast 		ckStatement
  HiLink ckNow			Special
  HiLink ckType		        Type
  HiLink cType		        Type
  HiLink ckStructure		Structure
  HiLink ckOperator		Operator	
  HiLink ckReference		Operator	
  HiLink ckShreds		ckStatement
  HiLink ckInheritance		ckStatement
  HiLink ckBoolean		Boolean
  HiLink ckIO			Number
  HiLink ckTime			Number
  HiLink cParenError		cError
  HiLink cErrInBracket		cError
  HiLink cErrInParen		cError
  HiLink cParen			cError
  HiLink cCppParen		cError
  HiLink cBracket	  	cError
  HiLink cCppBracket	  	cError
  HiLink cError			Error
  HiLink ckNumber		Number
  HiLink cNumber		Number
  HiLink cNumbers		Number
  HiLink cNumbersCom		Number
  HiLink cFloat 		Number
  HiLink ckPolar		Number
  HiLink ckComplex		Number
  HiLink ckConstant		Constant
  HiLink ckAnalysis		ckType
  HiLink ckFeatures		ckType
  HiLink cTodo                  Todo
  
  delcommand HiLink
endif

let b:current_syntax = "ck"

" vim: ts=8


More information about the chuck-users mailing list