ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* TeX + Metapost syntax highlighting in Vim
@ 2005-07-08 16:10 Mojca Miklavec
  2005-07-08 17:48 ` Thomas A. Schmitz
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Mojca Miklavec @ 2005-07-08 16:10 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1189 bytes --]


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

[-- Attachment #2: context.vim --]
[-- Type: text/plain, Size: 3074 bytes --]

" Vim syntax file
" Language:	   ConTeXt
" Maintainer:  Mojca Miklavec <mojca.miklavec@guest.arnes.si>
" 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:

[-- Attachment #3: Type: text/plain, Size: 139 bytes --]

_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2005-09-24 21:41 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-08 16:10 TeX + Metapost syntax highlighting in Vim Mojca Miklavec
2005-07-08 17:48 ` Thomas A. Schmitz
2005-07-08 22:14   ` VnPenguin
2005-07-14 14:50   ` Christopher Creutzig
2005-07-14 16:16     ` Thomas A. Schmitz
2005-07-08 17:53 ` Hans Hagen
2005-07-08 21:32   ` Nikolai Weibull
2005-07-12 13:38     ` Mojca Miklavec
2005-07-08 21:28 ` Nikolai Weibull
2005-07-14 19:19   ` VnPenguin
2005-07-15 16:01     ` Nikolai Weibull
2005-09-24 21:41     ` Nikolai Weibull

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).