A VS Code extension that provides rich editing support for the
compelem component framework,
especially for the HTML-style markup written inside the `h`...` tag
templates of a component's render() function.
Features
1. Syntax Highlighting
- The HTML text inside
`h`...`functions is highlighted. - The CSS text inside
`css`...`template functions is highlighted. - All compelem directive functions (
show / ifTrue / ifElse / forEach / when / slot / html / classes / styles / model / bind ...) have individually configurable colors. - When the cursor is on a tag, the matching opening/closing tag name is highlighted.
- Paired tags can be folded.
2. Formatting
- Right-click formatting of the HTML markup template inside
`h`...`functions is supported. - Long tags are broken into one attribute per line; short elements
(e.g.
<span>Hello</span>) stay on a single line. The result is idempotent. - When you want to keep the built-in TypeScript formatter as the default
document formatter, you can use the
Compelem: Formath...templates` command. - The number of indentation spaces can be set via
compelem.format.indentSize(the default0means following the editor'stabSize).
3. IntelliSense & Completion
- Typing
<l-(or a PascalCase prefix) inside`h`...`functions lists the components registered in the workspace. - Typing
.on a component tag lists the component's props — including the properties inherited viaextends(e.g.color/size/disabledfrom a base class) — and shows their type, default value, and@attrsdocumentation. - Typing an opening tag like
<div>automatically inserts</div>and moves the cursor inside the element. - Typing
<xx propname=on a component tag automatically inserts"${this.value}". - Typing
show / bind / classes / styles / model / htmlon any tag suggests a tag-directive snippet such as${show(this.visible)}; inside${ ... }, text directives (forEach / when / ifTrue / ifElse / slot) are suggested instead.
4. Snippets
render→ generates arender()that returns an`h`...`function template containing a root<div>.@watch→ generates an empty@watch(...)method.@computed→ generates an empty@computedgetter.
5. Diagnostics
- The
refattribute must be an interpolation of acreateRefmember, e.g.ref="${this.xxRef}". - The
.xxdirective attribute is only allowed onl-xxor PascalCase components (e.g.<l-input .value="${this.xx}">). - The
.nativeevent modifier is only allowed onl-xxcomponents;<div @click.native="...">is flagged as an error.
6. Navigation
- Hold Ctrl and click a component tag (
l-xx/ PascalCase) to jump to its@tagclass definition. - Hold Ctrl and click a
this.xxxreference to jump to that member's declaration. - Hold Ctrl and click a CSS class to find its
.classselector in the style files. - For cross-file lookups, it falls back to VS Code's workspace symbol search.