Repository navigation
feat(lsp): read scoped slot props in the editor and citry check (#168) - #521
Merged
Merged
Conversation
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]>
JuroOravec
force-pushed
the
feat/lsp-scoped-slots
branch
from
October 28, 2026 20:05
0a78ed5 to
a5f529c
Compare
This was referenced Oct 28, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is PR C of #168: editor and
citry checksupport 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 whatrowis, and did not notice a name the slot never passes.What changes
The editor and
citry checknow read the receiving component's<c-slot>tags. That gives them the Vue props each slot passes.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 nameundefinedwithout any error. Vue writes prop names in camelCase, so:row-datapassesrowData.v-slotname gets the type of the value the slot passes: ajs_data()value, av-foritem over one, a field of either, or a literal. That type appears in hover and in the TypeScript check of the fill, sorow.titelis an error.v-slot="props"gets an object type. A prop that only some of the slot's<c-slot>tags pass is optional.:rowon<c-slot>andv-sloton<c-fill>now get syntax hover. A fill's slotnamelists the Vue props next to the Python slot data. This also works for a slot that noSlotsclass declares.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 ownjs_datanames there.<c-slot>, thepython-variableandunknown-variablemessages stop offeringc-row="row"as a swap for:row="row". On<c-slot>, ac-attribute is Python slot data, which the fill reads withdata=. The messages now say that.Nothing is checked when the props cannot be known. That covers:
c-nameorc-bind;<c-slot>named that way, which turns the check off for every slot of that component;<c-slot>for the slot;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 checkreads 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 eachv-slotpattern with the names they bind. It also holds the lint. It is pure Python and needs no Rust or AST change.TagRulesis a citry-core PyO3 class, so it cannot carry the outlets' props without Rust.Each tool reads the receiver its own way.
citry checkusesengine.get(tag)andcomponent_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, eachv-slotname gets its type through the binding-type path the editor already uses forv-fornames, 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, whichcitry checkalso runs. A name inside a nested pattern, or a...restname, stays untyped, and a name from an optional prop gets the prop's type withoutundefined, because the JSON wire types have noundefined.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):
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.pyichange.Catalog and docs
citry.vue.unknown-slot-prop, a warning oncheckandlsp. The new message variants areslot-propandbrowser-slot-proponcitry.vue.python-variable, andpython-slot-proponcitry.vue.unknown-variable. The generated Python module and the protocol changelog are updated.ide/vscode.md.citry checkwarning, added to the scoped-slot entry.engine.pyimports the new citry module, so this citry-lsp needs Citry 0.7.0.MINIMUM_CITRY_VERSION, thecitry>=pin and the expected version inscripts/verify_citry_lsp_distribution.pymove in the release PR, perAGENTS.md.Tests
test_slot_props.py(new) covers outlets, fills, pattern keys and locals, both warning messages, andcamelizematching the render path.python-variableandunknown-variablecases on<c-slot>.citry checkend to end. That covers the warning and its position, thenonemessage, a dynamic outlet, an unregistered tag, a forwarded-fill outlet, an inherited template, and every key passed.:name/:keygetting none;Slotsclass, including optional props;tscis available;Evidence
tsc; an earlier run withtscpassed them, and PR CI runs them.scripts/validate.py,generate_diagnostic_catalog.py --check, ruff, ruff format, mypy (also with--platform linux), and the docs build with its guards.🤖 Generated with Claude Code