From c9d5d97e4d487b92a52d765dd9c467423ddd1de1 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 28 Sep 2026 16:45:54 -0300 Subject: A REPL's language is named and found as the syntax table finds one: aliases, any case Repl took only the grammar's exact name, and a file's language was found by a case-sensitive suffix of its path, apart from the aliases a code fence already had. The aliases move to grammar_manifest with byName and byPath, which syntax, Repl and langOf share, so `Repl py` and a .PY file work. The line-by-line warning is for the python language, not an id that starts with python. Joincol's doc line was sitting on Repl. Co-Authored-By: Claude Opus 5.5 --- src/syntax.zig | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) (limited to 'src/syntax.zig') diff --git a/src/syntax.zig b/src/syntax.zig index 9c1a4f4b..9930db20 100644 --- a/src/syntax.zig +++ b/src/syntax.zig @@ -226,35 +226,8 @@ fn forExt(ext: []const u8) !?Selected { return null; } -const LangAlias = struct { []const u8, []const u8 }; -const lang_aliases = [_]LangAlias{ - .{ "js", "javascript" }, - .{ "jsx", "javascript" }, - .{ "mjs", "javascript" }, - .{ "py", "python" }, - .{ "sh", "bash" }, - .{ "shell", "bash" }, - .{ "zsh", "bash" }, - .{ "bash", "bash" }, - .{ "rs", "rust" }, - .{ "c++", "cpp" }, - .{ "cxx", "cpp" }, - .{ "cc", "cpp" }, - .{ "cs", "c_sharp" }, - .{ "kt", "kotlin" }, - .{ "rb", "ruby" }, - .{ "ml", "ocaml" }, - .{ "hs", "haskell" }, -}; - fn forLang(name: []const u8) !?Selected { - var canonical = name; - for (lang_aliases) |a| { - if (std.ascii.eqlIgnoreCase(name, a[0])) { - canonical = a[1]; - break; - } - } + const canonical = if (grammar_manifest.byName(name)) |i| grammar_manifest.all[i].name else name; for (&specs) |*spec| { if (std.ascii.eqlIgnoreCase(canonical, spec.name)) return try ensure(spec); } -- cgit v1.3