Nikolai Weibull wrote:
I don't want to be a party-pooper, but I have already commited support for the context file-type to vim7 CVS. Perhaps you can look over my version and make suggestions?
That's great! I didn't know that. Some time ago some people were asking about ConTeXt support for vim, but I don't remember any responses. I like the "contains=@NoSpell" syntax and there are much more highlights in your code. Quite some pieces of code can still be added of course, but writing a good syntax highlighting scheme may become almost as is almost as tricky as writing a compiler for it :) \title, \subject, ... can be added Maybe some more extensive support for math as well ...
It doesn't use the rather bloated LaTeX/Plain TeX syntax definition, but my own blend,
Probably the opinions on what "bloated" means differ at that point. I find it very useful if wrong brackets or any other suspicious code is marked as an error before the compiler has to tell me that (and for an unexperienced user it is very difficult to find such a mistake from compiler messages). I'm very glad that your code got rid of LaTeX commands, but I find it great if we keep extending the code. Moreover, I even wanted to have command-specific code highlighting. ConTeXt has a big advantage over LaTeX: the central development. So theoretically it would be possible to highlight any known command different as the unknown (user-defined or misspelled) ones. PostScript syntax highlighting script in vim does exactly that for example. I wanted to suggest to make a cont-en.vim (cont-nl.vim, ..., maybe also tex-plain.vim) file with all the known ConTeXt commands. I don't know vim that well. I can imagine that this would cause some problems on slower machines, but including it would only be left as an option.
(Sorry for responding to two separate mails, I'm a bit rushed, going on a three-day holiday.)
Hans Hagen wrote:
Mojca Miklavec wrote:
If you have something like \startMPpage draw ... \stopMPpage, it will do the syntax highligting for metapost inside the \start-\stop pair.
That's a great idea, I'll add that to my version
I made some corrections to it (off-list), but it is still far away from being perfect. If you know how to correct some pecculiarities mentioned in the comments, please do so and then adapt the code to fit into your highlighting script. It would be great if someone could give some hints about which commands switch the mode of typesetting: - startformula ... \stopformula - startbuffer ... \stopbuffer (I would highlight the content for "buffer" as a string) - \start???MP??? ...\stop???MP??? - start???XML??? ... \stop???XML???
Version 7 has a spell-checker built in.
I noticed that. But I suppose I'll wait for an official version of Vim to come out. "contains=@NoSpell" should probably also be added to mp.vim and mf.vim.
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.
There's always the ever-simple CTRL-P/CTRL-N as well.
I just noticed that autocomplete is in no way as clever as syntax-highlighting is. It would be great if there would exist a similar support as the one for Java in Eclipse (only the keywords that make sense in the current context are offered for autocompletion). An example would be: if someone writes \adaptlayout[<ctrl-something> only the options height= and lines= would be offered. But at that point I have to answer to myself: "dream on!" It is probably possible, but too complex at this moment.
What is the syntax? I can exten ctstools to spit out a vim keyword table; it already handles scite, jedit and bbedit so adding vim is not undoable
Download vim and run :help syntax. But the short version is
syn keyword contextKeyword ... ^-- group name ^-- keywords
But that won't work for stuff beginning with \\. Then you'll have to use regexes and
syn match contextKeyword ... ^-- regex
Exactly what kind of keyword table are we talking about?,
My most optimistic version: [all] of the commands defined in ConTeXt (see also the comments above), together with some additional checking if \start-s have their corresponding \stop-s and if parameters in the brackets are applicable for the command they belong too. \adaptlayout[lines=30,somestupidparameter=1] would thus highlight the valid "lines=" different from "somestupidparameter=1" \setupblackrules[alternative=c] would mark "c" as invalid (only a and b are possible). And already the first obstacle I came across: How can I define a regexp matching the [ ... ] area? Note that \firstcommand[ command={\secondcommand[x]}, text=$]$ ] Quite some work to do ... but perhaps doable one day unless Vim is too slow to process all that. No other highlighting script is as huge is this one would be. The first and most primitive step towards this is (as Nikolai wrote) simply listing: syn match contextKeyword ... ^-- regex for every ConTeXt command. mf.vim and mp.vim are both defined that way. They only highlight the keywords, they don't care about the syntax. Mojca