Compare commits

...

2 commits

Author SHA1 Message Date
7ee2cb5ba3
feat: update flow-syntax 2025-08-22 23:03:31 +02:00
ebccd70d7d
feat: update flow-themes 2025-08-22 22:43:59 +02:00
2 changed files with 15 additions and 12 deletions

View file

@ -8,12 +8,12 @@
.hash = "clap-0.10.0-oBajB434AQBDh-Ei3YtoKIRxZacVPF1iSwp3IX_ZB8f0",
},
.themes = .{
.url = "https://github.com/neurocyte/flow-themes/releases/download/master-ac2e3fe2df3419b71276f86fa9c45fd39d668f23/flow-themes.tar.gz",
.hash = "N-V-__8AAEtaFwAjAHCmWHRCrBxL7uSG4hQiIsSgS32Y67K6",
.url = "https://github.com/neurocyte/flow-themes/releases/download/master-952f9f630ea9544088fd30293666ee0650b7a690/flow-themes.tar.gz",
.hash = "N-V-__8AAJiAIgDMVIi8CRb_xko9_qVQ-UiQzd5FTBBr0aPa",
},
.syntax = .{
.url = "https://github.com/neurocyte/flow-syntax/archive/fa6a411bc769882acc87cf0d961af3813abf2eac.tar.gz",
.hash = "flow_syntax-0.1.0-X8jOof39AADK25RT1Bst_x7aUIwHbh7y09PJXBghLu_b",
.url = "git+https://github.com/neurocyte/flow-syntax?ref=zig-0.14#410d19e633f237cd1602175450bd7d3bb03a1898",
.hash = "flow_syntax-0.1.0-X8jOoT4OAQDibKKzYlJls3u5KczVh__cWYN7vTqCE1o3",
},
.ansi_term = .{
.url = "https://github.com/ziglibs/ansi-term/archive/c0e6ad093d4f6a9ed4e65d962d1e53b97888f989.tar.gz",

View file

@ -167,11 +167,14 @@ pub fn main() !void {
try write_html_postamble(writer);
}
fn get_parser(a: std.mem.Allocator, content: []const u8, file_path: []const u8, query_cache: *syntax.QueryCache) *syntax {
return (if (lang_override) |name|
syntax.create_file_type(a, name, query_cache) catch unknown_file_type(name)
else
syntax.create_guess_file_type(a, content, file_path, query_cache)) catch syntax.create_file_type(a, lang_default, query_cache) catch unknown_file_type(lang_default);
fn get_parser(a: std.mem.Allocator, content: []const u8, file_path: []const u8, query_cache: *syntax.QueryCache) struct { syntax.FileType, *syntax } {
return if (lang_override) |name| blk: {
const file_type = syntax.FileType.get_by_name_static(name) orelse unknown_file_type(lang_default);
break :blk .{ file_type, syntax.create(file_type, a, query_cache) catch unknown_file_type(name) };
} else blk: {
const file_type = syntax.FileType.guess_static(file_path, content) orelse unknown_file_type(lang_default);
break :blk .{ file_type, syntax.create(file_type, a, query_cache) catch unknown_file_type(lang_default) };
};
}
fn unknown_file_type(name: []const u8) noreturn {
@ -211,10 +214,10 @@ fn render_file(
}
const query_cache = try syntax.QueryCache.create(a, .{});
const parser = get_parser(a, content, file_path, query_cache);
const file_type, const parser = get_parser(a, content, file_path, query_cache);
try parser.refresh_full(content);
if (show_file_type) {
try render_file_type(writer, parser.file_type, theme);
try render_file_type(writer, &file_type, theme);
end_line -= 1;
}
if (show_theme) {
@ -468,7 +471,7 @@ fn write_hex_color(writer: Writer, color: u24) !void {
}
fn list_langs(writer: Writer) !void {
for (syntax.FileType.file_types) |file_type| {
for (syntax.FileType.get_all()) |file_type| {
try writer.writeAll(file_type.name);
try writer.writeAll("\n");
}