Skip to content

feat(lsp): read scoped slot props in the editor and citry check (#168) - #521

Merged
JuroOravec merged 1 commit into
mainfrom
feat/lsp-scoped-slots
Oct 28, 2026
Merged

JuroOravec merged 1 commit into
mainfrom
feat/lsp-scoped-slots

Conversation

@JuroOravec

@JuroOravec JuroOravec commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

This is PR C of #168: editor and citry check support for scoped slots. PR B (#445, #447) lets a component pass Vue data to a fill with <c-slot name="item" :row="row" />, and the caller reads it with <c-fill name="item" v-slot="{ row }">. The editor already suggested the two attributes. Until now it did not explain them, did not know what row is, and did not notice a name the slot never passes.

What changes

The editor and citry check now read the receiving component's <c-slot> tags. That gives them the Vue props each slot passes.

  • Unknown prop warning. A name in v-slot="{ ... }" that the slot does not pass is a new warning, citry.vue.unknown-slot-prop, placed on the key. Vue would give that name undefined without any error. Vue writes prop names in camelCase, so :row-data passes rowData.
  • Types. In the editor, a v-slot name gets the type of the value the slot passes: a js_data() value, a v-for item over one, a field of either, or a literal. That type appears in hover and in the TypeScript check of the fill, so row.titel is an error. v-slot="props" gets an object type. A prop that only some of the slot's <c-slot> tags pass is optional.
  • Hover. :row on <c-slot> and v-slot on <c-fill> now get syntax hover. A fill's slot name lists the Vue props next to the Python slot data. This also works for a slot that no Slots class declares.
  • Completion. Inside v-slot="{ }", the editor offers the slot's props that the pattern does not name yet, and nothing at a rename or a default value. It also stops offering the caller's own js_data names there.
  • Messages. On <c-slot>, the python-variable and unknown-variable messages stop offering c-row="row" as a swap for :row="row". On <c-slot>, a c- attribute is Python slot data, which the fill reads with data=. The messages now say that.

Nothing is checked when the props cannot be known. That covers:

  • a fill whose slot name comes from c-name or c-bind;
  • a receiver with any <c-slot> named that way, which turns the check off for every slot of that component;
  • a receiver whose template cannot be read, or that has no <c-slot> for the slot;
  • an unregistered tag.

A single-name pattern such as v-slot="props" gets types but never this warning. In the editor, the warning also needs the open template to belong to a component the registry can prove, as the other Vue lints do. citry check reads only registered components' templates, so this always holds there.

Design

The design note covers prior art, alternatives and error modes. The main choices:

  • New module, no Rust. A new citry module, citry/_slot_props.py, reads each component's <c-slot> tags, the scoped fills, and the keys of each v-slot pattern with the names they bind. It also holds the lint. It is pure Python and needs no Rust or AST change. TagRules is a citry-core PyO3 class, so it cannot carry the outlets' props without Rust.

  • Each tool reads the receiver its own way. citry check uses engine.get(tag) and component_templates, with a parse cache keyed by template text. The editor uses its component catalog and _component_template_ast.

  • Type each name directly. Plan decision 11 described a CitrySlotProps_<n> typedef. Instead, each v-slot name gets its type through the binding-type path the editor already uses for v-for names, which gives the same results for top-level names, with less new code. The key check the typedef would have given TypeScript is covered by the Citry lint, which citry check also runs. A name inside a nested pattern, or a ...rest name, stays untyped, and a name from an optional prop gets the prop's type without undefined, because the JSON wire types have no undefined.

  • Read receivers only when needed. The editor reads a receiving component only when an expression uses one of that fill's names, and once per component and slot. An earlier version read every receiver on every request. With ten scoped fills on one page, the reviewer measured about 395 ms per completion or hover and 188 ms for diagnostics before the change. After it, the reviewer measured (receiver of about 150 elements, medians of 7 runs):

    Request After
    Completion or hover outside any fill about 5 ms (2 to 3 ms with no fills)
    Completion or hover inside a fill about 40 to 48 ms
    Diagnostics about 35 to 47 ms (13 to 23 ms with no fills)

    Inside a fill, the cost depends on the receiving component's size and is paid on each request, because nothing caches the receiver between requests.

Cross-binding audit: no grammar, AST, compiler-output, LangImpl, PyO3 or _rust.pyi change.

Catalog and docs

  • Catalog: a new code, citry.vue.unknown-slot-prop, a warning on check and lsp. The new message variants are slot-prop and browser-slot-prop on citry.vue.python-variable, and python-slot-prop on citry.vue.unknown-variable. The generated Python module and the protocol changelog are updated.
  • Docs: a new section "Vue slot props in fills" in ide/vscode.md.
  • Syntax fixture: a shared case, "scoped slot props", runs in both the VS Code grammar tests and the Pygments conformance test. Neither tokenizer needed a change.
  • Changelogs:
    • citry: the citry check warning, added to the scoped-slot entry.
    • citry-lsp: the editor features, and scoped slots added to the Citry 0.7.0 requirement line. engine.py imports the new citry module, so this citry-lsp needs Citry 0.7.0. MINIMUM_CITRY_VERSION, the citry>= pin and the expected version in scripts/verify_citry_lsp_distribution.py move in the release PR, per AGENTS.md.
    • The diagnostics protocol: the new code and message variants.

Tests

  • citry:
    • test_slot_props.py (new) covers outlets, fills, pattern keys and locals, both warning messages, and camelize matching the render path.
    • python-variable and unknown-variable cases on <c-slot>.
    • citry check end to end. That covers the warning and its position, the none message, a dynamic outlet, an unregistered tag, a forwarded-fill outlet, an inherited template, and every key passed.
  • citry-lsp:
    • hover on the attributes, including :name/:key getting none;
    • the slot hover, with and without a Slots class, including optional props;
    • typing in the projection and hover, with a TypeScript check when tsc is available;
    • the warning's range, including in an inline Python template;
    • the parser's errors for rejected forms reaching the editor with the attribute's range;
    • completion at each pattern position;
    • two tests that receiving components are read once per tag in diagnostics, and not at all for an expression outside every fill.

Evidence

  • Tests: 1,210 passed across the touched citry and citry-lsp test files after rebasing on main. The only failures are 9 ty-backed citry-lsp tests: my local environment has ty 0.0.90 and the repository pins 0.0.91. They fail the same way without this change. The full citry-lsp suite could not finish locally for the same reason; PR CI runs it with the pinned ty. The TypeScript-backed scoped-slot tests skip locally, because this checkout has no repo-local tsc; an earlier run with tsc passed them, and PR CI runs them.
  • Other checks: the VS Code grammar test (37) and the Pygments conformance test (15) pass, as do scripts/validate.py, generate_diagnostic_catalog.py --check, ruff, ruff format, mypy (also with --platform linux), and the docs build with its guards.
  • Reviews: three independent rounds found the speed problem and several wording, catalog and description issues, all folded in. A docs cold read of the new section and the catalog text ran too.

🤖 Generated with Claude Code

A component passes Vue data to a fill with <c-slot :row="row">, and the
caller reads it with <c-fill v-slot="{ row }">. The editor and citry check
now read the receiving component's <c-slot> tags to know those props.

- citry check and the editor warn when v-slot="{ ... }" reads a name the
  slot does not pass. The new warning, citry.vue.unknown-slot-prop, marks
  the key.
- In the editor, v-slot names get the type of the value the slot passes
  (a js_data value, a v-for item over one, a field of either, or a
  literal), in hover and in the TypeScript check of the fill. A prop only
  some <c-slot> tags pass is optional.
- Hover explains :row on <c-slot> and v-slot on <c-fill>, and a fill's
  slot name lists the Vue props next to the Python slot data.
- Inside v-slot="{ }", completion offers the slot's props and no longer
  the caller's own js_data names.
- On <c-slot>, the python-variable and unknown-variable messages explain
  that a c- attribute passes Python slot data, read with data=, instead
  of offering it as a swap for :row.

The receiving template is read only when an expression uses a fill's
names, once per component and slot, so a request outside every fill
reads no receiving template.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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