Compare commits

...

14 commits

4 changed files with 17 additions and 12 deletions

View file

@ -9,7 +9,7 @@ pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{}); const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{}); const optimize = b.standardOptimizeOption(.{});
const tree_sitter_dep = b.dependency("tree-sitter", .{ const tree_sitter_dep = b.dependency("tree_sitter", .{
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
}); });

View file

@ -1,11 +1,13 @@
.{ .{
.name = "flow-syntax", .name = .flow_syntax,
.version = "0.0.1", .version = "0.1.0",
.fingerprint = 0x3ba2584ea1cec85f,
.minimum_zig_version = "0.14.0-dev.3451+d8d2aa9af",
.dependencies = .{ .dependencies = .{
.@"tree-sitter" = .{ .tree_sitter = .{
.url = "https://github.com/neurocyte/tree-sitter/releases/download/master-86dd4d2536f2748c5b4ea0e1e70678039a569aac/source.tar.gz", .url = "https://github.com/neurocyte/tree-sitter/releases/download/master-86dd4d2536f2748c5b4ea0e1e70678039a569aac/source.tar.gz",
.hash = "1220e9fba96c468283129e977767472dee00b16f356e5912431cec8f1a009b6691a2", .hash = "N-V-__8AACablCbp-6lsRoKDEp6Xd2dHLe4AsW81blkSQxzs",
}, },
}, },
.paths = .{ .paths = .{

View file

@ -88,7 +88,7 @@ fn ft_func_name(comptime lang: []const u8) []const u8 {
const LangFn = *const fn () callconv(.C) ?*const treez.Language; const LangFn = *const fn () callconv(.C) ?*const treez.Language;
const FirstLineMatch = struct { pub const FirstLineMatch = struct {
prefix: ?[]const u8 = null, prefix: ?[]const u8 = null,
content: ?[]const u8 = null, content: ?[]const u8 = null,
}; };
@ -105,7 +105,7 @@ fn vec(comptime args: anytype) []const []const u8 {
fn load_file_types(comptime Namespace: type) []const FileType { fn load_file_types(comptime Namespace: type) []const FileType {
comptime switch (@typeInfo(Namespace)) { comptime switch (@typeInfo(Namespace)) {
.Struct => |info| { .@"struct" => |info| {
var count = 0; var count = 0;
for (info.decls) |_| { for (info.decls) |_| {
// @compileLog(decl.name, @TypeOf(@field(Namespace, decl.name))); // @compileLog(decl.name, @TypeOf(@field(Namespace, decl.name)));

View file

@ -1,3 +1,6 @@
const file_type = @import("file_type.zig");
const FirstLineMatch = file_type.FirstLineMatch;
pub const agda = .{ pub const agda = .{
.description = "Agda", .description = "Agda",
.extensions = .{"agda"}, .extensions = .{"agda"},
@ -18,7 +21,7 @@ pub const bash = .{
.icon = "󱆃", .icon = "󱆃",
.extensions = .{ "sh", "bash", ".profile" }, .extensions = .{ "sh", "bash", ".profile" },
.comment = "#", .comment = "#",
.first_line_matches = .{ .prefix = "#!", .content = "sh" }, .first_line_matches = FirstLineMatch{ .prefix = "#!", .content = "sh" },
.formatter = .{ "shfmt", "--indent", "4" }, .formatter = .{ "shfmt", "--indent", "4" },
.language_server = .{ "bash-language-server", "start" }, .language_server = .{ "bash-language-server", "start" },
}; };
@ -253,7 +256,7 @@ pub const lua = .{
.extensions = .{"lua"}, .extensions = .{"lua"},
.comment = "--", .comment = "--",
.injections = "tree-sitter-lua/queries/injections.scm", .injections = "tree-sitter-lua/queries/injections.scm",
.first_line_matches = .{ .prefix = "--", .content = "lua" }, .first_line_matches = FirstLineMatch{ .prefix = "--", .content = "lua" },
.language_server = .{"lua-lsp"}, .language_server = .{"lua-lsp"},
}; };
@ -263,7 +266,7 @@ pub const mail = .{
.extensions = .{ "eml", "mbox" }, .extensions = .{ "eml", "mbox" },
.comment = ">", .comment = ">",
.highlights = "tree-sitter-mail/queries/mail/highlights.scm", .highlights = "tree-sitter-mail/queries/mail/highlights.scm",
.first_line_matches = .{ .prefix = "From" }, .first_line_matches = FirstLineMatch{ .prefix = "From" },
}; };
pub const make = .{ pub const make = .{
@ -407,7 +410,7 @@ pub const python = .{
.icon = "󰌠", .icon = "󰌠",
.extensions = .{ "py", "pyi" }, .extensions = .{ "py", "pyi" },
.comment = "#", .comment = "#",
.first_line_matches = .{ .prefix = "#!", .content = "python" }, .first_line_matches = FirstLineMatch{ .prefix = "#!", .content = "python" },
.language_server = .{"pylsp"}, .language_server = .{"pylsp"},
}; };
@ -520,7 +523,7 @@ pub const xml = .{
.extensions = .{"xml"}, .extensions = .{"xml"},
.comment = "<!--", .comment = "<!--",
.highlights = "tree-sitter-xml/queries/xml/highlights.scm", .highlights = "tree-sitter-xml/queries/xml/highlights.scm",
.first_line_matches = .{ .prefix = "<?xml " }, .first_line_matches = FirstLineMatch{ .prefix = "<?xml " },
.formatter = .{ "xmllint", "--format", "-" }, .formatter = .{ "xmllint", "--format", "-" },
}; };