Files
carbon-lang/utils/textmate/Samples/customs.svg
T
Chandler Carruth fccb349af4 Improve the TextMate grammar scopes and precision (again) (#7914)
This is a re-do of #7888

Outside a call, the grammar scoped a name as a type or a variable by its
capitalization. A theme could not distinguish a type from a value with
the same spelling, or a parameter, a member, or an implemented interface
from any other name. Pointer member access `->` was scoped as a result
arrow, which scoped `Lookup` in `regions->Lookup(x)` as a type.

`entity.name.type` now applies only in a type position (after `:`, `->`,
`as`, `adapt`, or `require`, or in an `impl`) and to the name a nominal
declaration declares. A qualifier, in a declared name like `fn N.Base(T:
type).F()` or in a type, is `entity.name.scope-resolution` nested in
`entity.name.type`. As in the parser, a name is a qualifier when its
parameter lists are followed by `.`. Parameters, `let` bindings, choice
alternatives, members, implemented interfaces, primitive types,
`import`, and the strings naming a builtin or a library have their own
scopes, and brackets use the C++ grammar's scopes. A `->` written
directly after its operand is member access; no result arrow in the
repository is written that way.

The sample palette renders each scope that depends on context
differently, and `tmlanguage.py` now supports nested captures.

In 17 of the 19 themes measured, the VS Code built-ins plus One Dark
Pro, Night Owl, Tokyo Night, and Nord, 13% to 27% of the characters in
hand-written Carbon change color or style. A theme loses a color where
`.` is now punctuation, where word operators like `as` are no longer
control-flow keywords, or where a name outside a type position is no
longer a type.

Assisted-by: Claude Code
2026-10-06 23:21:43 +00:00

16 lines
2.6 KiB
XML

<svg xmlns="http://www.w3.org/2000/svg" width="721" height="233" viewBox="0 0 721 233">
<rect width="100%" height="100%" fill="#1e1e2e"/>
<g xml:space="preserve" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="14">
<text style="white-space:pre" x="12" y="26"><tspan fill="#6c7086"> 1 </tspan><tspan fill="#7f849c">//</tspan><tspan fill="#7f849c" font-style="italic"> Part of the Carbon Language project, under the Apache License v2.0 with LLVM</tspan></text>
<text style="white-space:pre" x="12" y="45"><tspan fill="#6c7086"> 2 </tspan><tspan fill="#7f849c">//</tspan><tspan fill="#7f849c" font-style="italic"> Exceptions. See /LICENSE for license information.</tspan></text>
<text style="white-space:pre" x="12" y="64"><tspan fill="#6c7086"> 3 </tspan><tspan fill="#7f849c">//</tspan><tspan fill="#7f849c" font-style="italic"> SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception</tspan></text>
<text style="white-space:pre" x="12" y="83"><tspan fill="#6c7086"> 4 </tspan></text>
<text style="white-space:pre" x="12" y="102"><tspan fill="#6c7086"> 5 </tspan><tspan fill="#cba6f7">package</tspan><tspan fill="#a6adc8"> </tspan><tspan fill="#f5e0dc">SomePackage</tspan><tspan fill="#74c7ec" font-weight="bold">;</tspan></text>
<text style="white-space:pre" x="12" y="121"><tspan fill="#6c7086"> 6 </tspan><tspan fill="#f9e2af" font-weight="bold">Core</tspan><tspan fill="#a6adc8"> </tspan><tspan fill="#cdd6f4">SomeCore</tspan><tspan fill="#74c7ec" font-weight="bold">;</tspan></text>
<text style="white-space:pre" x="12" y="140"><tspan fill="#6c7086"> 7 </tspan></text>
<text style="white-space:pre" x="12" y="159"><tspan fill="#6c7086"> 8 </tspan><tspan fill="#f38ba8">import</tspan><tspan fill="#a6adc8"> </tspan><tspan fill="#f5e0dc">SomePackage</tspan><tspan fill="#74c7ec" font-weight="bold">;</tspan></text>
<text style="white-space:pre" x="12" y="178"><tspan fill="#6c7086"> 9 </tspan></text>
<text style="white-space:pre" x="12" y="197"><tspan fill="#6c7086">10 </tspan><tspan fill="#89b4fa">CallFunction</tspan><tspan fill="#74c7ec">(</tspan><tspan fill="#cdd6f4">a</tspan><tspan fill="#74c7ec">,</tspan><tspan fill="#a6adc8"> </tspan><tspan fill="#cdd6f4">b</tspan><tspan fill="#74c7ec">,</tspan><tspan fill="#a6adc8"> </tspan><tspan fill="#cdd6f4">c</tspan><tspan fill="#74c7ec">.</tspan><tspan fill="#eba0ac" font-style="italic">d</tspan><tspan fill="#74c7ec">)</tspan><tspan fill="#74c7ec" font-weight="bold">;</tspan></text>
<text style="white-space:pre" x="12" y="216"><tspan fill="#6c7086">11 </tspan><tspan fill="#cdd6f4">unidentified</tspan><tspan fill="#74c7ec" font-weight="bold">;</tspan></text>
</g></svg>