coc-git 2.4.9 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Readme.md +0 -2
- package/lib/index.js +360 -223
- package/package.json +14 -9
package/lib/index.js
CHANGED
|
@@ -670,17 +670,17 @@ var require_zalgo = __commonJS((exports2, module2) => {
|
|
|
670
670
|
|
|
671
671
|
// node_modules/colors/lib/maps/america.js
|
|
672
672
|
var require_america = __commonJS((exports2, module2) => {
|
|
673
|
-
module2["exports"] = function(
|
|
673
|
+
module2["exports"] = function(colors5) {
|
|
674
674
|
return function(letter, i, exploded) {
|
|
675
675
|
if (letter === " ")
|
|
676
676
|
return letter;
|
|
677
677
|
switch (i % 3) {
|
|
678
678
|
case 0:
|
|
679
|
-
return
|
|
679
|
+
return colors5.red(letter);
|
|
680
680
|
case 1:
|
|
681
|
-
return
|
|
681
|
+
return colors5.white(letter);
|
|
682
682
|
case 2:
|
|
683
|
-
return
|
|
683
|
+
return colors5.blue(letter);
|
|
684
684
|
}
|
|
685
685
|
};
|
|
686
686
|
};
|
|
@@ -688,22 +688,22 @@ var require_america = __commonJS((exports2, module2) => {
|
|
|
688
688
|
|
|
689
689
|
// node_modules/colors/lib/maps/zebra.js
|
|
690
690
|
var require_zebra = __commonJS((exports2, module2) => {
|
|
691
|
-
module2["exports"] = function(
|
|
691
|
+
module2["exports"] = function(colors5) {
|
|
692
692
|
return function(letter, i, exploded) {
|
|
693
|
-
return i % 2 === 0 ? letter :
|
|
693
|
+
return i % 2 === 0 ? letter : colors5.inverse(letter);
|
|
694
694
|
};
|
|
695
695
|
};
|
|
696
696
|
});
|
|
697
697
|
|
|
698
698
|
// node_modules/colors/lib/maps/rainbow.js
|
|
699
699
|
var require_rainbow = __commonJS((exports2, module2) => {
|
|
700
|
-
module2["exports"] = function(
|
|
700
|
+
module2["exports"] = function(colors5) {
|
|
701
701
|
var rainbowColors = ["red", "yellow", "green", "blue", "magenta"];
|
|
702
702
|
return function(letter, i, exploded) {
|
|
703
703
|
if (letter === " ") {
|
|
704
704
|
return letter;
|
|
705
705
|
} else {
|
|
706
|
-
return
|
|
706
|
+
return colors5[rainbowColors[i++ % rainbowColors.length]](letter);
|
|
707
707
|
}
|
|
708
708
|
};
|
|
709
709
|
};
|
|
@@ -711,7 +711,7 @@ var require_rainbow = __commonJS((exports2, module2) => {
|
|
|
711
711
|
|
|
712
712
|
// node_modules/colors/lib/maps/random.js
|
|
713
713
|
var require_random = __commonJS((exports2, module2) => {
|
|
714
|
-
module2["exports"] = function(
|
|
714
|
+
module2["exports"] = function(colors5) {
|
|
715
715
|
var available = [
|
|
716
716
|
"underline",
|
|
717
717
|
"inverse",
|
|
@@ -732,40 +732,40 @@ var require_random = __commonJS((exports2, module2) => {
|
|
|
732
732
|
"brightMagenta"
|
|
733
733
|
];
|
|
734
734
|
return function(letter, i, exploded) {
|
|
735
|
-
return letter === " " ? letter :
|
|
735
|
+
return letter === " " ? letter : colors5[available[Math.round(Math.random() * (available.length - 2))]](letter);
|
|
736
736
|
};
|
|
737
737
|
};
|
|
738
738
|
});
|
|
739
739
|
|
|
740
740
|
// node_modules/colors/lib/colors.js
|
|
741
741
|
var require_colors = __commonJS((exports2, module2) => {
|
|
742
|
-
var
|
|
743
|
-
module2["exports"] =
|
|
744
|
-
|
|
742
|
+
var colors5 = {};
|
|
743
|
+
module2["exports"] = colors5;
|
|
744
|
+
colors5.themes = {};
|
|
745
745
|
var util2 = require("util");
|
|
746
|
-
var ansiStyles =
|
|
746
|
+
var ansiStyles = colors5.styles = require_styles();
|
|
747
747
|
var defineProps = Object.defineProperties;
|
|
748
748
|
var newLineRegex = new RegExp(/[\r\n]+/g);
|
|
749
|
-
|
|
750
|
-
if (typeof
|
|
751
|
-
|
|
749
|
+
colors5.supportsColor = require_supports_colors().supportsColor;
|
|
750
|
+
if (typeof colors5.enabled === "undefined") {
|
|
751
|
+
colors5.enabled = colors5.supportsColor() !== false;
|
|
752
752
|
}
|
|
753
|
-
|
|
754
|
-
|
|
753
|
+
colors5.enable = function() {
|
|
754
|
+
colors5.enabled = true;
|
|
755
755
|
};
|
|
756
|
-
|
|
757
|
-
|
|
756
|
+
colors5.disable = function() {
|
|
757
|
+
colors5.enabled = false;
|
|
758
758
|
};
|
|
759
|
-
|
|
759
|
+
colors5.stripColors = colors5.strip = function(str) {
|
|
760
760
|
return ("" + str).replace(/\x1B\[\d+m/g, "");
|
|
761
761
|
};
|
|
762
|
-
var stylize =
|
|
763
|
-
if (!
|
|
762
|
+
var stylize = colors5.stylize = function stylize2(str, style) {
|
|
763
|
+
if (!colors5.enabled) {
|
|
764
764
|
return str + "";
|
|
765
765
|
}
|
|
766
766
|
var styleMap = ansiStyles[style];
|
|
767
|
-
if (!styleMap && style in
|
|
768
|
-
return
|
|
767
|
+
if (!styleMap && style in colors5) {
|
|
768
|
+
return colors5[style](str);
|
|
769
769
|
}
|
|
770
770
|
return styleMap.open + str + styleMap.close;
|
|
771
771
|
};
|
|
@@ -797,7 +797,7 @@ var require_colors = __commonJS((exports2, module2) => {
|
|
|
797
797
|
});
|
|
798
798
|
return ret;
|
|
799
799
|
}();
|
|
800
|
-
var proto = defineProps(function
|
|
800
|
+
var proto = defineProps(function colors6() {
|
|
801
801
|
}, styles);
|
|
802
802
|
function applyStyle() {
|
|
803
803
|
var args = Array.prototype.slice.call(arguments);
|
|
@@ -808,7 +808,7 @@ var require_colors = __commonJS((exports2, module2) => {
|
|
|
808
808
|
return util2.inspect(arg);
|
|
809
809
|
}
|
|
810
810
|
}).join(" ");
|
|
811
|
-
if (!
|
|
811
|
+
if (!colors5.enabled || !str) {
|
|
812
812
|
return str;
|
|
813
813
|
}
|
|
814
814
|
var newLinesPresent = str.indexOf("\n") != -1;
|
|
@@ -825,22 +825,22 @@ var require_colors = __commonJS((exports2, module2) => {
|
|
|
825
825
|
}
|
|
826
826
|
return str;
|
|
827
827
|
}
|
|
828
|
-
|
|
828
|
+
colors5.setTheme = function(theme) {
|
|
829
829
|
if (typeof theme === "string") {
|
|
830
830
|
console.log("colors.setTheme now only accepts an object, not a string. If you are trying to set a theme from a file, it is now your (the caller's) responsibility to require the file. The old syntax looked like colors.setTheme(__dirname + '/../themes/generic-logging.js'); The new syntax looks like colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));");
|
|
831
831
|
return;
|
|
832
832
|
}
|
|
833
833
|
for (var style in theme) {
|
|
834
834
|
(function(style2) {
|
|
835
|
-
|
|
835
|
+
colors5[style2] = function(str) {
|
|
836
836
|
if (typeof theme[style2] === "object") {
|
|
837
837
|
var out = str;
|
|
838
838
|
for (var i in theme[style2]) {
|
|
839
|
-
out =
|
|
839
|
+
out = colors5[theme[style2][i]](out);
|
|
840
840
|
}
|
|
841
841
|
return out;
|
|
842
842
|
}
|
|
843
|
-
return
|
|
843
|
+
return colors5[theme[style2]](str);
|
|
844
844
|
};
|
|
845
845
|
})(style);
|
|
846
846
|
}
|
|
@@ -861,27 +861,27 @@ var require_colors = __commonJS((exports2, module2) => {
|
|
|
861
861
|
exploded = exploded.map(map2);
|
|
862
862
|
return exploded.join("");
|
|
863
863
|
};
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
for (var map in
|
|
864
|
+
colors5.trap = require_trap();
|
|
865
|
+
colors5.zalgo = require_zalgo();
|
|
866
|
+
colors5.maps = {};
|
|
867
|
+
colors5.maps.america = require_america()(colors5);
|
|
868
|
+
colors5.maps.zebra = require_zebra()(colors5);
|
|
869
|
+
colors5.maps.rainbow = require_rainbow()(colors5);
|
|
870
|
+
colors5.maps.random = require_random()(colors5);
|
|
871
|
+
for (var map in colors5.maps) {
|
|
872
872
|
(function(map2) {
|
|
873
|
-
|
|
874
|
-
return sequencer(
|
|
873
|
+
colors5[map2] = function(str) {
|
|
874
|
+
return sequencer(colors5.maps[map2], str);
|
|
875
875
|
};
|
|
876
876
|
})(map);
|
|
877
877
|
}
|
|
878
|
-
defineProps(
|
|
878
|
+
defineProps(colors5, init());
|
|
879
879
|
});
|
|
880
880
|
|
|
881
881
|
// node_modules/colors/safe.js
|
|
882
882
|
var require_safe = __commonJS((exports2, module2) => {
|
|
883
|
-
var
|
|
884
|
-
module2["exports"] =
|
|
883
|
+
var colors5 = require_colors();
|
|
884
|
+
module2["exports"] = colors5;
|
|
885
885
|
});
|
|
886
886
|
|
|
887
887
|
// node_modules/debounce/index.js
|
|
@@ -4508,7 +4508,7 @@ var require_lib = __commonJS((exports2, module2) => {
|
|
|
4508
4508
|
__export(exports, {
|
|
4509
4509
|
activate: () => activate
|
|
4510
4510
|
});
|
|
4511
|
-
var
|
|
4511
|
+
var import_coc15 = __toModule(require("coc.nvim"));
|
|
4512
4512
|
|
|
4513
4513
|
// src/constants.ts
|
|
4514
4514
|
var DEFAULT_TYPES = [
|
|
@@ -4924,20 +4924,19 @@ var Bcommits = class extends import_coc2.BasicList {
|
|
|
4924
4924
|
}, {tabPersist: true});
|
|
4925
4925
|
this.addAction("view", async (item, context) => {
|
|
4926
4926
|
let {commit, root, file} = item.data;
|
|
4927
|
-
let {window:
|
|
4927
|
+
let {window: window10} = context;
|
|
4928
4928
|
let content = await import_coc2.runCommand(`git show ${commit}:${shellescape(file)}`, {cwd: root});
|
|
4929
4929
|
let lines = content.replace(/\n$/, "").split("\n");
|
|
4930
4930
|
nvim.pauseNotification();
|
|
4931
|
-
nvim.call("win_gotoid", [
|
|
4932
|
-
nvim.command(`exe "
|
|
4931
|
+
nvim.call("win_gotoid", [window10.id], true);
|
|
4932
|
+
nvim.command(`exe "tabe ".fnameescape('(${commit}) ${file}')`, true);
|
|
4933
4933
|
nvim.call("append", [0, lines], true);
|
|
4934
4934
|
nvim.command("normal! Gdd", true);
|
|
4935
4935
|
nvim.command(`exe 1`, true);
|
|
4936
4936
|
nvim.command("setl buftype=nofile nomodifiable bufhidden=wipe nobuflisted", true);
|
|
4937
4937
|
nvim.command("filetype detect", true);
|
|
4938
|
-
nvim.call("win_gotoid", [listWindow.id], true);
|
|
4939
4938
|
await nvim.resumeNotification();
|
|
4940
|
-
}, {persist:
|
|
4939
|
+
}, {persist: false});
|
|
4941
4940
|
this.addAction("diff", async (item, context) => {
|
|
4942
4941
|
let buffer = await context.window.buffer;
|
|
4943
4942
|
let filetype = await buffer.getOption("filetype");
|
|
@@ -5250,7 +5249,7 @@ var Commits = class extends import_coc4.BasicList {
|
|
|
5250
5249
|
} else {
|
|
5251
5250
|
arg = `${list[1].data.commit} ${list[0].data.commit}`;
|
|
5252
5251
|
}
|
|
5253
|
-
let content = await runCommand(`git --no-pager diff ${arg}`, {cwd: list[0].data.root});
|
|
5252
|
+
let content = await runCommand(`git --no-pager diff --no-ext-diff ${arg}`, {cwd: list[0].data.root});
|
|
5254
5253
|
let lines = content.replace(/\n$/, "").split("\n");
|
|
5255
5254
|
nvim.pauseNotification();
|
|
5256
5255
|
nvim.command(`tabe [diff ${arg}]`, true);
|
|
@@ -5274,7 +5273,7 @@ var Commits = class extends import_coc4.BasicList {
|
|
|
5274
5273
|
} else {
|
|
5275
5274
|
arg = `${list[1].data.commit} ${list[0].data.commit}`;
|
|
5276
5275
|
}
|
|
5277
|
-
let content = await runCommand(`git --no-pager diff ${arg}`, {cwd: list[0].data.root});
|
|
5276
|
+
let content = await runCommand(`git --no-pager diff --no-ext-diff ${arg}`, {cwd: list[0].data.root});
|
|
5278
5277
|
let lines = content.replace(/\n$/, "").split("\n");
|
|
5279
5278
|
let winid = context.listWindow.id;
|
|
5280
5279
|
let mod = context.options.position == "tab" ? "below" : "above";
|
|
@@ -5370,7 +5369,7 @@ var Gfiles = class extends import_coc5.BasicList {
|
|
|
5370
5369
|
let {root, sha, filepath, branch} = item.data;
|
|
5371
5370
|
if (!sha)
|
|
5372
5371
|
return;
|
|
5373
|
-
let content = await runCommand(`git --no-pager diff ${branch} -- ${shellescape(filepath)}`, {cwd: root});
|
|
5372
|
+
let content = await runCommand(`git --no-pager diff --no-ext-diff ${branch} -- ${shellescape(filepath)}`, {cwd: root});
|
|
5374
5373
|
let lines = content.replace(/\n$/, "").split("\n");
|
|
5375
5374
|
await this.preview({
|
|
5376
5375
|
lines,
|
|
@@ -5502,7 +5501,7 @@ var GStatus = class extends import_coc6.BasicList {
|
|
|
5502
5501
|
}, context);
|
|
5503
5502
|
return;
|
|
5504
5503
|
}
|
|
5505
|
-
let args = ["--no-pager", "diff"];
|
|
5504
|
+
let args = ["--no-pager", "diff", "--no-ext-diff"];
|
|
5506
5505
|
if (index_symbol == "M" && tree_symbol != "M") {
|
|
5507
5506
|
args.push("--cached");
|
|
5508
5507
|
}
|
|
@@ -5530,6 +5529,9 @@ var GStatus = class extends import_coc6.BasicList {
|
|
|
5530
5529
|
throw new Error(`Can't resolve git root.`);
|
|
5531
5530
|
return;
|
|
5532
5531
|
}
|
|
5532
|
+
if (this.manager.gstatusSaveBeforeOpen) {
|
|
5533
|
+
await this.nvim.command(`wa`);
|
|
5534
|
+
}
|
|
5533
5535
|
let output = await runCommand(`git status --porcelain -uall ${context.args.join(" ")}`, {cwd: root});
|
|
5534
5536
|
output = output.replace(/\s+$/, "");
|
|
5535
5537
|
if (!output)
|
|
@@ -5558,19 +5560,90 @@ var GStatus = class extends import_coc6.BasicList {
|
|
|
5558
5560
|
};
|
|
5559
5561
|
var gstatus_default = GStatus;
|
|
5560
5562
|
|
|
5563
|
+
// src/lists/gchunks.ts
|
|
5564
|
+
var import_coc7 = __toModule(require("coc.nvim"));
|
|
5565
|
+
var import_safe3 = __toModule(require_safe());
|
|
5566
|
+
var GChunks = class extends import_coc7.BasicList {
|
|
5567
|
+
constructor(nvim, manager) {
|
|
5568
|
+
super(nvim);
|
|
5569
|
+
this.manager = manager;
|
|
5570
|
+
this.name = "gchunks";
|
|
5571
|
+
this.description = "Git changes of current buffer";
|
|
5572
|
+
this.defaultAction = "jump";
|
|
5573
|
+
this.actions.push({
|
|
5574
|
+
name: "jump",
|
|
5575
|
+
execute: (item) => {
|
|
5576
|
+
if (Array.isArray(item))
|
|
5577
|
+
return;
|
|
5578
|
+
import_coc7.window.moveTo({line: Math.max(item.data.line - 1, 0), character: 0});
|
|
5579
|
+
}
|
|
5580
|
+
});
|
|
5581
|
+
}
|
|
5582
|
+
async loadItems(context) {
|
|
5583
|
+
let buf = this.manager.getBuffer(context.buffer.id);
|
|
5584
|
+
if (!buf) {
|
|
5585
|
+
throw new Error(`Can't resolve git root.`);
|
|
5586
|
+
return;
|
|
5587
|
+
}
|
|
5588
|
+
let res = [];
|
|
5589
|
+
let diffs = buf.cachedDiffs;
|
|
5590
|
+
if (diffs && diffs.length > 0) {
|
|
5591
|
+
for (let diff of diffs) {
|
|
5592
|
+
let stagedSign = " ";
|
|
5593
|
+
res.push({
|
|
5594
|
+
label: `${stagedSign} Line:${diff.start} ${diff.lines[0]}`,
|
|
5595
|
+
sortText: `${diff.start}`,
|
|
5596
|
+
data: {
|
|
5597
|
+
line: diff.start
|
|
5598
|
+
}
|
|
5599
|
+
});
|
|
5600
|
+
}
|
|
5601
|
+
}
|
|
5602
|
+
try {
|
|
5603
|
+
let {relpath} = buf;
|
|
5604
|
+
let stagedDiff = await buf.repo.getStagedChunks(relpath);
|
|
5605
|
+
let chunks = Object.values(stagedDiff)[0];
|
|
5606
|
+
if (chunks.length > 0) {
|
|
5607
|
+
for (let diff of chunks) {
|
|
5608
|
+
let adjust = 0;
|
|
5609
|
+
let stagedSign = import_safe3.default.green("*");
|
|
5610
|
+
let line = diff.add.lnum;
|
|
5611
|
+
for (let diff2 of diffs) {
|
|
5612
|
+
if (diff2.end >= line) {
|
|
5613
|
+
break;
|
|
5614
|
+
}
|
|
5615
|
+
adjust += diff2.added.count;
|
|
5616
|
+
adjust -= diff2.removed.count;
|
|
5617
|
+
}
|
|
5618
|
+
line += adjust;
|
|
5619
|
+
res.push({
|
|
5620
|
+
label: `${stagedSign} Line:${line} ${diff.lines[0]}`,
|
|
5621
|
+
data: {
|
|
5622
|
+
line: `${line}`
|
|
5623
|
+
}
|
|
5624
|
+
});
|
|
5625
|
+
}
|
|
5626
|
+
}
|
|
5627
|
+
} catch (e) {
|
|
5628
|
+
}
|
|
5629
|
+
return res;
|
|
5630
|
+
}
|
|
5631
|
+
};
|
|
5632
|
+
var gchunks_default = GChunks;
|
|
5633
|
+
|
|
5561
5634
|
// src/manager.ts
|
|
5562
|
-
var
|
|
5635
|
+
var import_coc9 = __toModule(require("coc.nvim"));
|
|
5563
5636
|
var import_debounce = __toModule(require_debounce());
|
|
5564
5637
|
|
|
5565
5638
|
// src/model/status.ts
|
|
5566
|
-
var
|
|
5639
|
+
var import_coc8 = __toModule(require("coc.nvim"));
|
|
5567
5640
|
var GitStatus = class {
|
|
5568
5641
|
constructor(service) {
|
|
5569
5642
|
this.service = service;
|
|
5570
5643
|
this.disposables = [];
|
|
5571
5644
|
this._enabled = false;
|
|
5572
|
-
this.mutex = new
|
|
5573
|
-
let config =
|
|
5645
|
+
this.mutex = new import_coc8.Mutex();
|
|
5646
|
+
let config = import_coc8.workspace.getConfiguration("git");
|
|
5574
5647
|
this._enabled = config.get("enableGlobalStatus", true);
|
|
5575
5648
|
this.branchCharacter = config.get("branchCharacter", "");
|
|
5576
5649
|
this.characters = {
|
|
@@ -5579,10 +5652,10 @@ var GitStatus = class {
|
|
|
5579
5652
|
stagedDecorator: config.get("stagedDecorator"),
|
|
5580
5653
|
untrackedDecorator: config.get("untrackedDecorator")
|
|
5581
5654
|
};
|
|
5582
|
-
|
|
5583
|
-
|
|
5655
|
+
import_coc8.events.on("BufEnter", this.refresh, this, this.disposables);
|
|
5656
|
+
import_coc8.events.on("FocusGained", this.refresh, this, this.disposables);
|
|
5584
5657
|
let timer;
|
|
5585
|
-
|
|
5658
|
+
import_coc8.events.on("BufWritePost", () => {
|
|
5586
5659
|
timer = setTimeout(() => {
|
|
5587
5660
|
this.refresh();
|
|
5588
5661
|
}, 300);
|
|
@@ -5617,14 +5690,14 @@ var GitStatus = class {
|
|
|
5617
5690
|
if (this.gitStatus == status)
|
|
5618
5691
|
return;
|
|
5619
5692
|
this.gitStatus = status;
|
|
5620
|
-
let {nvim} =
|
|
5693
|
+
let {nvim} = import_coc8.workspace;
|
|
5621
5694
|
nvim.pauseNotification();
|
|
5622
5695
|
nvim.setVar("coc_git_status", status, true);
|
|
5623
5696
|
nvim.call("coc#util#do_autocmd", ["CocGitStatusChange"], true);
|
|
5624
5697
|
nvim.resumeNotification(false, true);
|
|
5625
5698
|
}
|
|
5626
5699
|
dispose() {
|
|
5627
|
-
|
|
5700
|
+
import_coc8.disposeAll(this.disposables);
|
|
5628
5701
|
}
|
|
5629
5702
|
};
|
|
5630
5703
|
var status_default = GitStatus;
|
|
@@ -5660,12 +5733,12 @@ var DocumentManager = class {
|
|
|
5660
5733
|
this.disposables = [];
|
|
5661
5734
|
this.defined = false;
|
|
5662
5735
|
this.loadConfiguration();
|
|
5663
|
-
|
|
5736
|
+
import_coc9.workspace.onDidChangeConfiguration(this.loadConfiguration, this, this.disposables);
|
|
5664
5737
|
this.gitStatus = new status_default(service);
|
|
5665
5738
|
const createBuffer = (doc) => {
|
|
5666
5739
|
let {uri} = doc;
|
|
5667
5740
|
service.createBuffer(doc, this.config).then((buf) => {
|
|
5668
|
-
if (!buf ||
|
|
5741
|
+
if (!buf || import_coc9.workspace.getDocument(uri) == null)
|
|
5669
5742
|
return;
|
|
5670
5743
|
this.defineSigns().catch((e) => {
|
|
5671
5744
|
console.error(e.message);
|
|
@@ -5673,43 +5746,43 @@ var DocumentManager = class {
|
|
|
5673
5746
|
this.buffers.set(doc.bufnr, buf);
|
|
5674
5747
|
});
|
|
5675
5748
|
};
|
|
5676
|
-
for (let doc of
|
|
5749
|
+
for (let doc of import_coc9.workspace.documents) {
|
|
5677
5750
|
createBuffer(doc);
|
|
5678
5751
|
}
|
|
5679
|
-
|
|
5680
|
-
createBuffer(
|
|
5752
|
+
import_coc9.workspace.onDidOpenTextDocument(async (e) => {
|
|
5753
|
+
createBuffer(import_coc9.workspace.getDocument(e.bufnr));
|
|
5681
5754
|
}, null, this.disposables);
|
|
5682
|
-
|
|
5755
|
+
import_coc9.workspace.onDidChangeTextDocument(async (e) => {
|
|
5683
5756
|
let buf = this.buffers.get(e.bufnr);
|
|
5684
5757
|
if (buf)
|
|
5685
5758
|
buf.refresh();
|
|
5686
5759
|
}, null, this.disposables);
|
|
5687
|
-
|
|
5760
|
+
import_coc9.workspace.onDidCloseTextDocument((e) => {
|
|
5688
5761
|
let buf = this.buffers.get(e.bufnr);
|
|
5689
5762
|
if (buf)
|
|
5690
5763
|
buf.dispose();
|
|
5691
5764
|
this.buffers.delete(e.bufnr);
|
|
5692
5765
|
this.service.resolver.delete(e.uri);
|
|
5693
5766
|
}, null, this.disposables);
|
|
5694
|
-
|
|
5767
|
+
import_coc9.events.on("CursorMoved", import_debounce.default(async (bufnr, cursor) => {
|
|
5695
5768
|
let buf = this.buffers.get(bufnr);
|
|
5696
5769
|
if (buf)
|
|
5697
5770
|
await buf.showBlameInfo(cursor[0]);
|
|
5698
5771
|
}, 100), null, this.disposables);
|
|
5699
|
-
|
|
5772
|
+
import_coc9.events.on("BufWritePre", (bufnr) => {
|
|
5700
5773
|
if (!this.enableGutters || this.config.realtimeGutters)
|
|
5701
5774
|
return;
|
|
5702
5775
|
let buf = this.buffers.get(bufnr);
|
|
5703
5776
|
if (buf)
|
|
5704
5777
|
buf.updateGutters();
|
|
5705
5778
|
}, null, this.disposables);
|
|
5706
|
-
|
|
5779
|
+
import_coc9.events.on("FocusGained", async () => {
|
|
5707
5780
|
let bufnr = await nvim.call("bufnr", ["%"]);
|
|
5708
5781
|
let buf = this.buffers.get(bufnr);
|
|
5709
5782
|
if (buf)
|
|
5710
5783
|
buf.refresh();
|
|
5711
5784
|
}, null, this.disposables);
|
|
5712
|
-
|
|
5785
|
+
import_coc9.events.on("BufEnter", (bufnr) => {
|
|
5713
5786
|
let buf = this.buffers.get(bufnr);
|
|
5714
5787
|
if (buf)
|
|
5715
5788
|
buf.refresh();
|
|
@@ -5720,7 +5793,7 @@ var DocumentManager = class {
|
|
|
5720
5793
|
return;
|
|
5721
5794
|
this.defined = true;
|
|
5722
5795
|
let {nvim} = this;
|
|
5723
|
-
const config =
|
|
5796
|
+
const config = import_coc9.workspace.getConfiguration("git");
|
|
5724
5797
|
let items = ["Changed", "Added", "Removed", "TopRemoved", "ChangeRemoved"];
|
|
5725
5798
|
nvim.pauseNotification();
|
|
5726
5799
|
for (let item of items) {
|
|
@@ -5735,13 +5808,13 @@ var DocumentManager = class {
|
|
|
5735
5808
|
loadConfiguration(e) {
|
|
5736
5809
|
if (e && !e.affectsConfiguration("git"))
|
|
5737
5810
|
return;
|
|
5738
|
-
let config =
|
|
5811
|
+
let config = import_coc9.workspace.getConfiguration("git");
|
|
5739
5812
|
let obj = {
|
|
5740
5813
|
remoteName: config.get("remoteName", "origin"),
|
|
5741
5814
|
diffRevision: config.get("diffRevision", ""),
|
|
5742
5815
|
issueFormat: config.get("issueFormat", "#%i"),
|
|
5743
5816
|
virtualTextPrefix: config.get("virtualTextPrefix", " "),
|
|
5744
|
-
addGBlameToVirtualText:
|
|
5817
|
+
addGBlameToVirtualText: import_coc9.workspace.nvim.hasFunction("nvim_buf_set_virtual_text") && config.get("addGBlameToVirtualText", false),
|
|
5745
5818
|
addGBlameToBufferVar: config.get("addGBlameToBufferVar", false),
|
|
5746
5819
|
blameUseRealTime: config.get("blameUseRealTime", false),
|
|
5747
5820
|
enableGutters: config.get("enableGutters", true),
|
|
@@ -5775,6 +5848,9 @@ var DocumentManager = class {
|
|
|
5775
5848
|
currentHlGroup: config.get("conflict.current.hlGroup", "DiffChange"),
|
|
5776
5849
|
incomingHlGroup: config.get("conflict.incoming.hlGroup", "DiffAdd")
|
|
5777
5850
|
},
|
|
5851
|
+
gstatus: {
|
|
5852
|
+
saveBeforeOpen: config.get("gstatus.saveBeforeOpen", false)
|
|
5853
|
+
},
|
|
5778
5854
|
virtualTextSrcId: this.virtualTextSrcId,
|
|
5779
5855
|
conflictSrcId: this.conflictSrcId
|
|
5780
5856
|
};
|
|
@@ -5783,12 +5859,15 @@ var DocumentManager = class {
|
|
|
5783
5859
|
get enableGutters() {
|
|
5784
5860
|
return this.config.enableGutters;
|
|
5785
5861
|
}
|
|
5862
|
+
get gstatusSaveBeforeOpen() {
|
|
5863
|
+
return this.config.gstatus.saveBeforeOpen;
|
|
5864
|
+
}
|
|
5786
5865
|
get git() {
|
|
5787
5866
|
return this.service.git;
|
|
5788
5867
|
}
|
|
5789
5868
|
async toggleGutters() {
|
|
5790
5869
|
let enabled = this.enableGutters;
|
|
5791
|
-
let config =
|
|
5870
|
+
let config = import_coc9.workspace.getConfiguration("git");
|
|
5792
5871
|
config.update("enableGutters", !enabled, true);
|
|
5793
5872
|
for (let buf of this.buffers.values()) {
|
|
5794
5873
|
await buf.toggleGutters(!enabled);
|
|
@@ -5800,7 +5879,7 @@ var DocumentManager = class {
|
|
|
5800
5879
|
await buf.toggleFold();
|
|
5801
5880
|
}
|
|
5802
5881
|
async resolveGitRootFromBufferOrCwd(bufnr) {
|
|
5803
|
-
let doc =
|
|
5882
|
+
let doc = import_coc9.workspace.getDocument(bufnr);
|
|
5804
5883
|
let root;
|
|
5805
5884
|
let {resolver} = this.service;
|
|
5806
5885
|
if (doc) {
|
|
@@ -5880,10 +5959,16 @@ var DocumentManager = class {
|
|
|
5880
5959
|
if (buf)
|
|
5881
5960
|
await buf.showCommit();
|
|
5882
5961
|
}
|
|
5883
|
-
async
|
|
5962
|
+
async showBlameDoc() {
|
|
5963
|
+
let buf = await this.buffer;
|
|
5964
|
+
let line = await this.nvim.call("line", ".");
|
|
5965
|
+
if (buf)
|
|
5966
|
+
await buf.showBlameDoc(line);
|
|
5967
|
+
}
|
|
5968
|
+
async browser(action = "open", range, permalink = false) {
|
|
5884
5969
|
let buf = await this.buffer;
|
|
5885
5970
|
if (buf)
|
|
5886
|
-
await buf.browser(action, range);
|
|
5971
|
+
await buf.browser(action, range, permalink);
|
|
5887
5972
|
}
|
|
5888
5973
|
async diffCached() {
|
|
5889
5974
|
let buf = await this.buffer;
|
|
@@ -5896,36 +5981,36 @@ var DocumentManager = class {
|
|
|
5896
5981
|
}
|
|
5897
5982
|
}
|
|
5898
5983
|
async push(args) {
|
|
5899
|
-
let bufnr = await
|
|
5984
|
+
let bufnr = await import_coc9.workspace.nvim.call("bufnr", "%");
|
|
5900
5985
|
let root = await this.resolveGitRootFromBufferOrCwd(bufnr);
|
|
5901
5986
|
let extra = this.config.pushArguments;
|
|
5902
5987
|
if (!root) {
|
|
5903
|
-
|
|
5988
|
+
import_coc9.window.showMessage(`not belongs to git repository.`, "warning");
|
|
5904
5989
|
return;
|
|
5905
5990
|
}
|
|
5906
5991
|
if (args && args.length) {
|
|
5907
|
-
await
|
|
5992
|
+
await import_coc9.window.runTerminalCommand(`git push ${[...args, ...extra].join(" ")}`, root, true);
|
|
5908
5993
|
return;
|
|
5909
5994
|
}
|
|
5910
5995
|
let repo = this.service.getRepoFromRoot(root);
|
|
5911
5996
|
let output = await repo.safeRun(["remote"]);
|
|
5912
5997
|
let remote = output.trim().split(/\r?\n/)[0];
|
|
5913
5998
|
if (!remote) {
|
|
5914
|
-
|
|
5999
|
+
import_coc9.window.showMessage(`remote not found`, "warning");
|
|
5915
6000
|
return;
|
|
5916
6001
|
}
|
|
5917
6002
|
output = await repo.safeRun(["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
5918
6003
|
if (!output) {
|
|
5919
|
-
|
|
6004
|
+
import_coc9.window.showMessage(`current branch not found`, "warning");
|
|
5920
6005
|
return;
|
|
5921
6006
|
}
|
|
5922
|
-
await
|
|
6007
|
+
await import_coc9.window.runTerminalCommand(`git push ${remote} ${output}${extra.length ? " " + extra.join(" ") : ""}`, root, true);
|
|
5923
6008
|
}
|
|
5924
6009
|
get buffer() {
|
|
5925
|
-
return
|
|
6010
|
+
return import_coc9.workspace.nvim.call("bufnr", "%").then((bufnr) => {
|
|
5926
6011
|
let buf = this.buffers.get(bufnr);
|
|
5927
6012
|
if (!buf)
|
|
5928
|
-
|
|
6013
|
+
import_coc9.window.showMessage(`Cant't resolve git repository for current buffer.`, "warning");
|
|
5929
6014
|
return buf;
|
|
5930
6015
|
});
|
|
5931
6016
|
}
|
|
@@ -5939,13 +6024,13 @@ var DocumentManager = class {
|
|
|
5939
6024
|
buf.dispose();
|
|
5940
6025
|
}
|
|
5941
6026
|
this.buffers.clear();
|
|
5942
|
-
|
|
6027
|
+
import_coc9.disposeAll(this.disposables);
|
|
5943
6028
|
}
|
|
5944
6029
|
};
|
|
5945
6030
|
var manager_default = DocumentManager;
|
|
5946
6031
|
|
|
5947
6032
|
// src/model/service.ts
|
|
5948
|
-
var
|
|
6033
|
+
var import_coc13 = __toModule(require("coc.nvim"));
|
|
5949
6034
|
|
|
5950
6035
|
// src/model/repo.ts
|
|
5951
6036
|
var import_fs2 = __toModule(require("fs"));
|
|
@@ -5960,7 +6045,7 @@ var Repo = class {
|
|
|
5960
6045
|
this.root = root;
|
|
5961
6046
|
}
|
|
5962
6047
|
async getStagedChunks(relpath) {
|
|
5963
|
-
let args = ["--no-pager", "diff", "-p", "-U0", "--no-color", "--staged"];
|
|
6048
|
+
let args = ["--no-pager", "diff", "--no-ext-diff", "-p", "-U0", "--no-color", "--staged"];
|
|
5964
6049
|
if (relpath)
|
|
5965
6050
|
args.push(toUnixSlash(relpath));
|
|
5966
6051
|
const result = await this.exec(args);
|
|
@@ -6109,7 +6194,7 @@ var Repo = class {
|
|
|
6109
6194
|
const currentFile = import_path4.default.join(import_os.default.tmpdir(), `coc-${uuid()}`);
|
|
6110
6195
|
await import_util6.default.promisify(import_fs2.default.writeFile)(stagedFile, staged + "\n", "utf8");
|
|
6111
6196
|
await import_util6.default.promisify(import_fs2.default.writeFile)(currentFile, content, "utf8");
|
|
6112
|
-
let output = await getStdout(`git --no-pager diff -p -U0 --no-color ${shellescape(stagedFile)} ${shellescape(currentFile)}`);
|
|
6197
|
+
let output = await getStdout(`git --no-pager diff --no-ext-diff -p -U0 --no-color ${shellescape(stagedFile)} ${shellescape(currentFile)}`);
|
|
6113
6198
|
await import_util6.default.promisify(import_fs2.default.unlink)(stagedFile);
|
|
6114
6199
|
await import_util6.default.promisify(import_fs2.default.unlink)(currentFile);
|
|
6115
6200
|
if (!output)
|
|
@@ -6218,7 +6303,7 @@ function parseDiff(diffStr) {
|
|
|
6218
6303
|
|
|
6219
6304
|
// src/model/git.ts
|
|
6220
6305
|
var cp = __toModule(require("child_process"));
|
|
6221
|
-
var
|
|
6306
|
+
var import_coc10 = __toModule(require("coc.nvim"));
|
|
6222
6307
|
var import_iconv_lite = __toModule(require_lib());
|
|
6223
6308
|
var import_path5 = __toModule(require("path"));
|
|
6224
6309
|
var Git = class {
|
|
@@ -6295,11 +6380,11 @@ async function exec2(child, cancellationToken) {
|
|
|
6295
6380
|
const disposables = [];
|
|
6296
6381
|
const once = (ee, name, fn) => {
|
|
6297
6382
|
ee.once(name, fn);
|
|
6298
|
-
disposables.push(
|
|
6383
|
+
disposables.push(import_coc10.Disposable.create(() => ee.removeListener(name, fn)));
|
|
6299
6384
|
};
|
|
6300
6385
|
const on = (ee, name, fn) => {
|
|
6301
6386
|
ee.on(name, fn);
|
|
6302
|
-
disposables.push(
|
|
6387
|
+
disposables.push(import_coc10.Disposable.create(() => ee.removeListener(name, fn)));
|
|
6303
6388
|
};
|
|
6304
6389
|
let result = Promise.all([
|
|
6305
6390
|
new Promise((c, e) => {
|
|
@@ -6333,12 +6418,12 @@ async function exec2(child, cancellationToken) {
|
|
|
6333
6418
|
const [exitCode, stdout, stderr] = await result;
|
|
6334
6419
|
return {exitCode, stdout, stderr};
|
|
6335
6420
|
} finally {
|
|
6336
|
-
|
|
6421
|
+
import_coc10.disposeAll(disposables);
|
|
6337
6422
|
}
|
|
6338
6423
|
}
|
|
6339
6424
|
|
|
6340
6425
|
// src/model/resolver.ts
|
|
6341
|
-
var
|
|
6426
|
+
var import_coc11 = __toModule(require("coc.nvim"));
|
|
6342
6427
|
var import_fs3 = __toModule(require("fs"));
|
|
6343
6428
|
var import_path6 = __toModule(require("path"));
|
|
6344
6429
|
var import_util9 = __toModule(require("util"));
|
|
@@ -6349,7 +6434,7 @@ async function getRealPath(fullpath) {
|
|
|
6349
6434
|
} catch (e) {
|
|
6350
6435
|
if (e.message.includes("ENOENT")) {
|
|
6351
6436
|
try {
|
|
6352
|
-
resolved = await
|
|
6437
|
+
resolved = await import_coc11.workspace.nvim.call("expand", [fullpath]);
|
|
6353
6438
|
} catch (e2) {
|
|
6354
6439
|
}
|
|
6355
6440
|
}
|
|
@@ -6390,7 +6475,7 @@ var Resolver = class {
|
|
|
6390
6475
|
if (doc.buftype != "" || doc.schema != "file") {
|
|
6391
6476
|
return null;
|
|
6392
6477
|
}
|
|
6393
|
-
let fullpath = await getRealPath(
|
|
6478
|
+
let fullpath = await getRealPath(import_coc11.Uri.parse(uri).fsPath);
|
|
6394
6479
|
if (process.platform == "win32") {
|
|
6395
6480
|
fullpath = import_path6.default.win32.normalize(fullpath);
|
|
6396
6481
|
}
|
|
@@ -6419,12 +6504,12 @@ var Resolver = class {
|
|
|
6419
6504
|
return root;
|
|
6420
6505
|
}
|
|
6421
6506
|
async resolveRootFromCwd() {
|
|
6422
|
-
let parts =
|
|
6507
|
+
let parts = import_coc11.workspace.cwd.split(import_path6.default.sep);
|
|
6423
6508
|
let idx = parts.indexOf(".git");
|
|
6424
6509
|
if (idx !== -1)
|
|
6425
6510
|
return parts.slice(0, idx).join(import_path6.default.sep);
|
|
6426
6511
|
try {
|
|
6427
|
-
return await this.git.getRepositoryRoot(
|
|
6512
|
+
return await this.git.getRepositoryRoot(import_coc11.workspace.cwd);
|
|
6428
6513
|
} catch (e) {
|
|
6429
6514
|
}
|
|
6430
6515
|
return null;
|
|
@@ -6437,7 +6522,7 @@ var Resolver = class {
|
|
|
6437
6522
|
var resolver_default = Resolver;
|
|
6438
6523
|
|
|
6439
6524
|
// src/model/buffer.ts
|
|
6440
|
-
var
|
|
6525
|
+
var import_coc12 = __toModule(require("coc.nvim"));
|
|
6441
6526
|
|
|
6442
6527
|
// node_modules/timeago.js/esm/lang/en_US.js
|
|
6443
6528
|
var EN_US = ["second", "minute", "hour", "day", "week", "month", "year"];
|
|
@@ -6535,7 +6620,7 @@ var GitBuffer = class {
|
|
|
6535
6620
|
this.hasConflicts = false;
|
|
6536
6621
|
this.foldEnabled = false;
|
|
6537
6622
|
this._disposed = false;
|
|
6538
|
-
this.mutex = new
|
|
6623
|
+
this.mutex = new import_coc12.Mutex();
|
|
6539
6624
|
this.refresh = import_debounce2.default(() => {
|
|
6540
6625
|
this._refresh().catch((e) => {
|
|
6541
6626
|
channel.append(`[Error] ${e.message}`);
|
|
@@ -6580,7 +6665,7 @@ var GitBuffer = class {
|
|
|
6580
6665
|
});
|
|
6581
6666
|
}
|
|
6582
6667
|
async chunkUndo() {
|
|
6583
|
-
let line = await
|
|
6668
|
+
let line = await import_coc12.workspace.nvim.call("line", ".");
|
|
6584
6669
|
let diff = this.getChunk(line);
|
|
6585
6670
|
if (!diff)
|
|
6586
6671
|
return;
|
|
@@ -6600,10 +6685,10 @@ var GitBuffer = class {
|
|
|
6600
6685
|
}
|
|
6601
6686
|
async chunkStage() {
|
|
6602
6687
|
let relpath = toUnixSlash(this.relpath);
|
|
6603
|
-
let line = await
|
|
6688
|
+
let line = await import_coc12.workspace.nvim.call("line", ".");
|
|
6604
6689
|
let diff = this.getChunk(line);
|
|
6605
6690
|
if (!diff) {
|
|
6606
|
-
|
|
6691
|
+
import_coc12.window.showMessage("Not positioned in git chunk", "error");
|
|
6607
6692
|
return;
|
|
6608
6693
|
}
|
|
6609
6694
|
let head;
|
|
@@ -6631,7 +6716,7 @@ var GitBuffer = class {
|
|
|
6631
6716
|
}
|
|
6632
6717
|
}
|
|
6633
6718
|
async chunkUnstage() {
|
|
6634
|
-
let {nvim} =
|
|
6719
|
+
let {nvim} = import_coc12.workspace;
|
|
6635
6720
|
const {diffs} = this;
|
|
6636
6721
|
let line = await nvim.call("line", ".");
|
|
6637
6722
|
let adjust = 0;
|
|
@@ -6639,7 +6724,7 @@ var GitBuffer = class {
|
|
|
6639
6724
|
for (let diff of diffs) {
|
|
6640
6725
|
if (diff.end >= line) {
|
|
6641
6726
|
if (diff.start <= line && diff.changeType != ChangeType.Delete) {
|
|
6642
|
-
|
|
6727
|
+
import_coc12.window.showErrorMessage(`Current line contains unstaged change.`);
|
|
6643
6728
|
invalid = true;
|
|
6644
6729
|
}
|
|
6645
6730
|
break;
|
|
@@ -6653,12 +6738,12 @@ var GitBuffer = class {
|
|
|
6653
6738
|
let stagedDiff = await this.repo.getStagedChunks(this.relpath);
|
|
6654
6739
|
let chunks = Object.values(stagedDiff)[0];
|
|
6655
6740
|
if (!chunks.length) {
|
|
6656
|
-
|
|
6741
|
+
import_coc12.window.showErrorMessage(`Staged chunk not found`);
|
|
6657
6742
|
return;
|
|
6658
6743
|
}
|
|
6659
6744
|
let chunk = chunks.find((o) => o.add.lnum <= line && o.add.lnum + o.add.count >= line);
|
|
6660
6745
|
if (!chunk) {
|
|
6661
|
-
|
|
6746
|
+
import_coc12.window.showErrorMessage(`Unable to find staged chunk on current line`);
|
|
6662
6747
|
return;
|
|
6663
6748
|
}
|
|
6664
6749
|
this.channel.appendLine(`[Info] resolved chunk ${JSON.stringify(chunk, null, 2)}`);
|
|
@@ -6669,52 +6754,77 @@ var GitBuffer = class {
|
|
|
6669
6754
|
await this.git.exec(this.repo.root, ["apply", "--cached", "--unidiff-zero", "-"], {input: patch});
|
|
6670
6755
|
this.refresh();
|
|
6671
6756
|
} catch (e) {
|
|
6672
|
-
|
|
6757
|
+
import_coc12.window.showErrorMessage(`Unable to apply patch: ${e.message}`);
|
|
6673
6758
|
this.channel.appendLine(`[Error] ${e.message}`);
|
|
6674
6759
|
}
|
|
6675
6760
|
}
|
|
6676
6761
|
async nextChunk() {
|
|
6677
6762
|
const {diffs} = this;
|
|
6678
|
-
let {nvim} =
|
|
6763
|
+
let {nvim} = import_coc12.workspace;
|
|
6679
6764
|
if (!diffs || diffs.length == 0)
|
|
6680
6765
|
return;
|
|
6681
6766
|
let line = await nvim.call("line", ".");
|
|
6682
6767
|
for (let diff of diffs) {
|
|
6683
6768
|
if (diff.start > line) {
|
|
6684
|
-
await
|
|
6769
|
+
await import_coc12.window.moveTo({line: Math.max(diff.start - 1, 0), character: 0});
|
|
6685
6770
|
return;
|
|
6686
6771
|
}
|
|
6687
6772
|
}
|
|
6688
6773
|
if (await nvim.getOption("wrapscan")) {
|
|
6689
|
-
await
|
|
6774
|
+
await import_coc12.window.moveTo({line: Math.max(diffs[0].start - 1, 0), character: 0});
|
|
6690
6775
|
}
|
|
6691
6776
|
}
|
|
6692
6777
|
async prevChunk() {
|
|
6693
|
-
const {nvim} =
|
|
6778
|
+
const {nvim} = import_coc12.workspace;
|
|
6694
6779
|
let {diffs} = this;
|
|
6695
6780
|
let line = await nvim.call("line", ".");
|
|
6696
6781
|
if (!diffs || diffs.length == 0)
|
|
6697
6782
|
return;
|
|
6698
6783
|
for (let diff of diffs.slice().reverse()) {
|
|
6699
6784
|
if (diff.end < line) {
|
|
6700
|
-
await
|
|
6785
|
+
await import_coc12.window.moveTo({line: Math.max(diff.start - 1, 0), character: 0});
|
|
6701
6786
|
return;
|
|
6702
6787
|
}
|
|
6703
6788
|
}
|
|
6704
6789
|
if (await nvim.getOption("wrapscan")) {
|
|
6705
|
-
await
|
|
6790
|
+
await import_coc12.window.moveTo({line: Math.max(diffs[diffs.length - 1].start - 1, 0), character: 0});
|
|
6706
6791
|
}
|
|
6707
6792
|
}
|
|
6708
6793
|
async chunkInfo() {
|
|
6709
|
-
let line = await
|
|
6794
|
+
let line = await import_coc12.workspace.nvim.call("line", ".");
|
|
6710
6795
|
let diff = this.getChunk(line);
|
|
6711
6796
|
if (diff) {
|
|
6712
6797
|
let content = diff.head + "\n" + diff.lines.join("\n");
|
|
6713
6798
|
await this.showDoc(content, "diff");
|
|
6799
|
+
} else {
|
|
6800
|
+
let chunks;
|
|
6801
|
+
try {
|
|
6802
|
+
let stagedDiff = await this.repo.getStagedChunks(this.relpath);
|
|
6803
|
+
chunks = Object.values(stagedDiff)[0];
|
|
6804
|
+
} catch (e) {
|
|
6805
|
+
return;
|
|
6806
|
+
}
|
|
6807
|
+
if (!chunks.length) {
|
|
6808
|
+
return;
|
|
6809
|
+
}
|
|
6810
|
+
let adjust = 0;
|
|
6811
|
+
for (let diff2 of this.diffs) {
|
|
6812
|
+
if (diff2.end >= line) {
|
|
6813
|
+
break;
|
|
6814
|
+
}
|
|
6815
|
+
adjust -= diff2.added.count;
|
|
6816
|
+
adjust += diff2.removed.count;
|
|
6817
|
+
}
|
|
6818
|
+
line = line + adjust;
|
|
6819
|
+
let chunk = chunks.find((o) => o.add.lnum <= line && o.add.lnum + o.add.count >= line);
|
|
6820
|
+
if (chunk) {
|
|
6821
|
+
let content = "Staged chagnes\n" + chunk.lines.join("\n");
|
|
6822
|
+
await this.showDoc(content, "diff");
|
|
6823
|
+
}
|
|
6714
6824
|
}
|
|
6715
6825
|
}
|
|
6716
6826
|
async showBlameInfo(lnum) {
|
|
6717
|
-
let {nvim} =
|
|
6827
|
+
let {nvim} = import_coc12.workspace;
|
|
6718
6828
|
let {virtualTextSrcId, addGBlameToBufferVar, addGBlameToVirtualText} = this.config;
|
|
6719
6829
|
if (!this.showBlame)
|
|
6720
6830
|
return;
|
|
@@ -6746,7 +6856,7 @@ var GitBuffer = class {
|
|
|
6746
6856
|
if (addGBlameToVirtualText) {
|
|
6747
6857
|
const prefix = this.config.virtualTextPrefix;
|
|
6748
6858
|
await buffer.clearNamespace(virtualTextSrcId);
|
|
6749
|
-
if (
|
|
6859
|
+
if (import_coc12.workspace.has("nvim-0.6.0")) {
|
|
6750
6860
|
await buffer.setExtMark(virtualTextSrcId, lnum - 1, 0, {
|
|
6751
6861
|
hl_mode: "combine",
|
|
6752
6862
|
virt_text: [[prefix + blameText, "CocCodeLens"]]
|
|
@@ -6757,9 +6867,27 @@ var GitBuffer = class {
|
|
|
6757
6867
|
}
|
|
6758
6868
|
}
|
|
6759
6869
|
}
|
|
6870
|
+
async showBlameDoc(lnum) {
|
|
6871
|
+
let indexed = await this.repo.isIndexed(this.relpath);
|
|
6872
|
+
if (!indexed) {
|
|
6873
|
+
import_coc12.window.showMessage("File not indexed");
|
|
6874
|
+
} else {
|
|
6875
|
+
let infos = await this.getBlameInfo();
|
|
6876
|
+
let info = infos.find((o) => lnum >= o.startLnum && lnum <= o.endLnum);
|
|
6877
|
+
if (info && info.author && info.author != "Not Committed Yet") {
|
|
6878
|
+
let blameText = [];
|
|
6879
|
+
blameText.push(`${info.author}, ${info.time}`);
|
|
6880
|
+
blameText.push(`${info.summary}`);
|
|
6881
|
+
blameText.push(`${info.sha.substring(0, 7)}`);
|
|
6882
|
+
await this.showDoc(blameText.join("\n\n"), "text");
|
|
6883
|
+
} else {
|
|
6884
|
+
import_coc12.window.showMessage("Not committed yet");
|
|
6885
|
+
}
|
|
6886
|
+
}
|
|
6887
|
+
}
|
|
6760
6888
|
async diffDocument(force = false) {
|
|
6761
6889
|
var _a;
|
|
6762
|
-
let {nvim} =
|
|
6890
|
+
let {nvim} = import_coc12.workspace;
|
|
6763
6891
|
let revision = this.config.diffRevision;
|
|
6764
6892
|
const {bufnr} = this.doc;
|
|
6765
6893
|
const diffs = await this.repo.getDiff(this.relpath, this.doc.content, revision);
|
|
@@ -6838,7 +6966,7 @@ var GitBuffer = class {
|
|
|
6838
6966
|
return;
|
|
6839
6967
|
if (!this.config.enableGutters)
|
|
6840
6968
|
return;
|
|
6841
|
-
let {nvim} =
|
|
6969
|
+
let {nvim} = import_coc12.workspace;
|
|
6842
6970
|
let {bufnr} = this.doc;
|
|
6843
6971
|
let {signPriority} = this.config;
|
|
6844
6972
|
let signs = this.currentSigns;
|
|
@@ -6911,10 +7039,10 @@ var GitBuffer = class {
|
|
|
6911
7039
|
async diffCached() {
|
|
6912
7040
|
let res = await this.repo.safeRun(["diff", "--cached"]);
|
|
6913
7041
|
if (!res.trim()) {
|
|
6914
|
-
|
|
7042
|
+
import_coc12.window.showMessage("Empty diff");
|
|
6915
7043
|
return;
|
|
6916
7044
|
}
|
|
6917
|
-
let {nvim} =
|
|
7045
|
+
let {nvim} = import_coc12.workspace;
|
|
6918
7046
|
nvim.pauseNotification();
|
|
6919
7047
|
nvim.command(`keepalt above new +setl\\ previewwindow`, true);
|
|
6920
7048
|
nvim.call("append", [0, res.split(/\r?\n/)], true);
|
|
@@ -6925,44 +7053,44 @@ var GitBuffer = class {
|
|
|
6925
7053
|
await nvim.resumeNotification();
|
|
6926
7054
|
}
|
|
6927
7055
|
async nextConflict() {
|
|
6928
|
-
let {nvim} =
|
|
7056
|
+
let {nvim} = import_coc12.workspace;
|
|
6929
7057
|
if (!this.conflicts.length) {
|
|
6930
|
-
|
|
7058
|
+
import_coc12.window.showMessage("No conflicts detected", "warning");
|
|
6931
7059
|
return;
|
|
6932
7060
|
}
|
|
6933
7061
|
let line = await nvim.call("line", ".");
|
|
6934
7062
|
for (let conflict of this.conflicts) {
|
|
6935
7063
|
if (conflict.start > line) {
|
|
6936
|
-
await
|
|
7064
|
+
await import_coc12.window.moveTo({line: Math.max(conflict.start - 1, 0), character: 0});
|
|
6937
7065
|
return;
|
|
6938
7066
|
}
|
|
6939
7067
|
}
|
|
6940
7068
|
if (await nvim.getOption("wrapscan")) {
|
|
6941
|
-
await
|
|
7069
|
+
await import_coc12.window.moveTo({line: Math.max(this.conflicts[0].start - 1, 0), character: 0});
|
|
6942
7070
|
}
|
|
6943
7071
|
}
|
|
6944
7072
|
async prevConflict() {
|
|
6945
|
-
let {nvim} =
|
|
7073
|
+
let {nvim} = import_coc12.workspace;
|
|
6946
7074
|
if (!this.conflicts.length) {
|
|
6947
|
-
|
|
7075
|
+
import_coc12.window.showMessage("No conflicts detected", "warning");
|
|
6948
7076
|
return;
|
|
6949
7077
|
}
|
|
6950
7078
|
let line = await nvim.call("line", ".");
|
|
6951
7079
|
for (let conflict of this.conflicts) {
|
|
6952
7080
|
if (conflict.start > line) {
|
|
6953
|
-
await
|
|
7081
|
+
await import_coc12.window.moveTo({line: Math.max(conflict.start - 1, 0), character: 0});
|
|
6954
7082
|
return;
|
|
6955
7083
|
}
|
|
6956
7084
|
}
|
|
6957
7085
|
if (await nvim.getOption("wrapscan")) {
|
|
6958
|
-
await
|
|
7086
|
+
await import_coc12.window.moveTo({line: Math.max(this.conflicts[0].start - 1, 0), character: 0});
|
|
6959
7087
|
}
|
|
6960
7088
|
}
|
|
6961
7089
|
async conflictKeepPart(part) {
|
|
6962
|
-
const {nvim} =
|
|
7090
|
+
const {nvim} = import_coc12.workspace;
|
|
6963
7091
|
let conflicts = this.conflicts;
|
|
6964
7092
|
if (!conflicts || conflicts.length == 0) {
|
|
6965
|
-
|
|
7093
|
+
import_coc12.window.showMessage("No conflicts detected");
|
|
6966
7094
|
return;
|
|
6967
7095
|
}
|
|
6968
7096
|
let line = await nvim.call("line", ".");
|
|
@@ -6982,12 +7110,11 @@ var GitBuffer = class {
|
|
|
6982
7110
|
}
|
|
6983
7111
|
}
|
|
6984
7112
|
}
|
|
6985
|
-
|
|
7113
|
+
import_coc12.window.showMessage("Not positioned on a conflict");
|
|
6986
7114
|
}
|
|
6987
|
-
async browser(action = "open", range) {
|
|
6988
|
-
let {nvim} =
|
|
6989
|
-
let config =
|
|
6990
|
-
let mode = config.get("urlMode", "normal").trim();
|
|
7115
|
+
async browser(action = "open", range, permalink = false) {
|
|
7116
|
+
let {nvim} = import_coc12.workspace;
|
|
7117
|
+
let config = import_coc12.workspace.getConfiguration("git");
|
|
6991
7118
|
let head = (await this.repo.safeRun(["rev-parse", "HEAD"])).trim();
|
|
6992
7119
|
let branch = config.get("browserBranchName", "").trim();
|
|
6993
7120
|
if (!branch.length) {
|
|
@@ -7006,7 +7133,7 @@ var GitBuffer = class {
|
|
|
7006
7133
|
}
|
|
7007
7134
|
let output = await this.repo.safeRun(["remote"]);
|
|
7008
7135
|
if (!output.trim()) {
|
|
7009
|
-
|
|
7136
|
+
import_coc12.window.showMessage(`No remote found`, "warning");
|
|
7010
7137
|
return;
|
|
7011
7138
|
}
|
|
7012
7139
|
let names = output.trim().split(/\r?\n/);
|
|
@@ -7015,7 +7142,7 @@ var GitBuffer = class {
|
|
|
7015
7142
|
if (names.includes(browserRemoteName)) {
|
|
7016
7143
|
names = [browserRemoteName];
|
|
7017
7144
|
} else {
|
|
7018
|
-
|
|
7145
|
+
import_coc12.window.showMessage("Configured git.browserRemoteName missing from remote list", "warning");
|
|
7019
7146
|
return;
|
|
7020
7147
|
}
|
|
7021
7148
|
}
|
|
@@ -7029,28 +7156,28 @@ var GitBuffer = class {
|
|
|
7029
7156
|
let hostname = tmp.hostname;
|
|
7030
7157
|
let fix = "|";
|
|
7031
7158
|
try {
|
|
7032
|
-
fix = config.get("urlFix")[hostname][
|
|
7159
|
+
fix = config.get("urlFix")[hostname][permalink ? 1 : 0];
|
|
7033
7160
|
} catch (e) {
|
|
7034
7161
|
}
|
|
7035
|
-
let url = getUrl(fix, repoURL,
|
|
7162
|
+
let url = getUrl(fix, repoURL, permalink ? head : branch, this.relpath.replace(/\\\\/g, "/"), lines);
|
|
7036
7163
|
if (url)
|
|
7037
7164
|
urls.push(url);
|
|
7038
7165
|
}
|
|
7039
7166
|
if (urls.length == 1) {
|
|
7040
7167
|
if (action == "open") {
|
|
7041
|
-
|
|
7168
|
+
await import_coc12.workspace.openResource(urls[0]);
|
|
7042
7169
|
} else {
|
|
7043
7170
|
nvim.command(`let @+ = '${urls[0]}'`, true);
|
|
7044
|
-
|
|
7171
|
+
import_coc12.window.showMessage("Copied url to clipboard");
|
|
7045
7172
|
}
|
|
7046
7173
|
} else if (urls.length > 1) {
|
|
7047
|
-
let idx = await
|
|
7174
|
+
let idx = await import_coc12.window.showQuickpick(urls, "Select url:");
|
|
7048
7175
|
if (idx >= 0) {
|
|
7049
7176
|
if (action == "open") {
|
|
7050
|
-
|
|
7177
|
+
await import_coc12.workspace.openResource(urls[idx]);
|
|
7051
7178
|
} else {
|
|
7052
7179
|
nvim.command(`let @+ = '${urls[idx]}'`, true);
|
|
7053
|
-
|
|
7180
|
+
import_coc12.window.showMessage("Copied url to clipboard");
|
|
7054
7181
|
}
|
|
7055
7182
|
}
|
|
7056
7183
|
}
|
|
@@ -7058,10 +7185,10 @@ var GitBuffer = class {
|
|
|
7058
7185
|
async showCommit() {
|
|
7059
7186
|
let indexed = await this.repo.isIndexed(this.relpath);
|
|
7060
7187
|
if (!indexed) {
|
|
7061
|
-
|
|
7188
|
+
import_coc12.window.showMessage(`"${this.relpath}" not indexed.`, "warning");
|
|
7062
7189
|
return;
|
|
7063
7190
|
}
|
|
7064
|
-
let nvim =
|
|
7191
|
+
let nvim = import_coc12.workspace.nvim;
|
|
7065
7192
|
let line = await nvim.eval('line(".")');
|
|
7066
7193
|
let args = ["--no-pager", "blame", "-l", "--root", "-t", `-L${line},${line}`, this.relpath];
|
|
7067
7194
|
let res = await this.repo.exec(args);
|
|
@@ -7070,7 +7197,7 @@ var GitBuffer = class {
|
|
|
7070
7197
|
return;
|
|
7071
7198
|
let commit = output.match(/^\S+/)[0];
|
|
7072
7199
|
if (/^0+$/.test(commit)) {
|
|
7073
|
-
|
|
7200
|
+
import_coc12.window.showMessage("not committed yet!", "warning");
|
|
7074
7201
|
return;
|
|
7075
7202
|
}
|
|
7076
7203
|
let useFloating = this.config.showCommitInFloating;
|
|
@@ -7101,16 +7228,16 @@ var GitBuffer = class {
|
|
|
7101
7228
|
}
|
|
7102
7229
|
}
|
|
7103
7230
|
async toggleFold() {
|
|
7104
|
-
let {nvim} =
|
|
7231
|
+
let {nvim} = import_coc12.workspace;
|
|
7105
7232
|
let buf = this.doc.buffer;
|
|
7106
7233
|
let win = await nvim.window;
|
|
7107
7234
|
let bufnr = buf.id;
|
|
7108
|
-
let doc =
|
|
7235
|
+
let doc = import_coc12.workspace.getDocument(bufnr);
|
|
7109
7236
|
if (!doc)
|
|
7110
7237
|
return;
|
|
7111
7238
|
let infos = this.currentSigns;
|
|
7112
7239
|
if (!infos || infos.length == 0) {
|
|
7113
|
-
|
|
7240
|
+
import_coc12.window.showMessage("No changes", "warning");
|
|
7114
7241
|
return;
|
|
7115
7242
|
}
|
|
7116
7243
|
let lnums = infos.map((o) => o.lnum);
|
|
@@ -7168,7 +7295,7 @@ var GitBuffer = class {
|
|
|
7168
7295
|
}
|
|
7169
7296
|
async toggleGutters(enabled) {
|
|
7170
7297
|
this.config.enableGutters = enabled;
|
|
7171
|
-
let {nvim} =
|
|
7298
|
+
let {nvim} = import_coc12.workspace;
|
|
7172
7299
|
if (!enabled) {
|
|
7173
7300
|
nvim.call("sign_unplace", [signGroup, {buffer: this.doc.bufnr}], true);
|
|
7174
7301
|
} else {
|
|
@@ -7253,7 +7380,7 @@ var GitBuffer = class {
|
|
|
7253
7380
|
let buffer = this.doc.buffer;
|
|
7254
7381
|
let currentHlGroup = this.config.conflict.currentHlGroup;
|
|
7255
7382
|
let incomingHlGroup = this.config.conflict.incomingHlGroup;
|
|
7256
|
-
let {nvim} =
|
|
7383
|
+
let {nvim} = import_coc12.workspace;
|
|
7257
7384
|
nvim.pauseNotification();
|
|
7258
7385
|
buffer.clearNamespace(this.config.conflictSrcId, 0, -1);
|
|
7259
7386
|
conflicts.map((conflict) => {
|
|
@@ -7274,12 +7401,12 @@ var GitBuffer = class {
|
|
|
7274
7401
|
nvim.resumeNotification(false, true);
|
|
7275
7402
|
}
|
|
7276
7403
|
async showDoc(content, filetype = "diff") {
|
|
7277
|
-
if (
|
|
7404
|
+
if (import_coc12.workspace.floatSupported) {
|
|
7278
7405
|
let docs = [{content, filetype}];
|
|
7279
7406
|
await this.floatFactory.show(docs);
|
|
7280
7407
|
} else {
|
|
7281
7408
|
const lines = content.split("\n");
|
|
7282
|
-
|
|
7409
|
+
import_coc12.workspace.nvim.call("coc#util#preview_info", [lines, "diff"], true);
|
|
7283
7410
|
}
|
|
7284
7411
|
}
|
|
7285
7412
|
setBufferStatus(status) {
|
|
@@ -7287,7 +7414,7 @@ var GitBuffer = class {
|
|
|
7287
7414
|
if (exists == status)
|
|
7288
7415
|
return;
|
|
7289
7416
|
this.gitStatus = status;
|
|
7290
|
-
let {nvim} =
|
|
7417
|
+
let {nvim} = import_coc12.workspace;
|
|
7291
7418
|
let buffer = nvim.createBuffer(this.doc.bufnr);
|
|
7292
7419
|
nvim.pauseNotification();
|
|
7293
7420
|
buffer.setVar("coc_git_status", status, true);
|
|
@@ -7313,7 +7440,7 @@ var GitBuffer = class {
|
|
|
7313
7440
|
return this.config.addGBlameToVirtualText || this.config.addGBlameToBufferVar;
|
|
7314
7441
|
}
|
|
7315
7442
|
dispose() {
|
|
7316
|
-
let {nvim} =
|
|
7443
|
+
let {nvim} = import_coc12.workspace;
|
|
7317
7444
|
let {bufnr} = this.doc;
|
|
7318
7445
|
let buffer = nvim.createBuffer(bufnr);
|
|
7319
7446
|
buffer.setVar("coc_git_status", "", true);
|
|
@@ -7341,10 +7468,10 @@ var import_path7 = __toModule(require("path"));
|
|
|
7341
7468
|
var GitService = class {
|
|
7342
7469
|
constructor(gitInfo) {
|
|
7343
7470
|
this.repos = new Map();
|
|
7344
|
-
const outputChannel = this.outputChannel =
|
|
7471
|
+
const outputChannel = this.outputChannel = import_coc13.window.createOutputChannel("git");
|
|
7345
7472
|
this._git = new git_default(gitInfo, outputChannel);
|
|
7346
7473
|
this._resolver = new resolver_default(this._git, outputChannel);
|
|
7347
|
-
this.floatFactory = new
|
|
7474
|
+
this.floatFactory = new import_coc13.FloatFactory(import_coc13.workspace.nvim);
|
|
7348
7475
|
}
|
|
7349
7476
|
getRepoFromRoot(root) {
|
|
7350
7477
|
if (this.repos.has(root)) {
|
|
@@ -7370,11 +7497,11 @@ var GitService = class {
|
|
|
7370
7497
|
return new buffer_default(doc, config, relpath, repo, this.git, this.outputChannel, this.floatFactory);
|
|
7371
7498
|
}
|
|
7372
7499
|
async getCurrentRepo() {
|
|
7373
|
-
let {nvim} =
|
|
7500
|
+
let {nvim} = import_coc13.workspace;
|
|
7374
7501
|
let [fullpath, buftype] = await nvim.eval('[expand("%:p"),&buftype]');
|
|
7375
7502
|
if (!import_path7.default.isAbsolute(fullpath) || buftype != "")
|
|
7376
7503
|
return void 0;
|
|
7377
|
-
let root = await this.resolver.resolveGitRoot({uri:
|
|
7504
|
+
let root = await this.resolver.resolveGitRoot({uri: import_coc13.Uri.file(fullpath).toString(), schema: "file", buftype: ""});
|
|
7378
7505
|
if (root == null)
|
|
7379
7506
|
return void 0;
|
|
7380
7507
|
return this.getRepoFromRoot(root);
|
|
@@ -7398,15 +7525,15 @@ var GitService = class {
|
|
|
7398
7525
|
var service_default = GitService;
|
|
7399
7526
|
|
|
7400
7527
|
// src/source.ts
|
|
7401
|
-
var
|
|
7402
|
-
var
|
|
7528
|
+
var import_coc14 = __toModule(require("coc.nvim"));
|
|
7529
|
+
var import_safe4 = __toModule(require_safe());
|
|
7403
7530
|
function byteSlice(content, start, end) {
|
|
7404
7531
|
let buf = Buffer.from(content, "utf8");
|
|
7405
7532
|
return buf.slice(start, end).toString("utf8");
|
|
7406
7533
|
}
|
|
7407
7534
|
var issuesMap = new Map();
|
|
7408
7535
|
function issuesFiletypes() {
|
|
7409
|
-
return
|
|
7536
|
+
return import_coc14.workspace.getConfiguration().get("coc.source.issues.filetypes");
|
|
7410
7537
|
}
|
|
7411
7538
|
function getOrganizationNameAndRepoNameFromGitHubRemoteUrl(remoteUrl) {
|
|
7412
7539
|
try {
|
|
@@ -7445,7 +7572,7 @@ function renderWord(issue, issueFormat) {
|
|
|
7445
7572
|
}
|
|
7446
7573
|
function addSource(context, resolver) {
|
|
7447
7574
|
let {subscriptions, logger} = context;
|
|
7448
|
-
let statusItem =
|
|
7575
|
+
let statusItem = import_coc14.window.createStatusBarItem(0, {progress: true});
|
|
7449
7576
|
statusItem.text = "loading issues";
|
|
7450
7577
|
let statusItemCounter = 0;
|
|
7451
7578
|
function onStartLoading() {
|
|
@@ -7488,7 +7615,7 @@ function addSource(context, resolver) {
|
|
|
7488
7615
|
const pageUri = `${uri}&page=${pageIndex}`;
|
|
7489
7616
|
pageIndex++;
|
|
7490
7617
|
try {
|
|
7491
|
-
let info = await
|
|
7618
|
+
let info = await import_coc14.fetch(pageUri, {headers: {"Private-Token": token}});
|
|
7492
7619
|
if (!info.length) {
|
|
7493
7620
|
break;
|
|
7494
7621
|
}
|
|
@@ -7524,7 +7651,7 @@ function addSource(context, resolver) {
|
|
|
7524
7651
|
let page_uri = `${uri}&page=${page_idx}`;
|
|
7525
7652
|
page_idx++;
|
|
7526
7653
|
try {
|
|
7527
|
-
let info = await
|
|
7654
|
+
let info = await import_coc14.fetch(page_uri, {headers});
|
|
7528
7655
|
if (info.length == 0) {
|
|
7529
7656
|
break;
|
|
7530
7657
|
}
|
|
@@ -7549,7 +7676,7 @@ function addSource(context, resolver) {
|
|
|
7549
7676
|
return issues;
|
|
7550
7677
|
}
|
|
7551
7678
|
async function loadIssues(root) {
|
|
7552
|
-
let config =
|
|
7679
|
+
let config = import_coc14.workspace.getConfiguration("git");
|
|
7553
7680
|
const issueSources = (await safeRun(`git config --get coc-git.issuesources`, {cwd: root}) || "").trim();
|
|
7554
7681
|
if (issueSources) {
|
|
7555
7682
|
return Array.prototype.concat.apply([], await Promise.all(issueSources.split(",").map((issueSource) => {
|
|
@@ -7592,14 +7719,14 @@ function addSource(context, resolver) {
|
|
|
7592
7719
|
}
|
|
7593
7720
|
}).catch(onError);
|
|
7594
7721
|
};
|
|
7595
|
-
for (let doc of
|
|
7722
|
+
for (let doc of import_coc14.workspace.documents) {
|
|
7596
7723
|
if (issuesFiletypes().includes(doc.filetype)) {
|
|
7597
7724
|
loadIssuesFromDocument(doc);
|
|
7598
7725
|
}
|
|
7599
7726
|
}
|
|
7600
|
-
|
|
7727
|
+
import_coc14.workspace.onDidOpenTextDocument(async (e) => {
|
|
7601
7728
|
if (issuesFiletypes().includes(e.languageId)) {
|
|
7602
|
-
let doc =
|
|
7729
|
+
let doc = import_coc14.workspace.getDocument(e.uri);
|
|
7603
7730
|
loadIssuesFromDocument(doc);
|
|
7604
7731
|
}
|
|
7605
7732
|
}, null, subscriptions);
|
|
@@ -7608,7 +7735,7 @@ function addSource(context, resolver) {
|
|
|
7608
7735
|
async doComplete(opt) {
|
|
7609
7736
|
let pre = byteSlice(opt.line, 0, opt.colnr - 1);
|
|
7610
7737
|
if (pre && pre.endsWith("#")) {
|
|
7611
|
-
const config =
|
|
7738
|
+
const config = import_coc14.workspace.getConfiguration("git");
|
|
7612
7739
|
const issueFormat = config.get("issueFormat", "#%i");
|
|
7613
7740
|
let issues = issuesMap.get(opt.bufnr);
|
|
7614
7741
|
if (!issues || issues.length == 0)
|
|
@@ -7634,14 +7761,14 @@ function addSource(context, resolver) {
|
|
|
7634
7761
|
};
|
|
7635
7762
|
}
|
|
7636
7763
|
};
|
|
7637
|
-
subscriptions.push(
|
|
7764
|
+
subscriptions.push(import_coc14.sources.createSource(source));
|
|
7638
7765
|
let list = {
|
|
7639
7766
|
name: "issues",
|
|
7640
7767
|
actions: [{
|
|
7641
7768
|
name: "open",
|
|
7642
7769
|
execute: async (item) => {
|
|
7643
7770
|
let {url} = item.data;
|
|
7644
|
-
await
|
|
7771
|
+
await import_coc14.workspace.openResource(url);
|
|
7645
7772
|
},
|
|
7646
7773
|
multiple: false
|
|
7647
7774
|
}, {
|
|
@@ -7651,7 +7778,7 @@ function addSource(context, resolver) {
|
|
|
7651
7778
|
let {body, id} = item.data;
|
|
7652
7779
|
let lines = body.split(/\r?\n/);
|
|
7653
7780
|
let mod = context2.options.position == "top" ? "below" : "above";
|
|
7654
|
-
let {nvim} =
|
|
7781
|
+
let {nvim} = import_coc14.workspace;
|
|
7655
7782
|
nvim.pauseNotification();
|
|
7656
7783
|
nvim.command("pclose", true);
|
|
7657
7784
|
nvim.command(`${mod} ${lines.length}sp +setl\\ previewwindow [issue ${id}]`, true);
|
|
@@ -7670,132 +7797,142 @@ function addSource(context, resolver) {
|
|
|
7670
7797
|
description: "issues on github/gitlab",
|
|
7671
7798
|
loadItems: async (context2) => {
|
|
7672
7799
|
let buf = await context2.window.buffer;
|
|
7673
|
-
let root = await resolver.resolveGitRoot(
|
|
7800
|
+
let root = await resolver.resolveGitRoot(import_coc14.workspace.getDocument(buf.id));
|
|
7674
7801
|
if (!root)
|
|
7675
7802
|
return [];
|
|
7676
7803
|
let issues = await loadIssues(root);
|
|
7677
7804
|
return issues.map((o) => {
|
|
7678
7805
|
return {
|
|
7679
|
-
label: `${
|
|
7806
|
+
label: `${import_safe4.default.red("#" + o.id.toFixed(0))} ${o.title} (${import_safe4.default.green(o.createAt.toUTCString())}) <${import_safe4.default.blue(o.creator)}>`,
|
|
7680
7807
|
data: {id: o.id, url: o.url, body: o.body}
|
|
7681
7808
|
};
|
|
7682
7809
|
});
|
|
7683
7810
|
}
|
|
7684
7811
|
};
|
|
7685
|
-
subscriptions.push(
|
|
7812
|
+
subscriptions.push(import_coc14.listManager.registerList(list));
|
|
7686
7813
|
}
|
|
7687
7814
|
|
|
7688
7815
|
// src/index.ts
|
|
7689
7816
|
async function activate(context) {
|
|
7690
|
-
const config =
|
|
7817
|
+
const config = import_coc15.workspace.getConfiguration("git");
|
|
7691
7818
|
const {subscriptions} = context;
|
|
7692
7819
|
let gitInfo;
|
|
7693
7820
|
try {
|
|
7694
7821
|
let pathHint = config.get("command");
|
|
7695
7822
|
gitInfo = await findGit(pathHint, (path8) => context.logger.info(`Looking for git in: ${path8}`));
|
|
7696
7823
|
} catch (e) {
|
|
7697
|
-
|
|
7824
|
+
import_coc15.window.showMessage("git command required for coc-git", "error");
|
|
7698
7825
|
return;
|
|
7699
7826
|
}
|
|
7700
|
-
const virtualTextSrcId = await
|
|
7701
|
-
const conflictSrcId = await
|
|
7702
|
-
const {nvim} =
|
|
7827
|
+
const virtualTextSrcId = await import_coc15.workspace.nvim.createNamespace("coc-git-virtual");
|
|
7828
|
+
const conflictSrcId = await import_coc15.workspace.nvim.createNamespace("coc-git-conflicts");
|
|
7829
|
+
const {nvim} = import_coc15.workspace;
|
|
7703
7830
|
const service = new service_default(gitInfo);
|
|
7704
7831
|
const manager = new manager_default(nvim, service, virtualTextSrcId, conflictSrcId);
|
|
7705
7832
|
subscriptions.push(manager);
|
|
7706
7833
|
addSource(context, service.resolver);
|
|
7707
|
-
subscriptions.push(
|
|
7834
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.refresh", () => {
|
|
7708
7835
|
manager.refresh();
|
|
7709
7836
|
}));
|
|
7710
|
-
subscriptions.push(
|
|
7837
|
+
subscriptions.push(import_coc15.workspace.registerKeymap(["n"], "git-nextchunk", async () => {
|
|
7711
7838
|
await manager.nextChunk();
|
|
7712
7839
|
}, {sync: false}));
|
|
7713
|
-
subscriptions.push(
|
|
7840
|
+
subscriptions.push(import_coc15.workspace.registerKeymap(["n"], "git-prevchunk", async () => {
|
|
7714
7841
|
await manager.prevChunk();
|
|
7715
7842
|
}, {sync: false}));
|
|
7716
|
-
subscriptions.push(
|
|
7843
|
+
subscriptions.push(import_coc15.workspace.registerKeymap(["n"], "git-nextconflict", async () => {
|
|
7717
7844
|
await manager.nextConflict();
|
|
7718
7845
|
}, {sync: false}));
|
|
7719
|
-
subscriptions.push(
|
|
7846
|
+
subscriptions.push(import_coc15.workspace.registerKeymap(["n"], "git-prevconflict", async () => {
|
|
7720
7847
|
await manager.prevConflict();
|
|
7721
7848
|
}, {sync: false}));
|
|
7722
|
-
subscriptions.push(
|
|
7849
|
+
subscriptions.push(import_coc15.workspace.registerKeymap(["n"], "git-keepcurrent", async () => {
|
|
7723
7850
|
await manager.keepCurrent();
|
|
7724
7851
|
}, {sync: false}));
|
|
7725
|
-
subscriptions.push(
|
|
7852
|
+
subscriptions.push(import_coc15.workspace.registerKeymap(["n"], "git-keepincoming", async () => {
|
|
7726
7853
|
await manager.keepIncoming();
|
|
7727
7854
|
}, {sync: false}));
|
|
7728
|
-
subscriptions.push(
|
|
7855
|
+
subscriptions.push(import_coc15.workspace.registerKeymap(["n"], "git-keepboth", async () => {
|
|
7729
7856
|
await manager.keepBoth();
|
|
7730
7857
|
}, {sync: false}));
|
|
7731
|
-
subscriptions.push(
|
|
7858
|
+
subscriptions.push(import_coc15.workspace.registerKeymap(["n"], "git-chunkinfo", async () => {
|
|
7732
7859
|
await manager.chunkInfo();
|
|
7733
7860
|
}, {sync: false}));
|
|
7734
|
-
subscriptions.push(
|
|
7861
|
+
subscriptions.push(import_coc15.workspace.registerKeymap(["n"], "git-commit", async () => {
|
|
7735
7862
|
await manager.showCommit();
|
|
7736
7863
|
}, {sync: false}));
|
|
7737
|
-
subscriptions.push(
|
|
7864
|
+
subscriptions.push(import_coc15.workspace.registerKeymap(["n"], "git-showblamedoc", async () => {
|
|
7865
|
+
await manager.showBlameDoc();
|
|
7866
|
+
}, {sync: false}));
|
|
7867
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.keepCurrent", async () => {
|
|
7738
7868
|
await manager.keepCurrent();
|
|
7739
7869
|
}));
|
|
7740
|
-
subscriptions.push(
|
|
7870
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.keepIncoming", async () => {
|
|
7741
7871
|
await manager.keepIncoming();
|
|
7742
7872
|
}));
|
|
7743
|
-
subscriptions.push(
|
|
7873
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.keepBoth", async () => {
|
|
7744
7874
|
await manager.keepBoth();
|
|
7745
7875
|
}));
|
|
7746
|
-
subscriptions.push(
|
|
7876
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.chunkInfo", async () => {
|
|
7747
7877
|
await manager.chunkInfo();
|
|
7748
7878
|
}));
|
|
7749
|
-
subscriptions.push(
|
|
7879
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.chunkStage", async () => {
|
|
7750
7880
|
await manager.chunkStage();
|
|
7751
7881
|
}));
|
|
7752
|
-
subscriptions.push(
|
|
7882
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.chunkUnstage", async () => {
|
|
7753
7883
|
await manager.chunkUnstage();
|
|
7754
7884
|
}));
|
|
7755
|
-
subscriptions.push(
|
|
7885
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.chunkUndo", async () => {
|
|
7756
7886
|
await manager.chunkUndo();
|
|
7757
7887
|
}));
|
|
7758
|
-
subscriptions.push(
|
|
7888
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.showCommit", async () => {
|
|
7759
7889
|
await manager.showCommit();
|
|
7760
7890
|
}));
|
|
7761
|
-
subscriptions.push(
|
|
7891
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.browserOpen", async () => {
|
|
7762
7892
|
await manager.browser();
|
|
7763
7893
|
}));
|
|
7764
|
-
subscriptions.push(
|
|
7894
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.copyUrl", async (...args) => {
|
|
7765
7895
|
await manager.browser("copy", args);
|
|
7766
7896
|
}));
|
|
7767
|
-
subscriptions.push(
|
|
7897
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.copyPermalink", async (...args) => {
|
|
7898
|
+
await manager.browser("copy", args, true);
|
|
7899
|
+
}));
|
|
7900
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.push", async (...args) => {
|
|
7768
7901
|
await manager.push(args);
|
|
7769
7902
|
}));
|
|
7770
|
-
subscriptions.push(
|
|
7903
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.diffCached", async () => {
|
|
7771
7904
|
await manager.diffCached();
|
|
7772
7905
|
}));
|
|
7773
|
-
subscriptions.push(
|
|
7906
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.toggleGutters", async () => {
|
|
7774
7907
|
await manager.toggleGutters();
|
|
7775
7908
|
}));
|
|
7776
|
-
subscriptions.push(
|
|
7909
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.foldUnchanged", async () => {
|
|
7777
7910
|
await manager.toggleFold();
|
|
7778
7911
|
}));
|
|
7779
|
-
subscriptions.push(
|
|
7780
|
-
|
|
7781
|
-
|
|
7782
|
-
subscriptions.push(
|
|
7783
|
-
subscriptions.push(
|
|
7784
|
-
subscriptions.push(
|
|
7912
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.showBlameDoc", async () => {
|
|
7913
|
+
await manager.showBlameDoc();
|
|
7914
|
+
}));
|
|
7915
|
+
subscriptions.push(import_coc15.listManager.registerList(new gstatus_default(nvim, manager)));
|
|
7916
|
+
subscriptions.push(import_coc15.listManager.registerList(new branches_default(nvim, manager)));
|
|
7917
|
+
subscriptions.push(import_coc15.listManager.registerList(new commits_default(nvim, manager)));
|
|
7918
|
+
subscriptions.push(import_coc15.listManager.registerList(new bcommits_default(nvim, manager)));
|
|
7919
|
+
subscriptions.push(import_coc15.listManager.registerList(new gfiles_default(nvim, manager)));
|
|
7920
|
+
subscriptions.push(import_coc15.listManager.registerList(new gchunks_default(nvim, manager)));
|
|
7921
|
+
subscriptions.push(import_coc15.languages.registerCompletionItemProvider("semantic-commit", "Commit", config.get("semanticCommit.filetypes"), {
|
|
7785
7922
|
provideCompletionItems: async (document, position) => {
|
|
7786
7923
|
if (position.line !== 0) {
|
|
7787
7924
|
return [];
|
|
7788
7925
|
}
|
|
7789
|
-
const text = document.getText(
|
|
7926
|
+
const text = document.getText(import_coc15.Range.create(import_coc15.Position.create(position.line, 0), position));
|
|
7790
7927
|
if (/^[a-z]*$/.test(text)) {
|
|
7791
7928
|
const scope = config.get("semanticCommit.scope");
|
|
7792
7929
|
const text2 = scope ? "(${1:scope}): ${2:commit}" : ": ${1:commit}";
|
|
7793
7930
|
return DEFAULT_TYPES.map((o) => {
|
|
7794
7931
|
return {
|
|
7795
7932
|
label: o.value,
|
|
7796
|
-
kind:
|
|
7933
|
+
kind: import_coc15.CompletionItemKind.Snippet,
|
|
7797
7934
|
documentation: {kind: "plaintext", value: o.name},
|
|
7798
|
-
insertTextFormat:
|
|
7935
|
+
insertTextFormat: import_coc15.InsertTextFormat.Snippet,
|
|
7799
7936
|
insertText: o.value + text2 + "\n\n"
|
|
7800
7937
|
};
|
|
7801
7938
|
});
|
|
@@ -7803,13 +7940,13 @@ async function activate(context) {
|
|
|
7803
7940
|
return [];
|
|
7804
7941
|
}
|
|
7805
7942
|
}));
|
|
7806
|
-
subscriptions.push(
|
|
7943
|
+
subscriptions.push(import_coc15.workspace.registerKeymap(["o", "x"], "git-chunk-inner", async () => {
|
|
7807
7944
|
let diff = await manager.getCurrentChunk();
|
|
7808
7945
|
if (!diff)
|
|
7809
7946
|
return;
|
|
7810
7947
|
await nvim.command(`normal! ${diff.start}GV${diff.end}G`);
|
|
7811
7948
|
}, {sync: true, silent: true}));
|
|
7812
|
-
subscriptions.push(
|
|
7949
|
+
subscriptions.push(import_coc15.workspace.registerKeymap(["o", "x"], "git-chunk-outer", async () => {
|
|
7813
7950
|
let diff = await manager.getCurrentChunk();
|
|
7814
7951
|
if (!diff)
|
|
7815
7952
|
return;
|