Improve git gutter
This commit is contained in:
parent
43b72770ec
commit
a56c39d69b
|
@ -97,25 +97,55 @@ Available commands:\n add\n rm\n blame\n commit\n checkout\n diff\n hide-
|
||||||
}
|
}
|
||||||
|
|
||||||
update_diff() {
|
update_diff() {
|
||||||
git diff -U0 $kak_buffile | awk '
|
git --no-pager diff -U0 $kak_buffile | perl -e '
|
||||||
BEGIN {
|
$flags = $ENV{"kak_timestamp"};
|
||||||
line=0
|
foreach $line (<STDIN>) {
|
||||||
flags=ENVIRON["kak_timestamp"]
|
if ($line =~ /@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))?/) {
|
||||||
|
$from_line = $1;
|
||||||
|
$from_count = ($2 eq "" ? 1 : $2);
|
||||||
|
$to_line = $3;
|
||||||
|
$to_count = ($4 eq "" ? 1 : $4);
|
||||||
|
|
||||||
|
if ($from_count == 0 and $to_count > 0) {
|
||||||
|
for $i (0..$to_count - 1) {
|
||||||
|
$line = $to_line + $i;
|
||||||
|
$flags .= ":$line|\{green\}+";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif ($from_count > 0 and $to_count == 0) {
|
||||||
|
if ($to_line == 0) {
|
||||||
|
$flags .= ":1|\{red\}‾";
|
||||||
|
} else {
|
||||||
|
$flags .= ":$to_line|\{red\}_";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif ($from_count > 0 and $from_count == $to_count) {
|
||||||
|
for $i (0..$to_count - 1) {
|
||||||
|
$line = $to_line + $i;
|
||||||
|
$flags .= ":$line|\{blue\}~";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif ($from_count > 0 and $from_count < $to_count) {
|
||||||
|
for $i (0..$from_count - 1) {
|
||||||
|
$line = $to_line + $i;
|
||||||
|
$flags .= ":$line|\{blue\}~";
|
||||||
|
}
|
||||||
|
for $i ($from_count..$to_count - 1) {
|
||||||
|
$line = $to_line + $i;
|
||||||
|
$flags .= ":$line|\{green\}+";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif ($to_count > 0 and $from_count > $to_count) {
|
||||||
|
for $i (0..$to_count - 2) {
|
||||||
|
$line = $to_line + $i;
|
||||||
|
$flags .= ":$line|\{blue\}~";
|
||||||
|
}
|
||||||
|
$last = $to_line + $to_count - 1;
|
||||||
|
$flags .= ":$last|\{blue\}~_";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/^---.*/ {}
|
print "set-option buffer git_diff_flags $flags"
|
||||||
/^@@ -[0-9]+(,[0-9]+)? \+[0-9]+(,[0-9]+)? @@.*/ {
|
|
||||||
if ((x=index($3, ",")) > 0) {
|
|
||||||
line=substr($3, 2, x-2)
|
|
||||||
} else {
|
|
||||||
line=substr($3, 2)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/^\+/ {
|
|
||||||
flags=flags ":" line "|{green}+"
|
|
||||||
line++
|
|
||||||
}
|
|
||||||
/^\-/ { flags=flags ":" line "|{red}-" }
|
|
||||||
END { print "set-option buffer git_diff_flags ", flags }
|
|
||||||
'
|
'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user