From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/21337 Path: news.gmane.org!not-for-mail From: Mojca Miklavec Newsgroups: gmane.comp.tex.context Subject: Re: TeX + Metapost syntax highlighting in Vim Date: Tue, 12 Jul 2005 15:38:39 +0200 Message-ID: <6faad9f00507120638824a479@mail.gmail.com> References: <42CEA592.8010603@gmail.com> <42CEBDB6.5030702@wxs.nl> <20050708213205.GB5397@puritan.pnetwork> Reply-To: Mojca Miklavec , mailing list for ConTeXt users NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1121175785 23188 80.91.229.2 (12 Jul 2005 13:43:05 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 12 Jul 2005 13:43:05 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Tue Jul 12 15:43:01 2005 Return-path: Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by ciao.gmane.org with esmtp (Exim 4.43) id 1DsL0o-0000wQ-5C for gctc-ntg-context-518@m.gmane.org; Tue, 12 Jul 2005 15:41:26 +0200 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id C31C5127CF; Tue, 12 Jul 2005 15:41:25 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 09051-04; Tue, 12 Jul 2005 15:41:25 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost.localdomain [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 672E0127B4; Tue, 12 Jul 2005 15:38:43 +0200 (CEST) Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 608FE127B4 for ; Tue, 12 Jul 2005 15:38:41 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 08980-03 for ; Tue, 12 Jul 2005 15:38:40 +0200 (CEST) Original-Received: from nproxy.gmail.com (nproxy.gmail.com [64.233.182.206]) by ronja.ntg.nl (Postfix) with ESMTP id 09261127A6 for ; Tue, 12 Jul 2005 15:38:39 +0200 (CEST) Original-Received: by nproxy.gmail.com with SMTP id x37so283291nfc for ; Tue, 12 Jul 2005 06:38:39 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=MeRSVKHo9cX2gtrOEUB3Zo+AjwGanbTKxiDyqmkreYfQB/l1dCJQc2EMu6AjdzEbIYAYQuR8n4yfO359+J+u+hqydxas0nYlKzYDYz9gV211i68yp82DVdJ0nBSaZI1LINPEHB2UQ6A+GVwtcp3qbK8TUNiq2S0Jwj/mNabCLxA= Original-Received: by 10.48.3.18 with SMTP id 18mr194096nfc; Tue, 12 Jul 2005 06:38:39 -0700 (PDT) Original-Received: by 10.48.247.2 with HTTP; Tue, 12 Jul 2005 06:38:39 -0700 (PDT) Original-To: mailing list for ConTeXt users In-Reply-To: <20050708213205.GB5397@puritan.pnetwork> Content-Disposition: inline X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.5 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on smtp.ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:21337 X-Report-Spam: http://spam.gmane.org/gmane.comp.tex.context:21337 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=3D@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.) >=20 > Hans Hagen wrote: >=20 > > Mojca Miklavec wrote: >=20 > > > If you have something like > > > \startMPpage > > > draw ... > > > \stopMPpage, > > > it will do the syntax highligting for metapost inside the \start-\sto= p > > > pair. >=20 > 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=3D@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 t= ry > > > to see what I can do, but please don't excpect any results too soon. >=20 > 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[ only the options height=3D and lines=3D 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 tabl= e; > > it already handles scite, jedit and bbedit so adding vim is not undoabl= e >=20 > Download vim and run :help syntax. But the short version is >=20 > syn keyword contextKeyword ... > ^-- group name ^-- keywords >=20 > But that won't work for stuff beginning with \\. Then you'll have to > use regexes and >=20 > syn match contextKeyword ... > ^-- regex >=20 > 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=3D30,somestupidparameter=3D1] would thus highlight the valid "lines=3D" different from "somestupidparamet= er=3D1" \setupblackrules[alternative=3Dc] 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=3D{\secondcommand[x]}, text=3D$]$ ] 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