Skip to content

Add optional language-server support for ConTeXt - #1134

Open
slem567 wants to merge 5 commits into
TeXworks:mainfrom
slem567:submission/context-lmtx
Open

slem567 wants to merge 5 commits into
TeXworks:mainfrom
slem567:submission/context-lmtx

Conversation

@slem567

@slem567 slem567 commented Sep 3, 2026

Copy link
Copy Markdown

Summary

Add optional language-server assistance for ConTeXt/LMTX documents, including
completion and Go to Definition, together with modern ConTeXt/LuaMetaTeX
defaults and documentation. No external provider dependency is introduced.

Motivation

ConTeXt/LMTX users can benefit from language-service assistance without making
an external provider a TeXworks dependency or changing the normal editor and
typesetting workflow.

What this changes

  • Adds .mkiv/.mkxl recognition and modern ConTeXt (LuaMetaTeX) defaults while
    retaining the distinct LuaTeX engine.
  • Adds optional asynchronous provider completion that augments native/static
    completion.
  • Adds capability-gated Go to Definition, with safe local same-file and
    cross-file navigation for one usable local-file result.
  • Adds disabled-by-default Preferences configuration for an external provider.
    Each argument is one literal line and is passed separately, with no shell
    parsing.

Architecture

The public generic LanguageService API, manager, document binding, and types
are provider-neutral. The manager owns active/pending service replacement and
document-binding authority; bindings own synchronization, generations,
freshness, and request tokens; process and JSON-RPC remain in the external
adapter; and editor/window code consumes capability-gated results. The adapter
implements a limited LSP subset; this is not a claim of universal LSP support.

ConTeXt and Digestif

Language-server support is optional and disabled by default. TeXworks does not
bundle, install, or discover a provider. Digestif is a tested ConTeXt/LMTX
example only, not a dependency or a promise of support for every provider.

Optional real-provider validation was reproduced against Digestif validation
revision 38aa19c0f11da9d1f08c24ec19724f11060b897f
,
published in slem567/digestif on branch validation/texworks-context-lmtx.
That revision contains the ConTeXt/LSP fixes used for the test, including modern
project/component filename resolution. It is a validation input only; TeXworks
does not bundle or require Digestif and its language-service API remains
provider-neutral.

Compatibility

Normal TeXworks editing remains available without a provider or when one is
unavailable, including native/static completion. The project policy floor
remains Qt 5.2.3. The actual Trusty Qt 5.2.1 proof is compatibility evidence;
it does not change that policy.

Validation

These are local validation results:

  • Qt 6: full configured CTest 13/13 passed.
  • Ubuntu Trusty / Qt 5.2.1: full configured CTest 13/13 passed.
  • Public Digestif validation revision 38aa19c0: both TeXworks real-provider
    layers passed (3/3 each).
  • Manual smoke: startup, main.mkxl, PDF preview, local/cross-file F12,
    truthful availability status, and clean shutdown.

Commit structure

The five commits are ordered for review:

  1. 88a18ff — ConTeXt metadata/defaults
  2. 965ad58 — provider-neutral service foundation
  3. 82ec5f7 — document/editor completion and definition integration
  4. 599ace8 — optional Preferences/configuration
  5. f05cb9c — documentation

Each behavior layer includes its associated tests.

Translation handling

This series adds translatable source strings but intentionally omits translation
catalog churn. TeXworks uses Weblate, and generated .qm files are not part of
this submission. Please advise whether a Weblate refresh should follow.

Extract the default engine and file-filter definitions so they can be tested
without initializing TWApp. Add .mkiv/.mkxl filters and ConTeXt source metadata
while preserving existing engine behavior, including LuaTeX's --luatex option.
Introduce a provider-neutral LanguageService seam and manager, with the initial
LSP/JSON-RPC/QProcess adapter behind it. Add transport, session, and
deterministic fake-server coverage; this commit enables no provider or editor
workflow by default.
Bind eligible ConTeXt documents to the service and expose capability-gated
completion and definition actions. Provider completions augment static
candidates, and tokens/generations reject stale asynchronous results. Include
document and navigation regression coverage.
Add persisted, disabled-by-default Preferences configuration and apply it
through TWApp. Arguments remain literal QStringList entries passed separately
to QProcess; reconfiguration replaces services with bounded teardown and is
covered by activation/failure tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant