From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/106178 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: "Philipp A." Newsgroups: gmane.comp.tex.context Subject: Re: How to approach a ConTeXt language server? Date: Wed, 5 Feb 2020 10:42:59 +0100 Message-ID: References: Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1514937651934112015==" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="120634"; mail-complaints-to="usenet@ciao.gmane.io" To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Wed Feb 05 10:43:32 2020 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1izHDY-000VGS-Ju for gctc-ntg-context-518@m.gmane-mx.org; Wed, 05 Feb 2020 10:43:32 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id BEC02165464; Wed, 5 Feb 2020 10:43:15 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4IxO1srszbiq; Wed, 5 Feb 2020 10:43:14 +0100 (CET) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id A149B1654CA; Wed, 5 Feb 2020 10:43:14 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 296B11654CA for ; Wed, 5 Feb 2020 10:43:13 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3DzZkQ5WVTOU for ; Wed, 5 Feb 2020 10:43:12 +0100 (CET) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.167.182; helo=mail-oi1-f182.google.com; envelope-from=trueflyingsheep@gmail.com; receiver= Original-Received: from mail-oi1-f182.google.com (mail-oi1-f182.google.com [209.85.167.182]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 1128A1650D3 for ; Wed, 5 Feb 2020 10:43:12 +0100 (CET) Original-Received: by mail-oi1-f182.google.com with SMTP id c16so124081oic.3 for ; Wed, 05 Feb 2020 01:43:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=iaRqHh2HC3iDyN8L3pU10DrHsiUXIWhYDph21hKTFwI=; b=sx8JpXzactJeWyUQ8DTOehOMrOAhe09WGEQxFkNTaXT6gUNG632GnUIryzOzU1huqr 8rhEMj53A+HACHp9uvWgwyc6tXEMBDEK5sj8a3jAdUhV3/5KDXZID7Xjd4WUEFFPm1FM ghU6t40SpiRqIWBv/UwEc0IjmBJglXd7M5liq+g4xltvXIbxOWuSv5CheY3NvMiOqiyn 1BtdUb/ZIavoKfRnlWJmgM5VLWAUuftcuCubgNe3zMiqEtoEvZnaJPgYzxsyhiYnyNte A4awfScTEcIrAkKmgpdwxNZsMcxQ7cnVaUcgfviK0SYN5eWAflvR/CQ4Y150pApJ3ZEO vZnQ== X-Gm-Message-State: APjAAAWuSDe1Ey/8J3pHAot/doLA9NVxqX/hgoJy8jnubBGFN+DPc7iW VI12JHfvxQHZzRdOEktra8FQF4yCwXlR6Ar7vQitsFPKXfI= X-Google-Smtp-Source: APXvYqxaRxOvDAFesD9DGpb7pzjiBCh/YaPDKfA3HIWmzu0rketeBGWnXoe9Pb9ELqEwNYDWCluMUeyVSvzpiks+KXE= X-Received: by 2002:a54:4816:: with SMTP id j22mr2232716oij.179.1580895790481; Wed, 05 Feb 2020 01:43:10 -0800 (PST) In-Reply-To: X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.io gmane.comp.tex.context:106178 Archived-At: --===============1514937651934112015== Content-Type: multipart/alternative; boundary="00000000000004c5c2059dd0fcd0" --00000000000004c5c2059dd0fcd0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thank you, that=E2=80=99s great information! What=E2=80=99s the =E2=80=9Cexport XML=E2=80=9D? Am Di., 4. Feb. 2020 um 19:09 Uhr schrieb Henning Hraban Ramm < texml@fiee.net>: > > > Am 2020-02-04 um 16:45 schrieb Philipp A. : > > > > Language servers are the new big deal in editor and IDE development: > https://langserver.org/ > > > > It would be cool to have a ConTeXt one for autocompletion (for ConTeXt: > command names, \cite IDs, labels, named parameters, =E2=80=A6), go-to-def= inition, > hover information (docs about a command) and so on. > > The way it works is that you have a server process that is the source o= f > truth for all this information, and the editor passes requests to it. > > The editor tells the server when it opens/closes files and when the use= r > requests something of the above. > > > > The way I=E2=80=99d implement it in ConTeXt is to keep a list of open C= onTeXt > projects in the server (obtained by following \include, \component, > \product, \environment, \project). > > Now my questions begin: > > =E2=80=A2 Then I=E2=80=99d make context load the project without = compiling it to a > PDF but make it execute some Lua (how do I do this?) > > =E2=80=A2 I=E2=80=99d need a way to get all available commands wi= th their > signatures into Lua. I assume this is done here, but how? > http://www.pragma-ade.nl/general/qrcs/setup-en.pdf > > Look for the interface files i-*.xml > > > =E2=80=A2 Optimally, for hover information and completion, I=E2= =80=99d want some > help/doc text for each command that has some. Is there a way to get it? > > No, there isn=E2=80=99t. It could be in the interface files if someone wo= uld put > in the work. > > > =E2=80=A2 Optimally, for label autocompletion, I=E2=80=99d also l= ike a list of > defined labels. Since I played around with bibliographies I already know > how to query the bibliography DB from Lua. > > =E2=80=A2 Optimally I=E2=80=99d also want some parse tree of each= document, but I > assume the way macros work, this doesn=E2=80=99t exist? This would make t= hings > easier that I=E2=80=99d otherwise have to (imperfectly) parse out of the = document > (due to things like catcode changes, but I guess I can pretend they don= =E2=80=99t > exist and \unprotect is always on) > > You could run ConTeXt and use the export XML. > > > =E2=80=A2 Optimally, for go-to-definition, I=E2=80=99d also want = a list of files > ConTeXt loaded so I can find definitions in it. > > Can anyone help me, especially with 1-2? To get me started, it would be > great to have an example script and a command line to invoke it, which > makes ConTeXt load a main tex file, execute some Lua, and exit without > creating a document or writing anything else to the channel Lua writes to > (stdout?). > > Look at the .tuc file that=E2=80=99s created in a ConTeXt run, it=E2=80= =99s a Lua table > and contains =E2=80=9Call=E2=80=9C the information about the project. > > > Greetlings, Hraban > --- > https://www.fiee.net > http://wiki.contextgarden.net > https://www.dreiviertelhaus.de > GPG Key ID 1C9B22FD > > > _________________________________________________________________________= __________ > If your question is of interest to others as well, please add an entry to > the Wiki! > > maillist : ntg-context@ntg.nl / > http://www.ntg.nl/mailman/listinfo/ntg-context > webpage : http://www.pragma-ade.nl / http://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : http://contextgarden.net > > _________________________________________________________________________= __________ > --00000000000004c5c2059dd0fcd0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thank you, that=E2=80=99s great information!

What=E2=80=99s the =E2=80=9Cexport XML=E2=80=9D?

Am Di., 4. Feb.= 2020 um 19:09=C2=A0Uhr schrieb Henning Hraban Ramm <texml@fiee.net>:

> Am 2020-02-04 um 16:45 schrieb Philipp A. <flying-sheep@web.de>:
>
> Language servers are the new big deal in editor and IDE development: <= a href=3D"https://langserver.org/" rel=3D"noreferrer" target=3D"_blank">htt= ps://langserver.org/
>
> It would be cool to have a ConTeXt one for autocompletion (for ConTeXt= : command names, \cite IDs, labels, named parameters, =E2=80=A6), go-to-def= inition, hover information (docs about a command) and so on.
> The way it works is that you have a server process that is the source = of truth for all this information, and the editor passes requests to it. > The editor tells the server when it opens/closes files and when the us= er requests something of the above.
>
> The way I=E2=80=99d implement it in ConTeXt is to keep a list of open = ConTeXt projects in the server (obtained by following \include, \component,= \product, \environment, \project).
> Now my questions begin:
>=C2=A0 =C2=A0 =C2=A0 =C2=A0=E2=80=A2 Then I=E2=80=99d make context load= the project without compiling it to a PDF but make it execute some Lua (ho= w do I do this?)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0=E2=80=A2 I=E2=80=99d need a way to get all = available commands with their signatures into Lua. I assume this is done he= re, but how? http://www.pragma-ade.nl/general/qrcs= /setup-en.pdf

Look for the interface files i-*.xml

>=C2=A0 =C2=A0 =C2=A0 =C2=A0=E2=80=A2 Optimally, for hover information a= nd completion, I=E2=80=99d want some help/doc text for each command that ha= s some. Is there a way to get it?

No, there isn=E2=80=99t. It could be in the interface files if someone woul= d put in the work.

>=C2=A0 =C2=A0 =C2=A0 =C2=A0=E2=80=A2 Optimally, for label autocompletio= n, I=E2=80=99d also like a list of defined labels. Since I played around wi= th bibliographies I already know how to query the bibliography DB from Lua.=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0=E2=80=A2 Optimally I=E2=80=99d also want so= me parse tree of each document, but I assume the way macros work, this does= n=E2=80=99t exist? This would make things easier that I=E2=80=99d otherwise= have to (imperfectly) parse out of the document (due to things like catcod= e changes, but I guess I can pretend they don=E2=80=99t exist and \unprotec= t is always on)

You could run ConTeXt and use the export XML.

>=C2=A0 =C2=A0 =C2=A0 =C2=A0=E2=80=A2 Optimally, for go-to-definition, I= =E2=80=99d also want a list of files ConTeXt loaded so I can find definitio= ns in it.
> Can anyone help me, especially with 1-2? To get me started, it would b= e great to have an example script and a command line to invoke it, which ma= kes ConTeXt load a main tex file, execute some Lua, and exit without creati= ng a document or writing anything else to the channel Lua writes to (stdout= ?).

Look at the .tuc file that=E2=80=99s created in a ConTeXt run, it=E2=80=99s= a Lua table and contains =E2=80=9Call=E2=80=9C the information about the p= roject.


Greetlings, Hraban
---
https= ://www.fiee.net
http://wiki.contextgarden.net
https://www.dreiviertelhaus.de
GPG Key ID 1C9B22FD

___________________________________________________________________________= ________
If your question is of interest to others as well, please add an entry to t= he Wiki!

maillist : ntg-cont= ext@ntg.nl / http://www.ntg.nl/mailman/listinfo/nt= g-context
webpage=C2=A0 : http://www.pragma-ade.nl / http://context.aanhet.net=
archive=C2=A0 : https://bitbucket.org/phg/context-m= irror/commits/
wiki=C2=A0 =C2=A0 =C2=A0: http://contextgarden.net
___________________________________________________________________________= ________
--00000000000004c5c2059dd0fcd0-- --===============1514937651934112015== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --===============1514937651934112015==--