/** file → grammar classification, shared by highlighting and the per-language file listing */ // mirrors canonical() in src/grammar_manifest.rs; keep them in sync const grammars: Record = { ada: "ada", adb: "ada", adoc: "asciidoc", ads: "ada", agda: "agda", asciidoc: "asciidoc", asm: "asm", assembly: "asm", awk: "awk", bash: "bash", bash_profile: "bash", bashrc: "bash", bat: "batch", batch: "batch", bazel: "starlark", bzl: "starlark", c: "c", "c#": "c-sharp", "c++": "cpp", "c-sharp": "c-sharp", caddy: "caddy", caddyfile: "caddy", capnp: "capnp", cbl: "cobol", cc: "cpp", cedar: "cedar", cedarschema: "cedarschema", cfg: "ini", cjs: "javascript", cl: "commonlisp", clj: "clojure", cljc: "clojure", cljs: "clojure", clojure: "clojure", cmake: "cmake", "cmakelists.txt": "cmake", cmd: "batch", cob: "cobol", cobol: "cobol", commonlisp: "commonlisp", conf: "ini", console: "bash", containerfile: "dockerfile", cpp: "cpp", cpy: "cobol", cs: "c-sharp", csharp: "c-sharp", csproj: "xml", css: "css", cts: "typescript", cxx: "cpp", d: "d", dart: "dart", devicetree: "devicetree", diff: "diff", dlang: "d", docker: "dockerfile", dockerfile: "dockerfile", dot: "dot", dts: "devicetree", dtsi: "devicetree", editorconfig: "ini", edn: "clojure", el: "elisp", elisp: "elisp", elixir: "elixir", elm: "elm", "emacs-lisp": "elisp", erl: "erlang", erlang: "erlang", ex: "elixir", exs: "elixir", "f#": "fsharp", fish: "fish", frag: "glsl", fs: "fsharp", fsharp: "fsharp", fsx: "fsharp", gemfile: "ruby", gemspec: "ruby", gitattributes: "gitattributes", gitconfig: "ini", gitmodules: "ini", gleam: "gleam", glsl: "glsl", gnumakefile: "make", go: "go", golang: "go", gql: "graphql", gradle: "groovy", graphql: "graphql", graphviz: "dot", groovy: "groovy", gsh: "groovy", gv: "dot", gvy: "groovy", gy: "groovy", h: "c", haskell: "haskell", hcl: "hcl", hh: "cpp", hlsl: "hlsl", hpp: "cpp", hrl: "erlang", hs: "haskell", htm: "html", html: "html", hxx: "cpp", idr: "idris", idris: "idris", ini: "ini", j2: "jinja2", java: "java", javascript: "javascript", jinja: "jinja2", jinja2: "jinja2", jl: "julia", jq: "jq", js: "javascript", jsdoc: "jsdoc", json: "json", json5: "json", jsonc: "json", jsx: "javascript", julia: "julia", just: "just", justfile: "just", kconfig: "kconfig", kdl: "kdl", kotlin: "kotlin", kt: "kotlin", kts: "kotlin", lean: "lean", lisp: "commonlisp", lua: "lua", m: "matlab", make: "make", makefile: "make", markdown: "markdown", matlab: "matlab", md: "markdown", mdx: "markdown", meson: "meson", "meson.build": "meson", mjs: "javascript", mk: "make", ml: "ocaml", mli: "ocaml", mm: "objc", mts: "typescript", mysql: "sql", nasm: "x86asm", nginx: "nginx", "nginx.conf": "nginx", ninja: "ninja", nix: "nix", objc: "objc", "objective-c": "objc", objectivec: "objc", ocaml: "ocaml", odin: "odin", opa: "rego", patch: "diff", pbtxt: "textproto", perl: "perl", pgsql: "sql", php: "php", pl: "perl", plist: "xml", plsql: "sql", pm: "perl", postgres: "sql", postgresql: "sql", postscript: "postscript", powershell: "powershell", pro: "prolog", prolog: "prolog", proto: "proto", protobuf: "proto", ps: "postscript", ps1: "powershell", psm1: "powershell", pwsh: "powershell", py: "python", py3: "python", pyi: "python", python: "python", python3: "python", query: "query", r: "r", racket: "scheme", rakefile: "ruby", rb: "ruby", regex: "regex", regexp: "regex", rego: "rego", res: "rescript", rescript: "rescript", rkt: "scheme", rlang: "r", ron: "ron", rq: "sparql", rs: "rust", ruby: "ruby", rust: "rust", s: "asm", sass: "scss", sbt: "scala", scala: "scala", scheme: "scheme", scm: "query", scss: "scss", sh: "bash", shell: "bash", sol: "solidity", solidity: "solidity", sparql: "sparql", sql: "sql", sqlite: "sql", ss: "scheme", "ssh-config": "ssh-config", ssh_config: "ssh-config", sshd_config: "ssh-config", starlark: "starlark", styx: "styx", sv: "verilog", svelte: "svelte", svg: "xml", swift: "swift", systemverilog: "verilog", terraform: "hcl", textpb: "textproto", textproto: "textproto", tf: "hcl", tfvars: "hcl", thrift: "thrift", tla: "tlaplus", tlaplus: "tlaplus", toml: "toml", ts: "typescript", tsql: "sql", tsx: "tsx", typ: "typst", typescript: "typescript", typst: "typst", ua: "uiua", uiua: "uiua", v: "verilog", vb: "vb", vbnet: "vb", verilog: "verilog", vert: "glsl", vhd: "vhdl", vhdl: "vhdl", vim: "vim", viml: "vim", vimrc: "vim", vimscript: "vim", visualbasic: "vb", vue: "vue", "wasm-interface": "wit", wit: "wit", x86: "x86asm", x86asm: "x86asm", xhtml: "html", xml: "xml", xsd: "xml", xsl: "xml", xslt: "xml", yaml: "yaml", yml: "yaml", yuri: "yuri", zig: "zig", zon: "zig", zsh: "zsh", zshrc: "zsh", }; /** mirrors detect() in src/grammar_manifest.rs: by file name, then by extension */ export function detectLanguage(path: string): string | null { const name = path.split("/").at(-1)!.toLowerCase(); return grammars[name] ?? grammars[name.split(".").at(-1)!] ?? null; } /** mirrors group() in src/languages.rs; keep them in sync */ export const languageGroup = (grammar: string) => grammar === "tsx" ? "typescript" : grammar;