feat: add {{blame_commit}} variable for expansion
This commit is contained in:
parent
414668c4cd
commit
0df97f5ad5
1 changed files with 13 additions and 0 deletions
|
|
@ -9,6 +9,7 @@
|
||||||
/// {{selections*}} - All current selections expanded to multiple quoted arguments
|
/// {{selections*}} - All current selections expanded to multiple quoted arguments
|
||||||
/// {{indent_mode}} - The current indent mode ("tabs" or "spaces")
|
/// {{indent_mode}} - The current indent mode ("tabs" or "spaces")
|
||||||
/// {{indent_size}} - The current indent size (in columns)
|
/// {{indent_size}} - The current indent size (in columns)
|
||||||
|
/// {{blame_commit}} - The blame commit ID at the line number of the primary cursor
|
||||||
pub fn expand(allocator: Allocator, arg: []const u8) Error![]const u8 {
|
pub fn expand(allocator: Allocator, arg: []const u8) Error![]const u8 {
|
||||||
var result: std.Io.Writer.Allocating = .init(allocator);
|
var result: std.Io.Writer.Allocating = .init(allocator);
|
||||||
defer result.deinit();
|
defer result.deinit();
|
||||||
|
|
@ -160,6 +161,18 @@ const functions = struct {
|
||||||
try stream.writer.print("{d}", .{ed.indent_size});
|
try stream.writer.print("{d}", .{ed.indent_size});
|
||||||
return stream.toOwnedSlice();
|
return stream.toOwnedSlice();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// {{blame_commit}} - The blame commit ID at the line number of the primary cursor
|
||||||
|
pub fn blame_commit(allocator: Allocator) Error![]const u8 {
|
||||||
|
const mv = tui.mainview() orelse return &.{};
|
||||||
|
const ed = mv.get_active_editor() orelse return &.{};
|
||||||
|
const row = ed.get_primary().cursor.row;
|
||||||
|
const commit = ed.get_vcs_blame(row);
|
||||||
|
const id = if (commit) |c| c.id else "";
|
||||||
|
var stream: std.Io.Writer.Allocating = .init(allocator);
|
||||||
|
try stream.writer.print("{s}", .{id});
|
||||||
|
return stream.toOwnedSlice();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fn get_functions() []struct { []const u8, Function } {
|
fn get_functions() []struct { []const u8, Function } {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue