Skip to content

Highlight Svelte, HTML, CSS and SCSS, with embedded code injected - #3

Open
KieranP wants to merge 1 commit into
mainfrom
more-highlighting
Open

KieranP wants to merge 1 commit into
mainfrom
more-highlighting

Conversation

@KieranP

@KieranP KieranP commented Oct 19, 2026

Copy link
Copy Markdown
Owner

Svelte's grammar leaves script and style bodies and every {...} expression as opaque text, so one whole-file parse and query coloured only the markup. The highlighter now finds injections with a query of its own, since Svelte's injection file is Neovim's and inherits one no package ships, and parses each in its own language over a plain span. Block heads the grammar leaves whole, such as an each key or an await's then, are cut apart, and inline style and event handler attributes are read as CSS and JavaScript.

  • Copy CSS's scanner under ThirdParty, as its package builds without it
  • Colour SQL's type.qualifier keywords and HTML's doctype as keywords
  • Move integerRange and shifted(by:) into MultishellAppCore, replacing the copies in the diff view, find results and changed-parts marker

What this does

What I ran

  • make format
  • make lint
  • make test
  • make build

What I could not verify:

Docs

  • A design note under Docs/design/ if this changes a decision, or the
    reason it does not need one.
  • An entry in BUGS.md if this leaves a gap rather than closing it, tagged
    [Unconfirmed] if nobody has watched it go either way.

@KieranP KieranP self-assigned this Oct 19, 2026
@KieranP
KieranP force-pushed the more-highlighting branch 6 times, most recently from 45fe7af to fd843e4 Compare October 21, 2026 10:31
@KieranP
KieranP force-pushed the more-highlighting branch 3 times, most recently from 44c0533 to d42a145 Compare October 21, 2026 11:15
Svelte's grammar leaves script and style bodies, every {...} expression
and its block heads as opaque text, so one whole-file parse and query
coloured only the markup. The highlighter now finds that code with a
query of its own, since Svelte's injection file is Neovim's and inherits
one no package ships, and parses each piece in its own language, over a
plain span where the host would colour it. A script or style's language
follows its type, lang or language as HTML or Svelte would read them,
and each/await/snippet heads are cut apart by a small scanner, as no
TypeScript parse of them marks where the parts end.

- Read inline style and event handler attributes as CSS and JavaScript,
  SVG animation's and WebKit's events included and a repeated one read
  as its first, decoding character references and mapping spans back
- Find those attributes by a text scan and a tree lookup, as a query
  over every attribute cost a large file 157 ms of its highlighting
- Copy CSS's scanner under ThirdParty, as its package builds without it
- Colour SQL's type.qualifier keywords and HTML's doctype as keywords,
  and CSS's property and selector names as attributes, in a table of
  per-language capture exceptions
- Restate a few CSS and SCSS patterns in a query read after theirs, as
  they were written for the earlier to win: a custom property is a
  variable where defined and used, an SCSS mixin's name a function
- Resolve each grammar and parser once per highlight, both diff sides
  sharing them, keeping only compiled grammars across highlights
- Let a plain span clear colour without leaving a run, so a removed
  diff row keeps its dimmed text inside injected code
- Log under the app's fixed bundle identifier, now in MultishellAppCore
  so the highlighter shares it with the platform and Ghostty loggers
- Move integerRange and shifted(by:) into MultishellAppCore, replacing
  the copies in the diff view, find results and changed-parts marker

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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