Repository navigation
Description
What problem does this solve?
Citry has a tested LSP4IJ setup for PyCharm: one citry-lsp process can attach to both inline Python component modules and standalone *.citry-html files while PyCharm's normal Python support remains active. Standard LSP diagnostics, completion, hover, Definition, References, Declaration, Type Definition, and standalone formatting work.
That configuration-only route still lacks the editor-side features that make the VS Code integration feel native:
- Citry-specific coloring inside Python
template,js, andcssstrings; - reliable standalone Citry coloring;
- first-party project interpreter and
appselection; - Citry registry/status and troubleshooting UI;
- delegation of nested templates and
<c-element>to the IDE's HTML intelligence; - typed JavaScript/Alpine and CSS projections backed by JetBrains language services;
- a supported bridge for Citry's private projection/status requests.
LSP4IJ's JSON definition can start and map the server, but it cannot register Python language injections, create and map JetBrains virtual files, or invoke the IDE's installed HTML/JavaScript/CSS services.
The completed attach spike and its exact capability matrix are recorded in docs/design/ide_research/pycharm_attach_spike.md.
Proposed solution
Treat this as staged JetBrains work rather than one all-or-nothing plugin.
1. Prove the smallest coloring path
- Add standard
textDocument/semanticTokenssupport tocitry-lsp. - Reuse Citry's parser, source maps, and shared syntax fixtures for token identity.
- Verify whether LSP4IJ and JetBrains' native LSP client can paint those tokens cleanly over Python string highlighting.
- Package/reuse Citry's existing TextMate grammar for standalone
*.citry-htmlcoloring.
If semantic tokens provide good inline coloring, keep that editor-neutral win even if the native plugin proceeds.
2. Ship a first-party native plugin
Create a Kotlin plugin using JetBrains' native LspIntegrationProvider / project-wide LSP client APIs. It should:
- start
citry-lspfrom the selected project interpreter; - configure the
module:attributeCitry app/library target; - attach alongside normal Python support;
- present Citry status, syntax-only degradation, restart, and troubleshooting UI;
- support both inline component modules and standalone templates;
- avoid exposing generated/virtual document locations to users.
The attach spike already proved that the native client reaches Running for both document shapes, so attachment itself is not an unknown.
3. Add native injections and projection bridges
Prefer JetBrains language injection where it preserves Citry semantics:
- Citry/HTML in
templatestrings and nested-template ranges; - JavaScript in
jsstrings and Alpine expressions; - CSS in
cssstrings; - generated prefixes/suffixes for
$component, Citry magics,JsData, props, events, Alpine scope, andCssData.
Use Citry's existing private HTML/browser projections where ordinary injection is insufficient, including:
<c-element is="...">native-element behavior;- recursively nested templates;
- statically selected child
$c-propscontracts; - component-aware event and Alpine scope data;
- exact source mapping for completion edits, hover, and navigation.
The bridge may use JetBrains LightVirtualFile documents and the installed HTML/JavaScript/CSS language services, but must degrade cleanly when an optional host language service is unavailable.
Acceptance criteria
- Inline
.pyand standalone*.citry-htmlhave deliberate Citry coloring without replacing Python support. - Existing standard LSP diagnostics, completion, hover, navigation, references, type definitions, and formatting remain correct.
- Nested-template and
<c-element>positions receive mapped HTML intelligence. - Component JavaScript/Alpine and CSS receive the same proven data contracts as the VS Code integration where the corresponding JetBrains language service is available.
- Completion edits and navigation map to authored files; generated virtual files never open as user-facing destinations.
- Stale document/project generations, cancellation, multiple workspaces, indexing mode, and server restart fail conservatively.
- The plugin has focused IDE fixtures for inline and standalone components, UTF-16/CRLF coordinates, nested templates, optional host-language support, and lifecycle cleanup.
- Local PyCharm is covered first; JetBrains Remote Development placement and interpreter discovery get an explicit follow-up acceptance matrix before being claimed.
Alternatives considered
- Keep only LSP4IJ: remains the supported interim route and already delivers substantial semantics, but cannot provide injections or private provider bridges by configuration alone.
- Semantic tokens only: potentially solves coloring and should be tested first, but does not provide setup/status UI or HTML/JavaScript/CSS delegation.
- Reimplement HTML/JavaScript/CSS analysis in Citry: rejected in favor of reusing JetBrains' installed language services and Citry's existing portable projections.
- Depend on LSP4IJ from the official plugin: possible, but the successful native attach spike means a first-party plugin can avoid coupling its core lifecycle to another plugin. Re-evaluate only if LSP4IJ exposes substantially safer projection APIs.
If this integration matters to your workflow, add a 👍 reaction and comment with the JetBrains IDE, local/remote setup, and Citry features you need most. That evidence will help prioritize the coloring-only and full-plugin rungs.
Activity