From bc723309678111c204e7d36a3133f2bea214f74b Mon Sep 17 00:00:00 2001 From: edwloef Date: Sun, 15 Dec 2024 12:03:09 +0100 Subject: [PATCH 01/10] add rustfmt as rust formatter --- src/file_types.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/src/file_types.zig b/src/file_types.zig index c0b47c3..506af5a 100644 --- a/src/file_types.zig +++ b/src/file_types.zig @@ -424,6 +424,7 @@ pub const rust = .{ .comment = "//", .injections = "tree-sitter-rust/queries/injections.scm", .language_server = .{"rust-analyzer"}, + .formatter = .{"rustfmt"}, }; pub const scheme = .{ From 1226f47301450ea385f3e9446de9e7a1b3ce74bd Mon Sep 17 00:00:00 2001 From: edwloef Date: Sun, 15 Dec 2024 14:10:24 +0100 Subject: [PATCH 02/10] add JuliaFormatter as julia formatter --- src/file_types.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/src/file_types.zig b/src/file_types.zig index 506af5a..fc11e81 100644 --- a/src/file_types.zig +++ b/src/file_types.zig @@ -227,6 +227,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 = .{ From ec62f6c7f45e5f04f0d6e7525b0390a148ea3ec9 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Fri, 20 Dec 2024 12:17:58 +0100 Subject: [PATCH 03/10] fix: build without tree-sitter --- src/treez_dummy.zig | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/treez_dummy.zig b/src/treez_dummy.zig index ccb96de..b73b1f4 100644 --- a/src/treez_dummy.zig +++ b/src/treez_dummy.zig @@ -95,10 +95,39 @@ pub const Node = struct { return ""; } pub fn freeSExpressionString(_: []const u8) void {} - pub fn getParent(_: *const @This()) *Node { - return &dummy; + pub fn getParent(_: *const @This()) Node { + return dummy; + } + pub fn getChild(_: *const @This(), _: usize) Node { + return dummy; + } + pub fn getChildCount(_: *const @This()) usize { + return 0; + } + pub fn getNamedChild(_: *const @This(), _: usize) Node { + return dummy; + } + pub fn getNamedChildCount(_: *const @This()) usize { + return 0; } pub fn isNull(_: *const @This()) bool { return true; } + pub const externs = struct { + pub fn ts_node_next_sibling(_: Node) Node { + return Node.dummy; + } + pub fn ts_node_prev_sibling(_: Node) Node { + return Node.dummy; + } + pub fn ts_node_next_named_sibling(_: Node) Node { + return Node.dummy; + } + pub fn ts_node_prev_named_sibling(_: Node) Node { + return Node.dummy; + } + pub fn ts_node_descendant_for_point_range(_: *const Node, _: Point, _: Point) Node { + return Node.dummy; + } + }; }; From da812e05d4cbe44056bf2bb30e9e88c0ead99530 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Wed, 8 Jan 2025 22:25:04 +0100 Subject: [PATCH 04/10] fix(config): add gui_config to file_types --- src/file_types.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/file_types.zig b/src/file_types.zig index fc11e81..d3aacfa 100644 --- a/src/file_types.zig +++ b/src/file_types.zig @@ -37,7 +37,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, From 942053ff0a771c77bbd372adb87a1afe6ec6c11a Mon Sep 17 00:00:00 2001 From: edwloef Date: Sat, 18 Jan 2025 11:34:41 +0100 Subject: [PATCH 05/10] add systemverilog lsp and formatter --- build.zig | 2 ++ build.zig.zon | 4 ++-- src/file_types.zig | 10 ++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/build.zig b/build.zig index 81ce4d5..b157459 100644 --- a/build.zig +++ b/build.zig @@ -76,6 +76,7 @@ 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-cpp/queries/injections.scm"), @@ -102,6 +103,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..1882f51 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -4,8 +4,8 @@ .dependencies = .{ .@"tree-sitter" = .{ - .url = "https://github.com/neurocyte/tree-sitter/releases/download/master-aea6072c6178d5cd0c97fff33e130f632f355bc2/source.tar.gz", - .hash = "12204c99c6093230023380068f386f7eb32ab83df9a8eb8b586ffe5aa44afa34ff0e", + .url = "https://github.com/neurocyte/tree-sitter/releases/download/master-f7a38f045f20164d333e355ac1a9d31d8352502b/source.tar.gz", + .hash = "122097835c8367b58cb57f55d6d60d12d93be0926e68544a1de996e883b53b82df44", }, }, .paths = .{ diff --git a/src/file_types.zig b/src/file_types.zig index d3aacfa..0541cbc 100644 --- a/src/file_types.zig +++ b/src/file_types.zig @@ -450,6 +450,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" }, From 01558741e40fc69f75328a3df68f3cecffa00fd7 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Sat, 25 Jan 2025 18:19:33 +0100 Subject: [PATCH 06/10] feat: add sql file type support --- build.zig | 1 + build.zig.zon | 4 ++-- src/file_types.zig | 7 +++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/build.zig b/build.zig index b157459..c24840e 100644 --- a/build.zig +++ b/build.zig @@ -65,6 +65,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"), diff --git a/build.zig.zon b/build.zig.zon index 1882f51..46e29c4 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -4,8 +4,8 @@ .dependencies = .{ .@"tree-sitter" = .{ - .url = "https://github.com/neurocyte/tree-sitter/releases/download/master-f7a38f045f20164d333e355ac1a9d31d8352502b/source.tar.gz", - .hash = "122097835c8367b58cb57f55d6d60d12d93be0926e68544a1de996e883b53b82df44", + .url = "https://github.com/neurocyte/tree-sitter/releases/download/master-69775ce3ba8a5e331bba9feb760d1ba31394eea7/source.tar.gz", + .hash = "1220f9702ca6257f5464b31e576b1e92b0f441bf0e61733c4a2fbf95b7c0c55a3e22", }, }, .paths = .{ diff --git a/src/file_types.zig b/src/file_types.zig index 0541cbc..a581f5b 100644 --- a/src/file_types.zig +++ b/src/file_types.zig @@ -434,6 +434,13 @@ pub const scheme = .{ .comment = ";", }; +pub const sql = .{ + .description = "SQL", + .icon = "󰆼", + .extensions = .{ "sql" }, + .comment = "--", +}; + pub const @"ssh-config" = .{ .description = "SSH config", .extensions = .{".ssh/config"}, From f81314c11e22fff43e8357ae91d8b822ccb7ddcd Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Tue, 4 Feb 2025 17:09:46 +0100 Subject: [PATCH 07/10] feat: add .ref to diff file type extensions --- src/file_types.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/file_types.zig b/src/file_types.zig index a581f5b..a634930 100644 --- a/src/file_types.zig +++ b/src/file_types.zig @@ -80,7 +80,7 @@ pub const css = .{ pub const diff = .{ .description = "Diff", - .extensions = .{ "diff", "patch" }, + .extensions = .{ "diff", "patch", "rej" }, .comment = "#", }; From 670aa9aedefcd2832aa85a6ea0c2f5e2d6e0fdbe Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Tue, 4 Feb 2025 22:59:18 +0100 Subject: [PATCH 08/10] build: update to zig 0.14.0-dev.3039 --- src/file_type.zig | 4 ++-- src/file_types.zig | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) 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 a634930..c5f0895 100644 --- a/src/file_types.zig +++ b/src/file_types.zig @@ -1,3 +1,6 @@ +const file_type = @import("file_type.zig"); +const FirstLineMatch = file_type.FirstLineMatch; + pub const agda = .{ .description = "Agda", .extensions = .{"agda"}, @@ -10,7 +13,7 @@ pub const bash = .{ .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" }, }; @@ -245,7 +248,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"}, }; @@ -255,7 +258,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 = .{ @@ -398,7 +401,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"}, }; @@ -511,7 +514,7 @@ pub const xml = .{ .extensions = .{"xml"}, .comment = "