Vim syntax file (CFDG file type)

Here you can discuss and share functionality improvements and helper programs to make Context Free better.

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
MLDaeni
Posts: 5
Joined: Fri Oct 20, 2006 6:38 am

Vim syntax file (CFDG file type)

Post by MLDaeni »

For those using Linux and Vim, here a syntax highlighting file based on cpp.vim. It is not extensively tested but so far it worked OK for me (tested with vim7). It might work on Windows, but I never tested.

Save it to a file name cfdg.vim and place it in $HOME/.vim/syntax directory. Make it active by adding the following lines to your .vimrc (or .gvimrc):

Code: Select all

" syntax for .cfdg files
au BufNewFile,BufRead *.cfdg,*.CFDG	setf cfdg
Cheers,
MLDaeni

Code: Select all

==========================================
" Vim syntax file
" Language:	CFDG
" Maintainer:	unmaintained
" Last Change:	Fri Oct 27 15:27 GMT 2006
" Adapted from cpp.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
if version < 600
  so <sfile>:p:h/c.vim
else
  runtime! syntax/c.vim
  unlet b:current_syntax
endif

" CFDG extentions
syn keyword cfdgStatement		startshape include rule
syn keyword cfdgPrimitiveShape	SQUARE TRIANGLE CIRCLE
syn keyword cfdgTransform		x y z skew size s rotate r flip f
syn keyword cfdgColor			hue h saturation sat brightness b alpha a
syn match	cfdgTargetModifier	"|"
syn match   cfdgComment			"#.*$"

" Default highlighting
if version >= 508 || !exists("did_cfdg_syntax_inits")
  if version < 508
    let did_cfdg_syntax_inits = 1
    command -nargs=+ HiLink hi link <args>
  else
    command -nargs=+ HiLink hi def link <args>
  endif
  HiLink cfdgStatement			Keyword
  HiLink cfdgPrimitiveShape		Statement
  HiLink cfdgTransform			Type
  HiLink cfdgColor				String
  HiLink cfdgTargetModifier		Keyword
  HiLink cfdgComment			Comment
  delcommand HiLink
endif

let b:current_syntax = "cfdg"

" vim: ts=8
==========================================

User avatar
MtnViewJohn
Site Admin
Posts: 882
Joined: Fri May 06, 2005 2:26 pm
Location: Mountain View, California
Contact:

Post by MtnViewJohn »

Cool! But don't forget to add 'background' to cfdgStatement.

MLDaeni
Posts: 5
Joined: Fri Oct 20, 2006 6:38 am

Post by MLDaeni »

Cool! But don't forget to add 'background' to cfdgStatement.
True! After some more testing, if everything is OK, I might sent it to Bram Moolenaar for the inclusion in the main Vim distribution.

After some thinking, I suppose there is no need for a linux graphics version. I use Vim to edit cfdg file, command line to call the interpreter, and kview to diaplay automatically reload the image, once it updates on disk.

User avatar
MtnViewJohn
Site Admin
Posts: 882
Joined: Fri May 06, 2005 2:26 pm
Location: Mountain View, California
Contact:

Post by MtnViewJohn »

Before you send it to Bram Moolenaar please add the tile statement. This is a new statement in Context Free 2.1beta (which I just posted).

Post Reply