Skip to content

Commit b701e70

Browse files
committed
Add txt grammar
1 parent 83c5acb commit b701e70

File tree

9 files changed

+78
-1
lines changed

9 files changed

+78
-1
lines changed

.changeset/few-poems-hunt.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@code-hike/lighter": patch
3+
---
4+
5+
Update grammars
6+
7+
- Update all grammars
8+
- Add txt grammar for text with comments
9+
- Add text to the list of LANG_NAMES

lib/dist/browser.esm.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,7 @@ const LANG_NAMES = [
608608
"tsx",
609609
"turtle",
610610
"twig",
611+
"txt",
611612
"typescript",
612613
"v",
613614
"vb",
@@ -816,6 +817,7 @@ const aliasOrIdToScope = {
816817
"tsx": "source.tsx",
817818
"turtle": "source.turtle",
818819
"twig": "text.html.twig",
820+
"txt": "source.txt",
819821
"typescript": "source.ts",
820822
"ts": "source.ts",
821823
"v": "source.v",
@@ -2258,6 +2260,11 @@ const scopeToLanguageData = {
22582260
"source.css"
22592261
]
22602262
},
2263+
"source.txt": {
2264+
"id": "txt",
2265+
"path": "txt.tmLanguage.json",
2266+
"embeddedScopes": []
2267+
},
22612268
"source.ts": {
22622269
"id": "typescript",
22632270
"path": "typescript.tmLanguage.json",

lib/dist/index.cjs.js

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/dist/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ declare class UnknownThemeError extends Error {
2828
declare const LANG_NAMES: string[];
2929
type NamesTuple = typeof LANG_NAMES;
3030
type LanguageAlias = NamesTuple[number];
31-
type LanguageName = "abap" | "actionscript-3" | "ada" | "apache" | "apex" | "apl" | "applescript" | "ara" | "asm" | "astro" | "awk" | "ballerina" | "bat" | "beancount" | "berry" | "bibtex" | "bicep" | "blade" | "c" | "cadence" | "clarity" | "clojure" | "cmake" | "cobol" | "codeql" | "coffee" | "cpp" | "crystal" | "csharp" | "css" | "cue" | "cypher" | "d" | "dart" | "dax" | "diff" | "docker" | "dream-maker" | "elixir" | "elm" | "erb" | "erlang" | "fish" | "fsharp" | "gdresource" | "gdscript" | "gdshader" | "gherkin" | "git-commit" | "git-rebase" | "glimmer-js" | "glimmer-ts" | "glsl" | "gnuplot" | "go" | "graphql" | "groovy" | "hack" | "haml" | "handlebars" | "haskell" | "hcl" | "hjson" | "hlsl" | "html" | "http" | "imba" | "ini" | "java" | "javascript" | "jinja-html" | "jison" | "json" | "json5" | "jsonc" | "jsonl" | "jsonnet" | "jssm" | "jsx" | "julia" | "kotlin" | "kusto" | "latex" | "less" | "liquid" | "lisp" | "logo" | "lua" | "make" | "markdown" | "marko" | "matlab" | "mdx" | "mermaid" | "narrat" | "nextflow" | "nginx" | "nim" | "nix" | "objective-c" | "objective-cpp" | "ocaml" | "pascal" | "perl" | "php" | "plsql" | "postcss" | "powerquery" | "powershell" | "prisma" | "prolog" | "proto" | "pug" | "puppet" | "purescript" | "python" | "r" | "raku" | "razor" | "reg" | "rel" | "riscv" | "rst" | "ruby" | "rust" | "sas" | "sass" | "scala" | "scheme" | "scss" | "shaderlab" | "shellscript" | "shellsession" | "smalltalk" | "solidity" | "sparql" | "sql" | "ssh-config" | "stata" | "stylus" | "svelte" | "swift" | "system-verilog" | "tasl" | "tcl" | "tex" | "toml" | "tsx" | "turtle" | "twig" | "typescript" | "v" | "vb" | "verilog" | "vhdl" | "viml" | "vue-html" | "vue" | "vyper" | "wasm" | "wenyan" | "wgsl" | "wolfram" | "xml" | "xsl" | "yaml" | "zenscript";
31+
type LanguageName = "abap" | "actionscript-3" | "ada" | "apache" | "apex" | "apl" | "applescript" | "ara" | "asm" | "astro" | "awk" | "ballerina" | "bat" | "beancount" | "berry" | "bibtex" | "bicep" | "blade" | "c" | "cadence" | "clarity" | "clojure" | "cmake" | "cobol" | "codeql" | "coffee" | "cpp" | "crystal" | "csharp" | "css" | "cue" | "cypher" | "d" | "dart" | "dax" | "diff" | "docker" | "dream-maker" | "elixir" | "elm" | "erb" | "erlang" | "fish" | "fsharp" | "gdresource" | "gdscript" | "gdshader" | "gherkin" | "git-commit" | "git-rebase" | "glimmer-js" | "glimmer-ts" | "glsl" | "gnuplot" | "go" | "graphql" | "groovy" | "hack" | "haml" | "handlebars" | "haskell" | "hcl" | "hjson" | "hlsl" | "html" | "http" | "imba" | "ini" | "java" | "javascript" | "jinja-html" | "jison" | "json" | "json5" | "jsonc" | "jsonl" | "jsonnet" | "jssm" | "jsx" | "julia" | "kotlin" | "kusto" | "latex" | "less" | "liquid" | "lisp" | "logo" | "lua" | "make" | "markdown" | "marko" | "matlab" | "mdx" | "mermaid" | "narrat" | "nextflow" | "nginx" | "nim" | "nix" | "objective-c" | "objective-cpp" | "ocaml" | "pascal" | "perl" | "php" | "plsql" | "postcss" | "powerquery" | "powershell" | "prisma" | "prolog" | "proto" | "pug" | "puppet" | "purescript" | "python" | "r" | "raku" | "razor" | "reg" | "rel" | "riscv" | "rst" | "ruby" | "rust" | "sas" | "sass" | "scala" | "scheme" | "scss" | "shaderlab" | "shellscript" | "shellsession" | "smalltalk" | "solidity" | "sparql" | "sql" | "ssh-config" | "stata" | "stylus" | "svelte" | "swift" | "system-verilog" | "tasl" | "tcl" | "tex" | "toml" | "tsx" | "turtle" | "twig" | "txt" | "typescript" | "v" | "vb" | "verilog" | "vhdl" | "viml" | "vue-html" | "vue" | "vyper" | "wasm" | "wenyan" | "wgsl" | "wolfram" | "xml" | "xsl" | "yaml" | "zenscript";
3232

3333
type LineNumber = number;
3434
type ColumnNumber = number;

lib/dist/index.esm.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,7 @@ const LANG_NAMES = [
956956
"tsx",
957957
"turtle",
958958
"twig",
959+
"txt",
959960
"typescript",
960961
"v",
961962
"vb",
@@ -1164,6 +1165,7 @@ const aliasOrIdToScope = {
11641165
"tsx": "source.tsx",
11651166
"turtle": "source.turtle",
11661167
"twig": "text.html.twig",
1168+
"txt": "source.txt",
11671169
"typescript": "source.ts",
11681170
"ts": "source.ts",
11691171
"v": "source.v",
@@ -2606,6 +2608,11 @@ const scopeToLanguageData = {
26062608
"source.css"
26072609
]
26082610
},
2611+
"source.txt": {
2612+
"id": "txt",
2613+
"path": "txt.tmLanguage.json",
2614+
"embeddedScopes": []
2615+
},
26092616
"source.ts": {
26102617
"id": "typescript",
26112618
"path": "typescript.tmLanguage.json",

lib/grammars/txt.tmLanguage.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "txt",
3+
"scopeName": "source.txt",
4+
"patterns": [
5+
{
6+
"include": "#comment"
7+
}
8+
],
9+
"repository": {
10+
"comment": {
11+
"begin": "(?:(^[ \\t]*)|[ \\t]+)(?=#\\p{Print}*$)",
12+
"beginCaptures": {
13+
"1": {
14+
"name": "punctuation.whitespace.comment.leading.txt"
15+
}
16+
},
17+
"end": "(?!\\G)",
18+
"patterns": [
19+
{
20+
"begin": "#",
21+
"beginCaptures": {
22+
"0": {
23+
"name": "punctuation.definition.comment.txt"
24+
}
25+
},
26+
"end": "\\n",
27+
"name": "comment.line.number-sign.txt"
28+
}
29+
]
30+
}
31+
}
32+
}

lib/src/language-data.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ export const LANG_NAMES = [
187187
"tsx",
188188
"turtle",
189189
"twig",
190+
"txt",
190191
"typescript",
191192
"v",
192193
"vb",
@@ -363,6 +364,7 @@ export type LanguageName =
363364
| "tsx"
364365
| "turtle"
365366
| "twig"
367+
| "txt"
366368
| "typescript"
367369
| "v"
368370
| "vb"
@@ -531,6 +533,7 @@ export type ScopeName =
531533
| "source.tsx"
532534
| "source.turtle"
533535
| "text.html.twig"
536+
| "source.txt"
534537
| "source.ts"
535538
| "source.v"
536539
| "source.asp.vb.net"
@@ -740,6 +743,7 @@ export const aliasOrIdToScope: Record<LanguageAlias, ScopeName> = {
740743
"tsx": "source.tsx",
741744
"turtle": "source.turtle",
742745
"twig": "text.html.twig",
746+
"txt": "source.txt",
743747
"typescript": "source.ts",
744748
"ts": "source.ts",
745749
"v": "source.v",
@@ -2182,6 +2186,11 @@ export const scopeToLanguageData: Record<ScopeName, LanguageData> = {
21822186
"source.css"
21832187
]
21842188
},
2189+
"source.txt": {
2190+
"id": "txt",
2191+
"path": "txt.tmLanguage.json",
2192+
"embeddedScopes": []
2193+
},
21852194
"source.ts": {
21862195
"id": "typescript",
21872196
"path": "typescript.tmLanguage.json",

lib/utils/languages.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,11 @@ export const languages = [
12021202
"ruby"
12031203
]
12041204
},
1205+
{
1206+
"id": "txt",
1207+
"scopeName": "source.txt",
1208+
"path": "txt.tmLanguage.json"
1209+
},
12051210
{
12061211
"id": "typescript",
12071212
"scopeName": "source.ts",

web/public/grammars/txt.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"name":"txt","scopeName":"source.txt","patterns":[{"include":"#comment"}],"repository":{"comment":{"begin":"(?:(^[ \\t]*)|[ \\t]+)(?=#\\p{Print}*$)","beginCaptures":{"1":{"name":"punctuation.whitespace.comment.leading.txt"}},"end":"(?!\\G)","patterns":[{"begin":"#","beginCaptures":{"0":{"name":"punctuation.definition.comment.txt"}},"end":"\\n","name":"comment.line.number-sign.txt"}]}}}]

0 commit comments

Comments
 (0)