Skip to content

Commit

Permalink
add snippets for format/panic/log
Browse files Browse the repository at this point in the history
  • Loading branch information
xdBronch committed Sep 10, 2024
1 parent dd78968 commit f3b5ee0
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/snippets.zig
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,22 @@ pub const top_level_decl_data = [_]Snipped{
.{ .label = "union tagged", .kind = .Snippet, .text = "const $1 = union(${2:enum}) {$0};" },
.{ .label = "test", .kind = .Snippet, .text = "test \"$1\" {$0}" },
.{ .label = "main", .kind = .Snippet, .text = "pub fn main() !void {$0}" },
.{ .label = "std_options", .kind = .Snippet, .text = "pub const std_options: std.Options = .{${0}};" },
.{ .label = "std_options", .kind = .Snippet, .text = "pub const std_options: std.Options = .{$0};" },
.{ .label = "logFn", .kind = .Snippet, .text =
\\fn logFn(
\\ comptime level: std.log.Level,
\\ comptime scope: @Type(.enum_literal),
\\ comptime fmt: []const u8,
\\ args: anytype,
\\) void {$0}
},
.{ .label = "panic", .kind = .Snippet, .text =
\\pub fn panic(
\\ msg: []const u8,
\\ trace: ?*std.builtin.StackTrace,
\\ ret_addr: ?usize,
\\) noreturn {$0}
},
};

pub const generic = [_]Snipped{
Expand Down Expand Up @@ -85,6 +100,14 @@ pub const generic = [_]Snipped{
.{ .label = "log warn", .kind = .Snippet, .text = "std.log.warn(\"$1\", .{$0});" },
.{ .label = "log info", .kind = .Snippet, .text = "std.log.info(\"$1\", .{$0});" },
.{ .label = "log debug", .kind = .Snippet, .text = "std.log.debug(\"$1\", .{$0});" },
.{ .label = "format", .kind = .Snippet, .text =
\\pub fn format(
\\ self: ${1:@This()},
\\ comptime fmt: []const u8,
\\ options: std.fmt.FormatOptions,
\\ writer: anytype,
\\) !void {$0}
},

// types
.{ .label = "anyerror", .kind = .Keyword },
Expand Down

0 comments on commit f3b5ee0

Please sign in to comment.