In case someone finds this experimental piece of code for highlighting
metapost inside ConTeXt useful, put:
" ConTeXt
augroup filetypedetect
au! BufRead,BufNewFile *.tex setfiletype context
augroup END
somewhere to your filetype.vim (probably after TeX) and move the
attached file to syntax\context.vim.
If you have something like
\startMPpage
draw ...
\stopMPpage,
it will do the syntax highligting for metapost inside the \start-\stop pair.
There are still some "bugs" present (see comments in file), but I don't
know how yet to get rid of them.
I downloaded SpellChecker and SuperTab (autocomplete) today from the vim
website and it works great! (see http://contextgarden.net/Vim and feel
free to add any useful stuff there)
I was astonished as I saw autocomplete work. There are only a couple of
lines with an extraordinary functionality. I think that if someone
writes a good script to convert texshow to vim syntax highlighting
script, than autocomplete will be able to provide good hints for all the
existing commands in ConTeXt and the corresponding parameters. I'll try
to see what I can do, but please don't excpect any results too soon.
Mojca
" Vim syntax file
" Language: ConTeXt
" Maintainer: Mojca Miklavec
" Installation:
" To automatilcally load this file when a .tex file is opened, add the
" following lines to ~/.vim/filetype.vim:
"
" augroup filetypedetect
" au! BufRead,BufNewFile *.tex setfiletype context
" augroup END
"
" You will have to restart vim for this to take effect. In any case it
" is a good idea to read ":he new-filetype" so that you know what is going
" on, and why the above lines work.
" Adapted from eruby by Michael Brailsford (Thanks for the idea!)
"
" This is just a testing version.
" TODO:
" - adapt tex.vim for plain TeX + ConTeXt support only (no LaTeX!!!)
" - add MetaFun support on the top of Metapost
" - add all the possible \start ... \stop delimiters which switch the
" syntax highlighting to MetaFun, XML, JavaScript, ...
"
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
"Source the tex syntax file
runtime! syntax/tex.vim
"Set the filetype to tex to load the tex %??? ftplugins
set ft=tex
unlet b:current_syntax
" Put the metafun syntax file in @metafunTop
"
" TODO: should be changed to metafun once the support is there
" javascript should probably be adapted to PDF specification too, but it
" changes in every version anyway and doesn't work either
"
syn include @metafunTop syntax/mp.vim
" for some reason I can't make both metapost and javascript working at the same time
"syn include @javascriptTop syntax/javascript.vim
syn region metafunBlock matchgroup=metafunDelim start=#\\startMPpage# end=#\\stopMPpage# keepend contains=@metafunTop
" TODO: \startuseMPgraphic{the name} - "the name" has to be catched and
" typeset in ConTeXt, not in metapost!!!
" \start..MP.. may not be inside comments!!!
syn region metafunBlock matchgroup=metafunDelim start=#\\startMPinclusions# end=#\\stopMPinclusions# keepend contains=@metafunTop
syn region metafunBlock matchgroup=metafunDelim start=#\\startMPgraphic# end=#\\stopMPgraphic# keepend contains=@metafunTop
syn region metafunBlock matchgroup=metafunDelim start=#\\startuseMPgraphic# end=#\\stopuseMPgraphic# keepend contains=@metafunTop
syn region metafunBlock matchgroup=metafunDelim start=#\\startreusableMPgraphic# end=#\\stopreusableMPgraphic# keepend contains=@metafunTop
syn region metafunBlock matchgroup=metafunDelim start=#\\startuniqueMPgraphic# end=#\\stopuniqueMPgraphic# keepend contains=@metafunTop
syn region metafunBlock matchgroup=metafunDelim start=#\\startMPrun# end=#\\stopMPrun# keepend contains=@metafunTop
" comments have to be added, \startJScode{name}, "name" has to be catched and
" typeset in ConTeXt, not in javascript
syn region javascriptBlock matchgroup=javascriptDelim start=#\\startJScode# end=#\\stopJScode# keepend contains=@javascriptTop
syn region javascriptBlock matchgroup=javascriptDelim start=#\\startJSpreamble# end=#\\stopJSpreamble# keepend contains=@javascriptTop
hi link metafunDelim texSTatement
hi link javascriptDelim texSTatement
let b:current_syntax = "context"
" vim: set ts=4 sw=4: