From dc4ce57e7a17cf1120d953c1c1d5388295181a8f Mon Sep 17 00:00:00 2001 From: Rodrigo Pombo Date: Thu, 26 Dec 2024 13:08:17 +0100 Subject: [PATCH] Update grammars --- .changeset/bright-starfishes-lick.md | 5 ++ known-issues.md | 16 ++++++ lib/package.json | 6 +-- lib/src/dynamic-imports.ts | 12 +++++ lib/src/language-data.ts | 77 ++++++++++++++++++++++++++-- yarn.lock | 8 +-- 6 files changed, 112 insertions(+), 12 deletions(-) create mode 100644 .changeset/bright-starfishes-lick.md create mode 100644 known-issues.md diff --git a/.changeset/bright-starfishes-lick.md b/.changeset/bright-starfishes-lick.md new file mode 100644 index 0000000..941ad98 --- /dev/null +++ b/.changeset/bright-starfishes-lick.md @@ -0,0 +1,5 @@ +--- +"@code-hike/lighter": patch +--- + +Update grammars diff --git a/known-issues.md b/known-issues.md new file mode 100644 index 0000000..5f0863d --- /dev/null +++ b/known-issues.md @@ -0,0 +1,16 @@ +## New grammars + +`lighter` uses the grammars from the `tm-grammars` package. When a grammar is updated you can use the new version by updating the `tm-grammars` package. But when a new grammar is added to `tm-grammars` we need to release a new version of `lighter` to include it. + +To release a new version including new grammars: + +- Update and download the `tm-grammars` dependency +- Run `yarn regenerate` +- Add a changeset (`yarn changeset`) +- Commit and push the changes + +## "Fetching resource from network" warning + +Sometimes `lighter` fails to use the file system to get the grammars or themes, as a fallback it tries to fetch them from the network. + +This is expected if you use `lighter` from the browser (or from an edge runtime which identifies itself as a browser). diff --git a/lib/package.json b/lib/package.json index 41a2d0c..226bd99 100644 --- a/lib/package.json +++ b/lib/package.json @@ -40,8 +40,7 @@ "typescript": "^4.9.4", "vitest": "1.0.0-beta.1", "vscode-oniguruma": "1.7.0", - "vscode-textmate": "9.0.0", - "tm-grammars": "1.16.2" + "vscode-textmate": "9.0.0" }, "scripts": { "build": "rollup -c", @@ -54,6 +53,7 @@ "homepage": "https://codehike.org", "funding": "https://github.com/sponsors/code-hike", "dependencies": { - "ansi-sequence-parser": "1.1.1" + "ansi-sequence-parser": "1.1.1", + "tm-grammars": "^1.21.10" } } diff --git a/lib/src/dynamic-imports.ts b/lib/src/dynamic-imports.ts index 4162279..f1e3c96 100644 --- a/lib/src/dynamic-imports.ts +++ b/lib/src/dynamic-imports.ts @@ -44,10 +44,14 @@ export async function importGrammar(langId: string): Promise { return import("tm-grammars/grammars/bicep.json"); case "blade": return import("tm-grammars/grammars/blade.json"); + case "bsl": + return import("tm-grammars/grammars/bsl.json"); case "c": return import("tm-grammars/grammars/c.json"); case "cadence": return import("tm-grammars/grammars/cadence.json"); + case "cairo": + return import("tm-grammars/grammars/cairo.json"); case "clarity": return import("tm-grammars/grammars/clarity.json"); case "clojure": @@ -64,6 +68,8 @@ export async function importGrammar(langId: string): Promise { return import("tm-grammars/grammars/coffee.json"); case "common-lisp": return import("tm-grammars/grammars/common-lisp.json"); + case "coq": + return import("tm-grammars/grammars/coq.json"); case "cpp": return import("tm-grammars/grammars/cpp.json"); case "crystal": @@ -236,6 +242,8 @@ export async function importGrammar(langId: string): Promise { return import("tm-grammars/grammars/mdx.json"); case "mermaid": return import("tm-grammars/grammars/mermaid.json"); + case "mipsasm": + return import("tm-grammars/grammars/mipsasm.json"); case "mojo": return import("tm-grammars/grammars/mojo.json"); case "move": @@ -326,6 +334,8 @@ export async function importGrammar(langId: string): Promise { return import("tm-grammars/grammars/scheme.json"); case "scss": return import("tm-grammars/grammars/scss.json"); + case "sdbl": + return import("tm-grammars/grammars/sdbl.json"); case "shaderlab": return import("tm-grammars/grammars/shaderlab.json"); case "shellscript": @@ -358,6 +368,8 @@ export async function importGrammar(langId: string): Promise { return import("tm-grammars/grammars/system-verilog.json"); case "systemd": return import("tm-grammars/grammars/systemd.json"); + case "talonscript": + return import("tm-grammars/grammars/talonscript.json"); case "tasl": return import("tm-grammars/grammars/tasl.json"); case "tcl": diff --git a/lib/src/language-data.ts b/lib/src/language-data.ts index 0e394e5..c2bf54c 100644 --- a/lib/src/language-data.ts +++ b/lib/src/language-data.ts @@ -1,6 +1,8 @@ // generated by lib/utils/02.languages-data.mjs export const LANG_NAMES = [ + "1c", + "1c-query", "abap", "actionscript-3", "ada", @@ -26,10 +28,12 @@ export const LANG_NAMES = [ "bibtex", "bicep", "blade", + "bsl", "c", "c#", "c++", "cadence", + "cairo", "cdc", "clarity", "clj", @@ -44,6 +48,7 @@ export const LANG_NAMES = [ "coffeescript", "common-lisp", "console", + "coq", "cpp", "cql", "crystal", @@ -164,6 +169,9 @@ export const LANG_NAMES = [ "mdx", "mediawiki", "mermaid", + "mips", + "mipsasm", + "mmd", "mojo", "move", "nar", @@ -194,6 +202,7 @@ export const LANG_NAMES = [ "prolog", "properties", "proto", + "protobuf", "ps", "ps1", "pug", @@ -224,6 +233,7 @@ export const LANG_NAMES = [ "scala", "scheme", "scss", + "sdbl", "sh", "shader", "shaderlab", @@ -245,6 +255,8 @@ export const LANG_NAMES = [ "swift", "system-verilog", "systemd", + "talon", + "talonscript", "tasl", "tcl", "templ", @@ -319,8 +331,10 @@ export type LanguageName = | "bibtex" | "bicep" | "blade" + | "bsl" | "c" | "cadence" + | "cairo" | "clarity" | "clojure" | "cmake" @@ -329,6 +343,7 @@ export type LanguageName = | "codeql" | "coffee" | "common-lisp" + | "coq" | "cpp" | "crystal" | "csharp" @@ -415,6 +430,7 @@ export type LanguageName = | "mdc" | "mdx" | "mermaid" + | "mipsasm" | "mojo" | "move" | "narrat" @@ -460,6 +476,7 @@ export type LanguageName = | "scala" | "scheme" | "scss" + | "sdbl" | "shaderlab" | "shellscript" | "shellsession" @@ -476,6 +493,7 @@ export type LanguageName = | "swift" | "system-verilog" | "systemd" + | "talonscript" | "tasl" | "tcl" | "templ" @@ -532,8 +550,10 @@ export type ScopeName = | "text.bibtex" | "source.bicep" | "text.html.php.blade" + | "source.bsl" | "source.c" | "source.cadence" + | "source.cairo0" | "source.clar" | "source.clojure" | "source.cmake" @@ -542,6 +562,7 @@ export type ScopeName = | "source.ql" | "source.coffee" | "source.commonlisp" + | "source.coq" | "source.cpp" | "source.crystal" | "source.cs" @@ -625,9 +646,10 @@ export type ScopeName = | "text.html.markdown" | "text.marko" | "source.matlab" - | "text.markdown.mdc" + | "text.markdown.mdc.standalone" | "source.mdx" | "markdown.mermaid.codeblock" + | "source.mips" | "source.mojo" | "source.move" | "source.narrat" @@ -673,6 +695,7 @@ export type ScopeName = | "source.scala" | "source.scheme" | "source.css.scss" + | "source.sdbl" | "source.shaderlab" | "source.shell" | "text.shell-session" @@ -689,6 +712,7 @@ export type ScopeName = | "source.swift" | "source.systemverilog" | "source.systemd" + | "source.talon" | "source.tasl" | "source.tcl" | "source.templ" @@ -754,9 +778,12 @@ export const aliasOrIdToScope: Record = { "bibtex": "text.bibtex", "bicep": "source.bicep", "blade": "text.html.php.blade", + "bsl": "source.bsl", + "1c": "source.bsl", "c": "source.c", "cadence": "source.cadence", "cdc": "source.cadence", + "cairo": "source.cairo0", "clarity": "source.clar", "clojure": "source.clojure", "clj": "source.clojure", @@ -769,6 +796,7 @@ export const aliasOrIdToScope: Record = { "coffeescript": "source.coffee", "common-lisp": "source.commonlisp", "lisp": "source.commonlisp", + "coq": "source.coq", "cpp": "source.cpp", "c++": "source.cpp", "crystal": "source.crystal", @@ -885,9 +913,12 @@ export const aliasOrIdToScope: Record = { "md": "text.html.markdown", "marko": "text.marko", "matlab": "source.matlab", - "mdc": "text.markdown.mdc", + "mdc": "text.markdown.mdc.standalone", "mdx": "source.mdx", "mermaid": "markdown.mermaid.codeblock", + "mmd": "markdown.mermaid.codeblock", + "mipsasm": "source.mips", + "mips": "source.mips", "mojo": "source.mojo", "move": "source.move", "narrat": "source.narrat", @@ -918,6 +949,7 @@ export const aliasOrIdToScope: Record = { "prisma": "source.prisma", "prolog": "source.prolog", "proto": "source.proto", + "protobuf": "source.proto", "pug": "text.pug", "jade": "text.pug", "puppet": "source.puppet", @@ -947,6 +979,8 @@ export const aliasOrIdToScope: Record = { "scala": "source.scala", "scheme": "source.scheme", "scss": "source.css.scss", + "sdbl": "source.sdbl", + "1c-query": "source.sdbl", "shaderlab": "source.shaderlab", "shader": "source.shaderlab", "shellscript": "source.shell", @@ -972,6 +1006,8 @@ export const aliasOrIdToScope: Record = { "swift": "source.swift", "system-verilog": "source.systemverilog", "systemd": "source.systemd", + "talonscript": "source.talon", + "talon": "source.talon", "tasl": "source.tasl", "tcl": "source.tcl", "templ": "source.templ", @@ -1175,6 +1211,12 @@ export const scopeToLanguageData: Record = { "source.css" ] }, + "source.bsl": { + "id": "bsl", + "embeddedScopes": [ + "source.sdbl" + ] + }, "source.c": { "id": "c", "embeddedScopes": [] @@ -1183,6 +1225,12 @@ export const scopeToLanguageData: Record = { "id": "cadence", "embeddedScopes": [] }, + "source.cairo0": { + "id": "cairo", + "embeddedScopes": [ + "source.python" + ] + }, "source.clar": { "id": "clarity", "embeddedScopes": [] @@ -1198,7 +1246,6 @@ export const scopeToLanguageData: Record = { "source.cobol": { "id": "cobol", "embeddedScopes": [ - "source.sql", "text.html.basic", "source.java" ] @@ -1221,6 +1268,10 @@ export const scopeToLanguageData: Record = { "id": "common-lisp", "embeddedScopes": [] }, + "source.coq": { + "id": "coq", + "embeddedScopes": [] + }, "source.cpp": { "id": "cpp", "embeddedScopes": [ @@ -1725,7 +1776,7 @@ export const scopeToLanguageData: Record = { "id": "matlab", "embeddedScopes": [] }, - "text.markdown.mdc": { + "text.markdown.mdc.standalone": { "id": "mdc", "embeddedScopes": [ "text.html.markdown", @@ -1784,6 +1835,10 @@ export const scopeToLanguageData: Record = { "id": "mermaid", "embeddedScopes": [] }, + "source.mips": { + "id": "mipsasm", + "embeddedScopes": [] + }, "source.mojo": { "id": "mojo", "embeddedScopes": [] @@ -1985,13 +2040,17 @@ export const scopeToLanguageData: Record = { "id": "ruby", "embeddedScopes": [ "text.html.basic", + "text.haml", "text.xml", "source.sql", + "source.graphql", "source.css", + "source.cpp", "source.c", "source.js", "source.shell", - "source.lua" + "source.lua", + "source.yaml" ] }, "source.rust": { @@ -2022,6 +2081,10 @@ export const scopeToLanguageData: Record = { "source.css" ] }, + "source.sdbl": { + "id": "sdbl", + "embeddedScopes": [] + }, "source.shaderlab": { "id": "shaderlab", "embeddedScopes": [ @@ -2108,6 +2171,10 @@ export const scopeToLanguageData: Record = { "id": "systemd", "embeddedScopes": [] }, + "source.talon": { + "id": "talonscript", + "embeddedScopes": [] + }, "source.tasl": { "id": "tasl", "embeddedScopes": [] diff --git a/yarn.lock b/yarn.lock index e09d20c..163b45d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2867,10 +2867,10 @@ tinyspy@^2.2.0: resolved "https://registry.yarnpkg.com/tinyspy/-/tinyspy-2.2.0.tgz#9dc04b072746520b432f77ea2c2d17933de5d6ce" integrity sha512-d2eda04AN/cPOR89F7Xv5bK/jrQEhmcLFe6HFldoeO9AJtps+fqEnh486vnT/8y4bw38pSyxDcTCAq+Ks2aJTg== -tm-grammars@1.16.2: - version "1.16.2" - resolved "https://registry.yarnpkg.com/tm-grammars/-/tm-grammars-1.16.2.tgz#a2311f5af90a2fa8293b9ce995d4b74114417956" - integrity sha512-XTxg7/sFP6pLrLaBap1tmzWQjozFUBpw2EC/uE3ElAEtxJtzVMUkPes+ixR5HC88wFdDyRxYilvIHRRCSDZ3nQ== +tm-grammars@^1.21.10: + version "1.21.10" + resolved "https://registry.yarnpkg.com/tm-grammars/-/tm-grammars-1.21.10.tgz#978b2fa8ceea6bda6df39bf888af0e216cd0e909" + integrity sha512-0TSAeQ90vvh0xRGdLw/HZG3K4M9gE1rwhGDB29QtoA5h2eRRD8tlGwukBJKx/y23l9EDbMP3+2QFeJqMsVOgBQ== tmp@^0.0.33: version "0.0.33"