Skip to content

Commit 2111bd4

Browse files
Jordan Millerclaude
andcommitted
Highlight .sx on GitHub as Rust, not TypeScript
The previous mapping picked TypeScript because SxfeScript is JavaScript plus erasable type annotations. That covered the JavaScript half but left the half the language is actually named for unhighlighted: `mut`, `&mut`, and `unsafe` all rendered as plain identifiers, which is the opposite of the emphasis the source intends. Both grammars were rendered on github.com from pushed branches and compared token by token, using perturbed file contents so the blob highlight cache did not serve one branch's colors for the other. Rust highlights, TypeScript does not: - `mut` in `let mut` keyword - `mut` in `bump(&mut counter)` keyword - `unsafe extern` keyword - `Repo`, `Counter`, `Request` type color TypeScript highlights, Rust does not: - `interface`, `function`, `void` keyword - template-literal text string color Shared by both: `const`, `let`, `if`, `return`, `async`, `await`, `new`, string literals, numbers, comments, and function-call names. Across the 19 `.sx` files in the repository `mut` appears 15 times against 7 `function`, 5 `interface`, and 2 `void`, so the Rust mapping colors more of what matters and the tokens it drops stay legible as plain identifiers. `safe` is a keyword under neither grammar. Rendering on github.com is the only thing this changes. The repository language statistics will now count `.sx` as Rust instead of TypeScript. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 895d60b commit 2111bd4

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

.gitattributes

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
# GitHub Linguist does not know `.sx`, so it renders SxfeScript as plain text.
2-
# TypeScript is the closest grammar it ships: same expression and statement
3-
# syntax, same `:` type annotations. `let mut`, `&mut`, and `unsafe` are the
4-
# only tokens it misses. The real grammar lives in
5-
# tooling/vscode/syntaxes/sxfe.tmLanguage.json.
6-
*.sx linguist-language=TypeScript
1+
# GitHub Linguist has no entry for `.sx`, so SxfeScript renders as plain text
2+
# and is left out of the language statistics. Rust is the closest grammar
3+
# Linguist ships. It is the only one that treats the ownership keywords the way
4+
# SxfeScript means them: `mut` in `let mut`, `mut` in `&mut`, and `unsafe
5+
# extern` all highlight as keywords, and type names get the type color.
6+
#
7+
# The cost is that `interface`, `function`, and `void` lose their keyword
8+
# color, and template-literal text is not colored as a string. Everything else
9+
# -- `const`, `let`, `if`, `return`, `async`, `await`, strings, numbers, and
10+
# comments -- is shared between the two languages and highlights either way.
11+
# `safe` is not a Rust keyword and stays plain under both.
12+
#
13+
# The real grammar lives in tooling/vscode/syntaxes/sxfe.tmLanguage.json.
14+
*.sx linguist-language=Rust

0 commit comments

Comments
 (0)