From 77a69410b8bdd993cb092c93353ecd51c0227353 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Wed, 5 Mar 2025 10:43:03 +0100 Subject: [PATCH] Squashed 'src/syntax/' changes from ba10d896..d5c1cd2a d5c1cd2a Merge branch 'master' into zig-0.14 6b4feb7d update dep hash 46cd19ca update to latest zig 7214ee0a refactor: run zig fmt b2238178 Set php's default LSP to intelephense 8b3a5ac1 refactor: run zig fmt 942e8dfd Merge commit 'f3c35545e3ba6038460bab1d130be54eb1067a29' into zig-0.14 f3c35545 Merge branch 'master' into zig-0.14 28bc77f4 feat: add astro file type support be80b598 refactor: run zig fmt 670aa9ae build: update to zig 0.14.0-dev.3039 f81314c1 feat: add .ref to diff file type extensions 01558741 feat: add sql file type support 942053ff add systemverilog lsp and formatter 3711541e anonymous struct do not coerce anymore since zig commit d11bbde da812e05 fix(config): add gui_config to file_types ec62f6c7 fix: build without tree-sitter 1226f473 add JuliaFormatter as julia formatter bc723309 add rustfmt as rust formatter e719a3b6 Merge branch 'master' into zig-0.14 65e5e6cc Merge branch 'master' into zig-0.14 231c5c1f Merge branch 'master' into zig-0.14 2a345ab7 Merge branch 'master' into zig-0.14 51e33d7b Merge pull request #3 from alichraghi/master 0b566414 update to latest zig git-subtree-dir: src/syntax git-subtree-split: d5c1cd2a328ec75fd9b0feddbc9eb84b5f590939 --- build.zig | 7 ++++++- build.zig.zon | 12 +++++++----- src/file_type.zig | 4 ++-- src/file_types.zig | 45 ++++++++++++++++++++++++++++++++++++++------- src/treez_dummy.zig | 33 +++++++++++++++++++++++++++++++-- 5 files changed, 84 insertions(+), 17 deletions(-) diff --git a/build.zig b/build.zig index 81ce4d5..f9a3105 100644 --- a/build.zig +++ b/build.zig @@ -9,7 +9,7 @@ pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); - const tree_sitter_dep = b.dependency("tree-sitter", .{ + const tree_sitter_dep = b.dependency("tree_sitter", .{ .target = target, .optimize = optimize, }); @@ -19,6 +19,7 @@ pub fn build(b: *std.Build) void { .{ .name = "treez", .module = tree_sitter_dep.module("treez") }, ts_queryfile(b, tree_sitter_dep, "queries/cmake/highlights.scm"), ts_queryfile(b, tree_sitter_dep, "tree-sitter-agda/queries/highlights.scm"), + ts_queryfile(b, tree_sitter_dep, "tree-sitter-astro/queries/highlights.scm"), ts_queryfile(b, tree_sitter_dep, "tree-sitter-bash/queries/highlights.scm"), ts_queryfile(b, tree_sitter_dep, "tree-sitter-c-sharp/queries/highlights.scm"), ts_queryfile(b, tree_sitter_dep, "tree-sitter-c/queries/highlights.scm"), @@ -65,6 +66,7 @@ pub fn build(b: *std.Build) void { ts_queryfile(b, tree_sitter_dep, "tree-sitter-scala/queries/highlights.scm"), ts_queryfile(b, tree_sitter_dep, "tree-sitter-scheme/queries/highlights.scm"), ts_queryfile(b, tree_sitter_dep, "tree-sitter-superhtml/tree-sitter-superhtml/queries/highlights.scm"), + ts_queryfile(b, tree_sitter_dep, "tree-sitter-sql/queries/highlights.scm"), ts_queryfile(b, tree_sitter_dep, "tree-sitter-swift/queries/highlights.scm"), ts_queryfile(b, tree_sitter_dep, "tree-sitter-toml/queries/highlights.scm"), ts_queryfile(b, tree_sitter_dep, "tree-sitter-typescript/queries/highlights.scm"), @@ -76,8 +78,10 @@ pub fn build(b: *std.Build) void { ts_queryfile(b, tree_sitter_dep, "tree-sitter-zig/queries/highlights.scm"), ts_queryfile(b, tree_sitter_dep, "tree-sitter-ziggy/tree-sitter-ziggy/queries/highlights.scm"), ts_queryfile(b, tree_sitter_dep, "tree-sitter-ziggy/tree-sitter-ziggy-schema/queries/highlights.scm"), + ts_queryfile(b, tree_sitter_dep, "nvim-treesitter/queries/verilog/highlights.scm"), ts_queryfile(b, tree_sitter_dep, "queries/cmake/injections.scm"), + ts_queryfile(b, tree_sitter_dep, "tree-sitter-astro/queries/injections.scm"), ts_queryfile(b, tree_sitter_dep, "tree-sitter-cpp/queries/injections.scm"), ts_queryfile(b, tree_sitter_dep, "tree-sitter-elixir/queries/injections.scm"), ts_queryfile(b, tree_sitter_dep, "tree-sitter-gitcommit/queries/injections.scm"), @@ -102,6 +106,7 @@ pub fn build(b: *std.Build) void { ts_queryfile(b, tree_sitter_dep, "tree-sitter-typst/queries/typst/injections.scm"), ts_queryfile(b, tree_sitter_dep, "tree-sitter-vim/queries/vim/injections.scm"), ts_queryfile(b, tree_sitter_dep, "tree-sitter-zig/queries/injections.scm"), + ts_queryfile(b, tree_sitter_dep, "nvim-treesitter/queries/verilog/injections.scm"), } else &.{ .{ .name = "build_options", .module = options_mod }, }; diff --git a/build.zig.zon b/build.zig.zon index d5171f5..eb592e2 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,11 +1,13 @@ .{ - .name = "flow-syntax", - .version = "0.0.1", + .name = .flow_syntax, + .version = "0.1.0", + .fingerprint = 0x3ba2584ea1cec85f, + .minimum_zig_version = "0.14.0-dev.3451+d8d2aa9af", .dependencies = .{ - .@"tree-sitter" = .{ - .url = "https://github.com/neurocyte/tree-sitter/releases/download/master-aea6072c6178d5cd0c97fff33e130f632f355bc2/source.tar.gz", - .hash = "12204c99c6093230023380068f386f7eb32ab83df9a8eb8b586ffe5aa44afa34ff0e", + .tree_sitter = .{ + .url = "https://github.com/neurocyte/tree-sitter/releases/download/master-86dd4d2536f2748c5b4ea0e1e70678039a569aac/source.tar.gz", + .hash = "N-V-__8AACablCbp-6lsRoKDEp6Xd2dHLe4AsW81blkSQxzs", }, }, .paths = .{ diff --git a/src/file_type.zig b/src/file_type.zig index dfecb1b..d6c4445 100644 --- a/src/file_type.zig +++ b/src/file_type.zig @@ -88,7 +88,7 @@ fn ft_func_name(comptime lang: []const u8) []const u8 { const LangFn = *const fn () callconv(.C) ?*const treez.Language; -const FirstLineMatch = struct { +pub const FirstLineMatch = struct { prefix: ?[]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 { comptime switch (@typeInfo(Namespace)) { - .Struct => |info| { + .@"struct" => |info| { var count = 0; for (info.decls) |_| { // @compileLog(decl.name, @TypeOf(@field(Namespace, decl.name))); diff --git a/src/file_types.zig b/src/file_types.zig index c0b47c3..870c6b7 100644 --- a/src/file_types.zig +++ b/src/file_types.zig @@ -1,16 +1,27 @@ +const file_type = @import("file_type.zig"); +const FirstLineMatch = file_type.FirstLineMatch; + pub const agda = .{ .description = "Agda", .extensions = .{"agda"}, .comment = "--", }; +pub const astro = .{ + .description = "Astro", + .icon = "", + .extensions = .{"astro"}, + .comment = "//", + .language_server = .{ "astro-ls", "--stdio" }, +}; + pub const bash = .{ .description = "Bash", .color = 0x3e474a, .icon = "󱆃", .extensions = .{ "sh", "bash", ".profile" }, .comment = "#", - .first_line_matches = .{ .prefix = "#!", .content = "sh" }, + .first_line_matches = FirstLineMatch{ .prefix = "#!", .content = "sh" }, .formatter = .{ "shfmt", "--indent", "4" }, .language_server = .{ "bash-language-server", "start" }, }; @@ -37,7 +48,7 @@ pub const conf = .{ .description = "Config", .color = 0x000000, .icon = "", - .extensions = .{ "conf", "config", ".gitconfig" }, + .extensions = .{ "conf", "config", ".gitconfig", "gui_config" }, .highlights = fish.highlights, .comment = "#", .parser = fish.parser, @@ -80,7 +91,7 @@ pub const css = .{ pub const diff = .{ .description = "Diff", - .extensions = .{ "diff", "patch" }, + .extensions = .{ "diff", "patch", "rej" }, .comment = "#", }; @@ -227,6 +238,7 @@ pub const julia = .{ .extensions = .{"jl"}, .comment = "#", .language_server = .{ "julia", "-e", "using LanguageServer; runserver()" }, + .formatter = .{ "julia", "-e", "using JuliaFormatter; print(format_text(read(stdin, String)))" }, }; pub const kdl = .{ @@ -244,7 +256,7 @@ pub const lua = .{ .extensions = .{"lua"}, .comment = "--", .injections = "tree-sitter-lua/queries/injections.scm", - .first_line_matches = .{ .prefix = "--", .content = "lua" }, + .first_line_matches = FirstLineMatch{ .prefix = "--", .content = "lua" }, .language_server = .{"lua-lsp"}, }; @@ -254,7 +266,7 @@ pub const mail = .{ .extensions = .{ "eml", "mbox" }, .comment = ">", .highlights = "tree-sitter-mail/queries/mail/highlights.scm", - .first_line_matches = .{ .prefix = "From" }, + .first_line_matches = FirstLineMatch{ .prefix = "From" }, }; pub const make = .{ @@ -380,6 +392,7 @@ pub const php = .{ .extensions = .{"php"}, .comment = "//", .injections = "tree-sitter-php/queries/injections.scm", + .language_server = .{ "intelephense", "--stdio" }, }; pub const purescript = .{ @@ -397,7 +410,7 @@ pub const python = .{ .icon = "󰌠", .extensions = .{ "py", "pyi" }, .comment = "#", - .first_line_matches = .{ .prefix = "#!", .content = "python" }, + .first_line_matches = FirstLineMatch{ .prefix = "#!", .content = "python" }, .language_server = .{"pylsp"}, }; @@ -424,6 +437,7 @@ pub const rust = .{ .comment = "//", .injections = "tree-sitter-rust/queries/injections.scm", .language_server = .{"rust-analyzer"}, + .formatter = .{"rustfmt"}, }; pub const scheme = .{ @@ -432,6 +446,13 @@ pub const scheme = .{ .comment = ";", }; +pub const sql = .{ + .description = "SQL", + .icon = "󰆼", + .extensions = .{"sql"}, + .comment = "--", +}; + pub const @"ssh-config" = .{ .description = "SSH config", .extensions = .{".ssh/config"}, @@ -448,6 +469,16 @@ pub const swift = .{ .formatter = .{"swift-format"}, }; +pub const verilog = .{ + .description = "SystemVerilog", + .extensions = .{ "sv", "svh" }, + .comment = "//", + .highlights = "nvim-treesitter/queries/verilog/highlights.scm", + .injections = "nvim-treesitter/queries/verilog/injections.scm", + .language_server = .{"verible-verilog-ls"}, + .formatter = .{ "verible-verilog-format", "-" }, +}; + pub const toml = .{ .description = "TOML", .extensions = .{ "toml", "ini" }, @@ -492,7 +523,7 @@ pub const xml = .{ .extensions = .{"xml"}, .comment = "