Skip to content

Build a first-party JetBrains plugin for PyCharm and IntelliJ #78

Open

Description

@JuroOravec

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, and css strings;
  • reliable standalone Citry coloring;
  • first-party project interpreter and app selection;
  • 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/semanticTokens support to citry-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-html coloring.

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-lsp from the selected project interpreter;
  • configure the module:attribute Citry 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 template strings and nested-template ranges;
  • JavaScript in js strings and Alpine expressions;
  • CSS in css strings;
  • generated prefixes/suffixes for $component, Citry magics, JsData, props, events, Alpine scope, and CssData.

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-props contracts;
  • 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 .py and standalone *.citry-html have 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

  1. added
    enhancement
    on Aug 11, 2026
  2. added
    next-sprint
    on Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementnext-sprint

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions