From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/106166 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: "Philipp A." Newsgroups: gmane.comp.tex.context Subject: How to approach a ConTeXt language server? Date: Tue, 4 Feb 2020 16:45:48 +0100 Message-ID: Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8975125775039231891==" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="109706"; mail-complaints-to="usenet@ciao.gmane.io" To: ConTeXt Mailing List Original-X-From: ntg-context-bounces@ntg.nl Tue Feb 04 16:46:24 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 1iz0P9-000SQN-Q7 for gctc-ntg-context-518@m.gmane-mx.org; Tue, 04 Feb 2020 16:46:23 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 59E1816548D; Tue, 4 Feb 2020 16:46:05 +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 RR-_gXpnK-Ht; Tue, 4 Feb 2020 16:46:03 +0100 (CET) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id CC847165487; Tue, 4 Feb 2020 16:46:03 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 0D9C1165483 for ; Tue, 4 Feb 2020 16:46:03 +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 T0fgVM9Xh3IZ for ; Tue, 4 Feb 2020 16:46:02 +0100 (CET) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.210.44; helo=mail-ot1-f44.google.com; envelope-from=trueflyingsheep@gmail.com; receiver= Original-Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (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 E8884165482 for ; Tue, 4 Feb 2020 16:46:01 +0100 (CET) Original-Received: by mail-ot1-f44.google.com with SMTP id g64so17456232otb.13 for ; Tue, 04 Feb 2020 07:46:01 -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:from:date:message-id:subject:to; bh=dKTAlLRZqNmlHis0WpPU7QVu6eRGzgGQo0B+Jr8q/jY=; b=ZM25wX9uA9Pn4KVunsQERoFQQF7reBbiQe9bx7zfh/c7TrYLkn/nJjYL9MIZbeZZWH Mw04pdf83Yqtnbjvrcn55sxA/ioik5uKRwmcmBZpsiPARvT7kaj8ReA7UQBzqL333ArF 9TvHdgwbTBY2rmao7v4cBrhsROQyfDfSO6FSC5VEnSCRxkATWP/n2RsoyTBXyHslGXkz cKYeuj8iz5WyEq59mrgCAhybAy7Vud/Rt8XSqYL6UYkqken7QqHP6f3I6U0A7JAGB/1v GW06+uAR/pB4DXrUHuCejNdNcrmlV3Pdg/UrKX1JGUm9KSqI1SJ1JN5wvxun+HmBnd0r tcog== X-Gm-Message-State: APjAAAUCZekIZP/0yl6WgKIa2FvjmjxGDIQSRfL6i1AaE5eA5EzY7el8 XDHJ0ic5tkJqvS8ekgPB2NoTOjfLCZ2wWHVhzJ+ZDpcFKNc= X-Google-Smtp-Source: APXvYqz0L7TQELNWHQX0h/u4W/3lU6x/27AqiR77qdyQaAsY4JA67+5uiiCykdHP+Yx6kKjR6DlRrgOelFphF2eZi1w= X-Received: by 2002:a9d:7a56:: with SMTP id z22mr12151636otm.201.1580831160258; Tue, 04 Feb 2020 07:46:00 -0800 (PST) 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:106166 Archived-At: --===============8975125775039231891== Content-Type: multipart/alternative; boundary="000000000000c1d541059dc1ef52" --000000000000c1d541059dc1ef52 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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-defin= ition, 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 user requests something of the above. The way I=E2=80=99d implement it in ConTeXt is to keep a list of open ConTe= Xt projects in the server (obtained by following \include, \component, \product, \environment, \project). Now my questions begin: 1. Then I=E2=80=99d make context load the project without compiling it t= o a PDF but make it execute some Lua (how do I do this?) 2. I=E2=80=99d need a way to get all available commands with their signa= tures into Lua. I assume this is done here, but how? http://www.pragma-ade.nl/general/qrcs/setup-en.pdf 3. Optimally, for hover information and completion, I=E2=80=99d want som= e help/doc text for each command that has some. Is there a way to get it? 4. Optimally, for label autocompletion, I=E2=80=99d also like a list of = defined labels. Since I played around with bibliographies I already know how to query the bibliography DB from Lua. 5. 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 = things 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) 6. Optimally, for go-to-definition, I=E2=80=99d also want a list of file= s 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?). Best, Philipp --000000000000c1d541059dc1ef52 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Language servers are the new big deal in editor and IDE de= velopment:=C2=A0https://langserver.org/=

It would be cool to have a ConTeXt one for autocomp= letion (for ConTeXt: command names, \cite IDs, labels, named parameters, = =E2=80=A6), go-to-definition, 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 reques= ts to it.
The editor tells the server when it opens/closes fi= les and when the user 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:
=
  1. Then I=E2=80=99d make context load the project without compili= ng it to a PDF but make it execute some Lua (how do I do this?)
  2. I= =E2=80=99d need a way to get all available commands with their signatures i= nto Lua. I assume this is done here, but how?=C2=A0http://www.pragma-ade.nl/general/qrc= s/setup-en.pdf
  3. Optimally, for hover information and completion,= I=E2=80=99d want some help/doc text for each command that has some. Is the= re a way to get it?
  4. Optimally, for label autocompletion, I=E2=80=99= d also like a list of defined labels. Since I played around with bibliograp= hies I already know how to query the bibliography DB from Lua.
  5. Opti= mally 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 things eas= ier that I=E2=80=99d otherwise have to (imperfectly) parse out of the docum= ent (due to things like catcode changes, but I guess I can pretend they don= =E2=80=99t exist and \unprotect is always on)
  6. Optimally, for go-to-= definition, I=E2=80=99d also want a list of files ConTeXt loaded so I can f= ind 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 com= mand line to invoke it, which makes ConTeXt load a main tex file, execute s= ome Lua, and exit without creating a document or writing anything else to t= he channel Lua writes to (stdout?).

Best, Ph= ilipp
--000000000000c1d541059dc1ef52-- --===============8975125775039231891== 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== --===============8975125775039231891==--