coc-git 2.4.10 → 2.5.1
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/lib/index.js +356 -216
- package/package.json +10 -1
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,11 +4924,11 @@ 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", [
|
|
4931
|
+
nvim.call("win_gotoid", [window10.id], true);
|
|
4932
4932
|
nvim.command(`exe "tabe ".fnameescape('(${commit}) ${file}')`, true);
|
|
4933
4933
|
nvim.call("append", [0, lines], true);
|
|
4934
4934
|
nvim.command("normal! Gdd", true);
|
|
@@ -5249,7 +5249,7 @@ var Commits = class extends import_coc4.BasicList {
|
|
|
5249
5249
|
} else {
|
|
5250
5250
|
arg = `${list[1].data.commit} ${list[0].data.commit}`;
|
|
5251
5251
|
}
|
|
5252
|
-
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});
|
|
5253
5253
|
let lines = content.replace(/\n$/, "").split("\n");
|
|
5254
5254
|
nvim.pauseNotification();
|
|
5255
5255
|
nvim.command(`tabe [diff ${arg}]`, true);
|
|
@@ -5273,7 +5273,7 @@ var Commits = class extends import_coc4.BasicList {
|
|
|
5273
5273
|
} else {
|
|
5274
5274
|
arg = `${list[1].data.commit} ${list[0].data.commit}`;
|
|
5275
5275
|
}
|
|
5276
|
-
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});
|
|
5277
5277
|
let lines = content.replace(/\n$/, "").split("\n");
|
|
5278
5278
|
let winid = context.listWindow.id;
|
|
5279
5279
|
let mod = context.options.position == "tab" ? "below" : "above";
|
|
@@ -5369,7 +5369,7 @@ var Gfiles = class extends import_coc5.BasicList {
|
|
|
5369
5369
|
let {root, sha, filepath, branch} = item.data;
|
|
5370
5370
|
if (!sha)
|
|
5371
5371
|
return;
|
|
5372
|
-
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});
|
|
5373
5373
|
let lines = content.replace(/\n$/, "").split("\n");
|
|
5374
5374
|
await this.preview({
|
|
5375
5375
|
lines,
|
|
@@ -5501,7 +5501,7 @@ var GStatus = class extends import_coc6.BasicList {
|
|
|
5501
5501
|
}, context);
|
|
5502
5502
|
return;
|
|
5503
5503
|
}
|
|
5504
|
-
let args = ["--no-pager", "diff"];
|
|
5504
|
+
let args = ["--no-pager", "diff", "--no-ext-diff"];
|
|
5505
5505
|
if (index_symbol == "M" && tree_symbol != "M") {
|
|
5506
5506
|
args.push("--cached");
|
|
5507
5507
|
}
|
|
@@ -5529,6 +5529,9 @@ var GStatus = class extends import_coc6.BasicList {
|
|
|
5529
5529
|
throw new Error(`Can't resolve git root.`);
|
|
5530
5530
|
return;
|
|
5531
5531
|
}
|
|
5532
|
+
if (this.manager.gstatusSaveBeforeOpen) {
|
|
5533
|
+
await this.nvim.command(`wa`);
|
|
5534
|
+
}
|
|
5532
5535
|
let output = await runCommand(`git status --porcelain -uall ${context.args.join(" ")}`, {cwd: root});
|
|
5533
5536
|
output = output.replace(/\s+$/, "");
|
|
5534
5537
|
if (!output)
|
|
@@ -5557,19 +5560,90 @@ var GStatus = class extends import_coc6.BasicList {
|
|
|
5557
5560
|
};
|
|
5558
5561
|
var gstatus_default = GStatus;
|
|
5559
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
|
+
|
|
5560
5634
|
// src/manager.ts
|
|
5561
|
-
var
|
|
5635
|
+
var import_coc9 = __toModule(require("coc.nvim"));
|
|
5562
5636
|
var import_debounce = __toModule(require_debounce());
|
|
5563
5637
|
|
|
5564
5638
|
// src/model/status.ts
|
|
5565
|
-
var
|
|
5639
|
+
var import_coc8 = __toModule(require("coc.nvim"));
|
|
5566
5640
|
var GitStatus = class {
|
|
5567
5641
|
constructor(service) {
|
|
5568
5642
|
this.service = service;
|
|
5569
5643
|
this.disposables = [];
|
|
5570
5644
|
this._enabled = false;
|
|
5571
|
-
this.mutex = new
|
|
5572
|
-
let config =
|
|
5645
|
+
this.mutex = new import_coc8.Mutex();
|
|
5646
|
+
let config = import_coc8.workspace.getConfiguration("git");
|
|
5573
5647
|
this._enabled = config.get("enableGlobalStatus", true);
|
|
5574
5648
|
this.branchCharacter = config.get("branchCharacter", "");
|
|
5575
5649
|
this.characters = {
|
|
@@ -5578,10 +5652,10 @@ var GitStatus = class {
|
|
|
5578
5652
|
stagedDecorator: config.get("stagedDecorator"),
|
|
5579
5653
|
untrackedDecorator: config.get("untrackedDecorator")
|
|
5580
5654
|
};
|
|
5581
|
-
|
|
5582
|
-
|
|
5655
|
+
import_coc8.events.on("BufEnter", this.refresh, this, this.disposables);
|
|
5656
|
+
import_coc8.events.on("FocusGained", this.refresh, this, this.disposables);
|
|
5583
5657
|
let timer;
|
|
5584
|
-
|
|
5658
|
+
import_coc8.events.on("BufWritePost", () => {
|
|
5585
5659
|
timer = setTimeout(() => {
|
|
5586
5660
|
this.refresh();
|
|
5587
5661
|
}, 300);
|
|
@@ -5616,14 +5690,14 @@ var GitStatus = class {
|
|
|
5616
5690
|
if (this.gitStatus == status)
|
|
5617
5691
|
return;
|
|
5618
5692
|
this.gitStatus = status;
|
|
5619
|
-
let {nvim} =
|
|
5693
|
+
let {nvim} = import_coc8.workspace;
|
|
5620
5694
|
nvim.pauseNotification();
|
|
5621
5695
|
nvim.setVar("coc_git_status", status, true);
|
|
5622
5696
|
nvim.call("coc#util#do_autocmd", ["CocGitStatusChange"], true);
|
|
5623
5697
|
nvim.resumeNotification(false, true);
|
|
5624
5698
|
}
|
|
5625
5699
|
dispose() {
|
|
5626
|
-
|
|
5700
|
+
import_coc8.disposeAll(this.disposables);
|
|
5627
5701
|
}
|
|
5628
5702
|
};
|
|
5629
5703
|
var status_default = GitStatus;
|
|
@@ -5659,12 +5733,12 @@ var DocumentManager = class {
|
|
|
5659
5733
|
this.disposables = [];
|
|
5660
5734
|
this.defined = false;
|
|
5661
5735
|
this.loadConfiguration();
|
|
5662
|
-
|
|
5736
|
+
import_coc9.workspace.onDidChangeConfiguration(this.loadConfiguration, this, this.disposables);
|
|
5663
5737
|
this.gitStatus = new status_default(service);
|
|
5664
5738
|
const createBuffer = (doc) => {
|
|
5665
5739
|
let {uri} = doc;
|
|
5666
5740
|
service.createBuffer(doc, this.config).then((buf) => {
|
|
5667
|
-
if (!buf ||
|
|
5741
|
+
if (!buf || import_coc9.workspace.getDocument(uri) == null)
|
|
5668
5742
|
return;
|
|
5669
5743
|
this.defineSigns().catch((e) => {
|
|
5670
5744
|
console.error(e.message);
|
|
@@ -5672,43 +5746,43 @@ var DocumentManager = class {
|
|
|
5672
5746
|
this.buffers.set(doc.bufnr, buf);
|
|
5673
5747
|
});
|
|
5674
5748
|
};
|
|
5675
|
-
for (let doc of
|
|
5749
|
+
for (let doc of import_coc9.workspace.documents) {
|
|
5676
5750
|
createBuffer(doc);
|
|
5677
5751
|
}
|
|
5678
|
-
|
|
5679
|
-
createBuffer(
|
|
5752
|
+
import_coc9.workspace.onDidOpenTextDocument(async (e) => {
|
|
5753
|
+
createBuffer(import_coc9.workspace.getDocument(e.bufnr));
|
|
5680
5754
|
}, null, this.disposables);
|
|
5681
|
-
|
|
5755
|
+
import_coc9.workspace.onDidChangeTextDocument(async (e) => {
|
|
5682
5756
|
let buf = this.buffers.get(e.bufnr);
|
|
5683
5757
|
if (buf)
|
|
5684
5758
|
buf.refresh();
|
|
5685
5759
|
}, null, this.disposables);
|
|
5686
|
-
|
|
5760
|
+
import_coc9.workspace.onDidCloseTextDocument((e) => {
|
|
5687
5761
|
let buf = this.buffers.get(e.bufnr);
|
|
5688
5762
|
if (buf)
|
|
5689
5763
|
buf.dispose();
|
|
5690
5764
|
this.buffers.delete(e.bufnr);
|
|
5691
5765
|
this.service.resolver.delete(e.uri);
|
|
5692
5766
|
}, null, this.disposables);
|
|
5693
|
-
|
|
5767
|
+
import_coc9.events.on("CursorMoved", import_debounce.default(async (bufnr, cursor) => {
|
|
5694
5768
|
let buf = this.buffers.get(bufnr);
|
|
5695
5769
|
if (buf)
|
|
5696
5770
|
await buf.showBlameInfo(cursor[0]);
|
|
5697
5771
|
}, 100), null, this.disposables);
|
|
5698
|
-
|
|
5772
|
+
import_coc9.events.on("BufWritePre", (bufnr) => {
|
|
5699
5773
|
if (!this.enableGutters || this.config.realtimeGutters)
|
|
5700
5774
|
return;
|
|
5701
5775
|
let buf = this.buffers.get(bufnr);
|
|
5702
5776
|
if (buf)
|
|
5703
5777
|
buf.updateGutters();
|
|
5704
5778
|
}, null, this.disposables);
|
|
5705
|
-
|
|
5779
|
+
import_coc9.events.on("FocusGained", async () => {
|
|
5706
5780
|
let bufnr = await nvim.call("bufnr", ["%"]);
|
|
5707
5781
|
let buf = this.buffers.get(bufnr);
|
|
5708
5782
|
if (buf)
|
|
5709
5783
|
buf.refresh();
|
|
5710
5784
|
}, null, this.disposables);
|
|
5711
|
-
|
|
5785
|
+
import_coc9.events.on("BufEnter", (bufnr) => {
|
|
5712
5786
|
let buf = this.buffers.get(bufnr);
|
|
5713
5787
|
if (buf)
|
|
5714
5788
|
buf.refresh();
|
|
@@ -5719,7 +5793,7 @@ var DocumentManager = class {
|
|
|
5719
5793
|
return;
|
|
5720
5794
|
this.defined = true;
|
|
5721
5795
|
let {nvim} = this;
|
|
5722
|
-
const config =
|
|
5796
|
+
const config = import_coc9.workspace.getConfiguration("git");
|
|
5723
5797
|
let items = ["Changed", "Added", "Removed", "TopRemoved", "ChangeRemoved"];
|
|
5724
5798
|
nvim.pauseNotification();
|
|
5725
5799
|
for (let item of items) {
|
|
@@ -5734,13 +5808,13 @@ var DocumentManager = class {
|
|
|
5734
5808
|
loadConfiguration(e) {
|
|
5735
5809
|
if (e && !e.affectsConfiguration("git"))
|
|
5736
5810
|
return;
|
|
5737
|
-
let config =
|
|
5811
|
+
let config = import_coc9.workspace.getConfiguration("git");
|
|
5738
5812
|
let obj = {
|
|
5739
5813
|
remoteName: config.get("remoteName", "origin"),
|
|
5740
5814
|
diffRevision: config.get("diffRevision", ""),
|
|
5741
5815
|
issueFormat: config.get("issueFormat", "#%i"),
|
|
5742
5816
|
virtualTextPrefix: config.get("virtualTextPrefix", " "),
|
|
5743
|
-
addGBlameToVirtualText:
|
|
5817
|
+
addGBlameToVirtualText: import_coc9.workspace.nvim.hasFunction("nvim_buf_set_virtual_text") && config.get("addGBlameToVirtualText", false),
|
|
5744
5818
|
addGBlameToBufferVar: config.get("addGBlameToBufferVar", false),
|
|
5745
5819
|
blameUseRealTime: config.get("blameUseRealTime", false),
|
|
5746
5820
|
enableGutters: config.get("enableGutters", true),
|
|
@@ -5774,6 +5848,9 @@ var DocumentManager = class {
|
|
|
5774
5848
|
currentHlGroup: config.get("conflict.current.hlGroup", "DiffChange"),
|
|
5775
5849
|
incomingHlGroup: config.get("conflict.incoming.hlGroup", "DiffAdd")
|
|
5776
5850
|
},
|
|
5851
|
+
gstatus: {
|
|
5852
|
+
saveBeforeOpen: config.get("gstatus.saveBeforeOpen", false)
|
|
5853
|
+
},
|
|
5777
5854
|
virtualTextSrcId: this.virtualTextSrcId,
|
|
5778
5855
|
conflictSrcId: this.conflictSrcId
|
|
5779
5856
|
};
|
|
@@ -5782,12 +5859,15 @@ var DocumentManager = class {
|
|
|
5782
5859
|
get enableGutters() {
|
|
5783
5860
|
return this.config.enableGutters;
|
|
5784
5861
|
}
|
|
5862
|
+
get gstatusSaveBeforeOpen() {
|
|
5863
|
+
return this.config.gstatus.saveBeforeOpen;
|
|
5864
|
+
}
|
|
5785
5865
|
get git() {
|
|
5786
5866
|
return this.service.git;
|
|
5787
5867
|
}
|
|
5788
5868
|
async toggleGutters() {
|
|
5789
5869
|
let enabled = this.enableGutters;
|
|
5790
|
-
let config =
|
|
5870
|
+
let config = import_coc9.workspace.getConfiguration("git");
|
|
5791
5871
|
config.update("enableGutters", !enabled, true);
|
|
5792
5872
|
for (let buf of this.buffers.values()) {
|
|
5793
5873
|
await buf.toggleGutters(!enabled);
|
|
@@ -5799,7 +5879,7 @@ var DocumentManager = class {
|
|
|
5799
5879
|
await buf.toggleFold();
|
|
5800
5880
|
}
|
|
5801
5881
|
async resolveGitRootFromBufferOrCwd(bufnr) {
|
|
5802
|
-
let doc =
|
|
5882
|
+
let doc = import_coc9.workspace.getDocument(bufnr);
|
|
5803
5883
|
let root;
|
|
5804
5884
|
let {resolver} = this.service;
|
|
5805
5885
|
if (doc) {
|
|
@@ -5879,6 +5959,12 @@ var DocumentManager = class {
|
|
|
5879
5959
|
if (buf)
|
|
5880
5960
|
await buf.showCommit();
|
|
5881
5961
|
}
|
|
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
|
+
}
|
|
5882
5968
|
async browser(action = "open", range, permalink = false) {
|
|
5883
5969
|
let buf = await this.buffer;
|
|
5884
5970
|
if (buf)
|
|
@@ -5895,36 +5981,36 @@ var DocumentManager = class {
|
|
|
5895
5981
|
}
|
|
5896
5982
|
}
|
|
5897
5983
|
async push(args) {
|
|
5898
|
-
let bufnr = await
|
|
5984
|
+
let bufnr = await import_coc9.workspace.nvim.call("bufnr", "%");
|
|
5899
5985
|
let root = await this.resolveGitRootFromBufferOrCwd(bufnr);
|
|
5900
5986
|
let extra = this.config.pushArguments;
|
|
5901
5987
|
if (!root) {
|
|
5902
|
-
|
|
5988
|
+
import_coc9.window.showMessage(`not belongs to git repository.`, "warning");
|
|
5903
5989
|
return;
|
|
5904
5990
|
}
|
|
5905
5991
|
if (args && args.length) {
|
|
5906
|
-
await
|
|
5992
|
+
await import_coc9.window.runTerminalCommand(`git push ${[...args, ...extra].join(" ")}`, root, true);
|
|
5907
5993
|
return;
|
|
5908
5994
|
}
|
|
5909
5995
|
let repo = this.service.getRepoFromRoot(root);
|
|
5910
5996
|
let output = await repo.safeRun(["remote"]);
|
|
5911
5997
|
let remote = output.trim().split(/\r?\n/)[0];
|
|
5912
5998
|
if (!remote) {
|
|
5913
|
-
|
|
5999
|
+
import_coc9.window.showMessage(`remote not found`, "warning");
|
|
5914
6000
|
return;
|
|
5915
6001
|
}
|
|
5916
6002
|
output = await repo.safeRun(["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
5917
6003
|
if (!output) {
|
|
5918
|
-
|
|
6004
|
+
import_coc9.window.showMessage(`current branch not found`, "warning");
|
|
5919
6005
|
return;
|
|
5920
6006
|
}
|
|
5921
|
-
await
|
|
6007
|
+
await import_coc9.window.runTerminalCommand(`git push ${remote} ${output}${extra.length ? " " + extra.join(" ") : ""}`, root, true);
|
|
5922
6008
|
}
|
|
5923
6009
|
get buffer() {
|
|
5924
|
-
return
|
|
6010
|
+
return import_coc9.workspace.nvim.call("bufnr", "%").then((bufnr) => {
|
|
5925
6011
|
let buf = this.buffers.get(bufnr);
|
|
5926
6012
|
if (!buf)
|
|
5927
|
-
|
|
6013
|
+
import_coc9.window.showMessage(`Cant't resolve git repository for current buffer.`, "warning");
|
|
5928
6014
|
return buf;
|
|
5929
6015
|
});
|
|
5930
6016
|
}
|
|
@@ -5938,13 +6024,13 @@ var DocumentManager = class {
|
|
|
5938
6024
|
buf.dispose();
|
|
5939
6025
|
}
|
|
5940
6026
|
this.buffers.clear();
|
|
5941
|
-
|
|
6027
|
+
import_coc9.disposeAll(this.disposables);
|
|
5942
6028
|
}
|
|
5943
6029
|
};
|
|
5944
6030
|
var manager_default = DocumentManager;
|
|
5945
6031
|
|
|
5946
6032
|
// src/model/service.ts
|
|
5947
|
-
var
|
|
6033
|
+
var import_coc13 = __toModule(require("coc.nvim"));
|
|
5948
6034
|
|
|
5949
6035
|
// src/model/repo.ts
|
|
5950
6036
|
var import_fs2 = __toModule(require("fs"));
|
|
@@ -5959,7 +6045,7 @@ var Repo = class {
|
|
|
5959
6045
|
this.root = root;
|
|
5960
6046
|
}
|
|
5961
6047
|
async getStagedChunks(relpath) {
|
|
5962
|
-
let args = ["--no-pager", "diff", "-p", "-U0", "--no-color", "--staged"];
|
|
6048
|
+
let args = ["--no-pager", "diff", "--no-ext-diff", "-p", "-U0", "--no-color", "--staged"];
|
|
5963
6049
|
if (relpath)
|
|
5964
6050
|
args.push(toUnixSlash(relpath));
|
|
5965
6051
|
const result = await this.exec(args);
|
|
@@ -6108,7 +6194,7 @@ var Repo = class {
|
|
|
6108
6194
|
const currentFile = import_path4.default.join(import_os.default.tmpdir(), `coc-${uuid()}`);
|
|
6109
6195
|
await import_util6.default.promisify(import_fs2.default.writeFile)(stagedFile, staged + "\n", "utf8");
|
|
6110
6196
|
await import_util6.default.promisify(import_fs2.default.writeFile)(currentFile, content, "utf8");
|
|
6111
|
-
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)}`);
|
|
6112
6198
|
await import_util6.default.promisify(import_fs2.default.unlink)(stagedFile);
|
|
6113
6199
|
await import_util6.default.promisify(import_fs2.default.unlink)(currentFile);
|
|
6114
6200
|
if (!output)
|
|
@@ -6217,7 +6303,7 @@ function parseDiff(diffStr) {
|
|
|
6217
6303
|
|
|
6218
6304
|
// src/model/git.ts
|
|
6219
6305
|
var cp = __toModule(require("child_process"));
|
|
6220
|
-
var
|
|
6306
|
+
var import_coc10 = __toModule(require("coc.nvim"));
|
|
6221
6307
|
var import_iconv_lite = __toModule(require_lib());
|
|
6222
6308
|
var import_path5 = __toModule(require("path"));
|
|
6223
6309
|
var Git = class {
|
|
@@ -6294,11 +6380,11 @@ async function exec2(child, cancellationToken) {
|
|
|
6294
6380
|
const disposables = [];
|
|
6295
6381
|
const once = (ee, name, fn) => {
|
|
6296
6382
|
ee.once(name, fn);
|
|
6297
|
-
disposables.push(
|
|
6383
|
+
disposables.push(import_coc10.Disposable.create(() => ee.removeListener(name, fn)));
|
|
6298
6384
|
};
|
|
6299
6385
|
const on = (ee, name, fn) => {
|
|
6300
6386
|
ee.on(name, fn);
|
|
6301
|
-
disposables.push(
|
|
6387
|
+
disposables.push(import_coc10.Disposable.create(() => ee.removeListener(name, fn)));
|
|
6302
6388
|
};
|
|
6303
6389
|
let result = Promise.all([
|
|
6304
6390
|
new Promise((c, e) => {
|
|
@@ -6332,12 +6418,12 @@ async function exec2(child, cancellationToken) {
|
|
|
6332
6418
|
const [exitCode, stdout, stderr] = await result;
|
|
6333
6419
|
return {exitCode, stdout, stderr};
|
|
6334
6420
|
} finally {
|
|
6335
|
-
|
|
6421
|
+
import_coc10.disposeAll(disposables);
|
|
6336
6422
|
}
|
|
6337
6423
|
}
|
|
6338
6424
|
|
|
6339
6425
|
// src/model/resolver.ts
|
|
6340
|
-
var
|
|
6426
|
+
var import_coc11 = __toModule(require("coc.nvim"));
|
|
6341
6427
|
var import_fs3 = __toModule(require("fs"));
|
|
6342
6428
|
var import_path6 = __toModule(require("path"));
|
|
6343
6429
|
var import_util9 = __toModule(require("util"));
|
|
@@ -6348,7 +6434,7 @@ async function getRealPath(fullpath) {
|
|
|
6348
6434
|
} catch (e) {
|
|
6349
6435
|
if (e.message.includes("ENOENT")) {
|
|
6350
6436
|
try {
|
|
6351
|
-
resolved = await
|
|
6437
|
+
resolved = await import_coc11.workspace.nvim.call("expand", [fullpath]);
|
|
6352
6438
|
} catch (e2) {
|
|
6353
6439
|
}
|
|
6354
6440
|
}
|
|
@@ -6389,7 +6475,7 @@ var Resolver = class {
|
|
|
6389
6475
|
if (doc.buftype != "" || doc.schema != "file") {
|
|
6390
6476
|
return null;
|
|
6391
6477
|
}
|
|
6392
|
-
let fullpath = await getRealPath(
|
|
6478
|
+
let fullpath = await getRealPath(import_coc11.Uri.parse(uri).fsPath);
|
|
6393
6479
|
if (process.platform == "win32") {
|
|
6394
6480
|
fullpath = import_path6.default.win32.normalize(fullpath);
|
|
6395
6481
|
}
|
|
@@ -6418,12 +6504,12 @@ var Resolver = class {
|
|
|
6418
6504
|
return root;
|
|
6419
6505
|
}
|
|
6420
6506
|
async resolveRootFromCwd() {
|
|
6421
|
-
let parts =
|
|
6507
|
+
let parts = import_coc11.workspace.cwd.split(import_path6.default.sep);
|
|
6422
6508
|
let idx = parts.indexOf(".git");
|
|
6423
6509
|
if (idx !== -1)
|
|
6424
6510
|
return parts.slice(0, idx).join(import_path6.default.sep);
|
|
6425
6511
|
try {
|
|
6426
|
-
return await this.git.getRepositoryRoot(
|
|
6512
|
+
return await this.git.getRepositoryRoot(import_coc11.workspace.cwd);
|
|
6427
6513
|
} catch (e) {
|
|
6428
6514
|
}
|
|
6429
6515
|
return null;
|
|
@@ -6436,7 +6522,7 @@ var Resolver = class {
|
|
|
6436
6522
|
var resolver_default = Resolver;
|
|
6437
6523
|
|
|
6438
6524
|
// src/model/buffer.ts
|
|
6439
|
-
var
|
|
6525
|
+
var import_coc12 = __toModule(require("coc.nvim"));
|
|
6440
6526
|
|
|
6441
6527
|
// node_modules/timeago.js/esm/lang/en_US.js
|
|
6442
6528
|
var EN_US = ["second", "minute", "hour", "day", "week", "month", "year"];
|
|
@@ -6534,7 +6620,7 @@ var GitBuffer = class {
|
|
|
6534
6620
|
this.hasConflicts = false;
|
|
6535
6621
|
this.foldEnabled = false;
|
|
6536
6622
|
this._disposed = false;
|
|
6537
|
-
this.mutex = new
|
|
6623
|
+
this.mutex = new import_coc12.Mutex();
|
|
6538
6624
|
this.refresh = import_debounce2.default(() => {
|
|
6539
6625
|
this._refresh().catch((e) => {
|
|
6540
6626
|
channel.append(`[Error] ${e.message}`);
|
|
@@ -6579,7 +6665,7 @@ var GitBuffer = class {
|
|
|
6579
6665
|
});
|
|
6580
6666
|
}
|
|
6581
6667
|
async chunkUndo() {
|
|
6582
|
-
let line = await
|
|
6668
|
+
let line = await import_coc12.workspace.nvim.call("line", ".");
|
|
6583
6669
|
let diff = this.getChunk(line);
|
|
6584
6670
|
if (!diff)
|
|
6585
6671
|
return;
|
|
@@ -6599,10 +6685,10 @@ var GitBuffer = class {
|
|
|
6599
6685
|
}
|
|
6600
6686
|
async chunkStage() {
|
|
6601
6687
|
let relpath = toUnixSlash(this.relpath);
|
|
6602
|
-
let line = await
|
|
6688
|
+
let line = await import_coc12.workspace.nvim.call("line", ".");
|
|
6603
6689
|
let diff = this.getChunk(line);
|
|
6604
6690
|
if (!diff) {
|
|
6605
|
-
|
|
6691
|
+
import_coc12.window.showMessage("Not positioned in git chunk", "error");
|
|
6606
6692
|
return;
|
|
6607
6693
|
}
|
|
6608
6694
|
let head;
|
|
@@ -6630,7 +6716,7 @@ var GitBuffer = class {
|
|
|
6630
6716
|
}
|
|
6631
6717
|
}
|
|
6632
6718
|
async chunkUnstage() {
|
|
6633
|
-
let {nvim} =
|
|
6719
|
+
let {nvim} = import_coc12.workspace;
|
|
6634
6720
|
const {diffs} = this;
|
|
6635
6721
|
let line = await nvim.call("line", ".");
|
|
6636
6722
|
let adjust = 0;
|
|
@@ -6638,7 +6724,7 @@ var GitBuffer = class {
|
|
|
6638
6724
|
for (let diff of diffs) {
|
|
6639
6725
|
if (diff.end >= line) {
|
|
6640
6726
|
if (diff.start <= line && diff.changeType != ChangeType.Delete) {
|
|
6641
|
-
|
|
6727
|
+
import_coc12.window.showErrorMessage(`Current line contains unstaged change.`);
|
|
6642
6728
|
invalid = true;
|
|
6643
6729
|
}
|
|
6644
6730
|
break;
|
|
@@ -6652,12 +6738,12 @@ var GitBuffer = class {
|
|
|
6652
6738
|
let stagedDiff = await this.repo.getStagedChunks(this.relpath);
|
|
6653
6739
|
let chunks = Object.values(stagedDiff)[0];
|
|
6654
6740
|
if (!chunks.length) {
|
|
6655
|
-
|
|
6741
|
+
import_coc12.window.showErrorMessage(`Staged chunk not found`);
|
|
6656
6742
|
return;
|
|
6657
6743
|
}
|
|
6658
6744
|
let chunk = chunks.find((o) => o.add.lnum <= line && o.add.lnum + o.add.count >= line);
|
|
6659
6745
|
if (!chunk) {
|
|
6660
|
-
|
|
6746
|
+
import_coc12.window.showErrorMessage(`Unable to find staged chunk on current line`);
|
|
6661
6747
|
return;
|
|
6662
6748
|
}
|
|
6663
6749
|
this.channel.appendLine(`[Info] resolved chunk ${JSON.stringify(chunk, null, 2)}`);
|
|
@@ -6668,52 +6754,77 @@ var GitBuffer = class {
|
|
|
6668
6754
|
await this.git.exec(this.repo.root, ["apply", "--cached", "--unidiff-zero", "-"], {input: patch});
|
|
6669
6755
|
this.refresh();
|
|
6670
6756
|
} catch (e) {
|
|
6671
|
-
|
|
6757
|
+
import_coc12.window.showErrorMessage(`Unable to apply patch: ${e.message}`);
|
|
6672
6758
|
this.channel.appendLine(`[Error] ${e.message}`);
|
|
6673
6759
|
}
|
|
6674
6760
|
}
|
|
6675
6761
|
async nextChunk() {
|
|
6676
6762
|
const {diffs} = this;
|
|
6677
|
-
let {nvim} =
|
|
6763
|
+
let {nvim} = import_coc12.workspace;
|
|
6678
6764
|
if (!diffs || diffs.length == 0)
|
|
6679
6765
|
return;
|
|
6680
6766
|
let line = await nvim.call("line", ".");
|
|
6681
6767
|
for (let diff of diffs) {
|
|
6682
6768
|
if (diff.start > line) {
|
|
6683
|
-
await
|
|
6769
|
+
await import_coc12.window.moveTo({line: Math.max(diff.start - 1, 0), character: 0});
|
|
6684
6770
|
return;
|
|
6685
6771
|
}
|
|
6686
6772
|
}
|
|
6687
6773
|
if (await nvim.getOption("wrapscan")) {
|
|
6688
|
-
await
|
|
6774
|
+
await import_coc12.window.moveTo({line: Math.max(diffs[0].start - 1, 0), character: 0});
|
|
6689
6775
|
}
|
|
6690
6776
|
}
|
|
6691
6777
|
async prevChunk() {
|
|
6692
|
-
const {nvim} =
|
|
6778
|
+
const {nvim} = import_coc12.workspace;
|
|
6693
6779
|
let {diffs} = this;
|
|
6694
6780
|
let line = await nvim.call("line", ".");
|
|
6695
6781
|
if (!diffs || diffs.length == 0)
|
|
6696
6782
|
return;
|
|
6697
6783
|
for (let diff of diffs.slice().reverse()) {
|
|
6698
6784
|
if (diff.end < line) {
|
|
6699
|
-
await
|
|
6785
|
+
await import_coc12.window.moveTo({line: Math.max(diff.start - 1, 0), character: 0});
|
|
6700
6786
|
return;
|
|
6701
6787
|
}
|
|
6702
6788
|
}
|
|
6703
6789
|
if (await nvim.getOption("wrapscan")) {
|
|
6704
|
-
await
|
|
6790
|
+
await import_coc12.window.moveTo({line: Math.max(diffs[diffs.length - 1].start - 1, 0), character: 0});
|
|
6705
6791
|
}
|
|
6706
6792
|
}
|
|
6707
6793
|
async chunkInfo() {
|
|
6708
|
-
let line = await
|
|
6794
|
+
let line = await import_coc12.workspace.nvim.call("line", ".");
|
|
6709
6795
|
let diff = this.getChunk(line);
|
|
6710
6796
|
if (diff) {
|
|
6711
6797
|
let content = diff.head + "\n" + diff.lines.join("\n");
|
|
6712
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
|
+
}
|
|
6713
6824
|
}
|
|
6714
6825
|
}
|
|
6715
6826
|
async showBlameInfo(lnum) {
|
|
6716
|
-
let {nvim} =
|
|
6827
|
+
let {nvim} = import_coc12.workspace;
|
|
6717
6828
|
let {virtualTextSrcId, addGBlameToBufferVar, addGBlameToVirtualText} = this.config;
|
|
6718
6829
|
if (!this.showBlame)
|
|
6719
6830
|
return;
|
|
@@ -6745,7 +6856,7 @@ var GitBuffer = class {
|
|
|
6745
6856
|
if (addGBlameToVirtualText) {
|
|
6746
6857
|
const prefix = this.config.virtualTextPrefix;
|
|
6747
6858
|
await buffer.clearNamespace(virtualTextSrcId);
|
|
6748
|
-
if (
|
|
6859
|
+
if (import_coc12.workspace.has("nvim-0.6.0")) {
|
|
6749
6860
|
await buffer.setExtMark(virtualTextSrcId, lnum - 1, 0, {
|
|
6750
6861
|
hl_mode: "combine",
|
|
6751
6862
|
virt_text: [[prefix + blameText, "CocCodeLens"]]
|
|
@@ -6756,9 +6867,27 @@ var GitBuffer = class {
|
|
|
6756
6867
|
}
|
|
6757
6868
|
}
|
|
6758
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
|
+
}
|
|
6759
6888
|
async diffDocument(force = false) {
|
|
6760
6889
|
var _a;
|
|
6761
|
-
let {nvim} =
|
|
6890
|
+
let {nvim} = import_coc12.workspace;
|
|
6762
6891
|
let revision = this.config.diffRevision;
|
|
6763
6892
|
const {bufnr} = this.doc;
|
|
6764
6893
|
const diffs = await this.repo.getDiff(this.relpath, this.doc.content, revision);
|
|
@@ -6837,7 +6966,7 @@ var GitBuffer = class {
|
|
|
6837
6966
|
return;
|
|
6838
6967
|
if (!this.config.enableGutters)
|
|
6839
6968
|
return;
|
|
6840
|
-
let {nvim} =
|
|
6969
|
+
let {nvim} = import_coc12.workspace;
|
|
6841
6970
|
let {bufnr} = this.doc;
|
|
6842
6971
|
let {signPriority} = this.config;
|
|
6843
6972
|
let signs = this.currentSigns;
|
|
@@ -6910,10 +7039,10 @@ var GitBuffer = class {
|
|
|
6910
7039
|
async diffCached() {
|
|
6911
7040
|
let res = await this.repo.safeRun(["diff", "--cached"]);
|
|
6912
7041
|
if (!res.trim()) {
|
|
6913
|
-
|
|
7042
|
+
import_coc12.window.showMessage("Empty diff");
|
|
6914
7043
|
return;
|
|
6915
7044
|
}
|
|
6916
|
-
let {nvim} =
|
|
7045
|
+
let {nvim} = import_coc12.workspace;
|
|
6917
7046
|
nvim.pauseNotification();
|
|
6918
7047
|
nvim.command(`keepalt above new +setl\\ previewwindow`, true);
|
|
6919
7048
|
nvim.call("append", [0, res.split(/\r?\n/)], true);
|
|
@@ -6924,44 +7053,44 @@ var GitBuffer = class {
|
|
|
6924
7053
|
await nvim.resumeNotification();
|
|
6925
7054
|
}
|
|
6926
7055
|
async nextConflict() {
|
|
6927
|
-
let {nvim} =
|
|
7056
|
+
let {nvim} = import_coc12.workspace;
|
|
6928
7057
|
if (!this.conflicts.length) {
|
|
6929
|
-
|
|
7058
|
+
import_coc12.window.showMessage("No conflicts detected", "warning");
|
|
6930
7059
|
return;
|
|
6931
7060
|
}
|
|
6932
7061
|
let line = await nvim.call("line", ".");
|
|
6933
7062
|
for (let conflict of this.conflicts) {
|
|
6934
7063
|
if (conflict.start > line) {
|
|
6935
|
-
await
|
|
7064
|
+
await import_coc12.window.moveTo({line: Math.max(conflict.start - 1, 0), character: 0});
|
|
6936
7065
|
return;
|
|
6937
7066
|
}
|
|
6938
7067
|
}
|
|
6939
7068
|
if (await nvim.getOption("wrapscan")) {
|
|
6940
|
-
await
|
|
7069
|
+
await import_coc12.window.moveTo({line: Math.max(this.conflicts[0].start - 1, 0), character: 0});
|
|
6941
7070
|
}
|
|
6942
7071
|
}
|
|
6943
7072
|
async prevConflict() {
|
|
6944
|
-
let {nvim} =
|
|
7073
|
+
let {nvim} = import_coc12.workspace;
|
|
6945
7074
|
if (!this.conflicts.length) {
|
|
6946
|
-
|
|
7075
|
+
import_coc12.window.showMessage("No conflicts detected", "warning");
|
|
6947
7076
|
return;
|
|
6948
7077
|
}
|
|
6949
7078
|
let line = await nvim.call("line", ".");
|
|
6950
7079
|
for (let conflict of this.conflicts) {
|
|
6951
7080
|
if (conflict.start > line) {
|
|
6952
|
-
await
|
|
7081
|
+
await import_coc12.window.moveTo({line: Math.max(conflict.start - 1, 0), character: 0});
|
|
6953
7082
|
return;
|
|
6954
7083
|
}
|
|
6955
7084
|
}
|
|
6956
7085
|
if (await nvim.getOption("wrapscan")) {
|
|
6957
|
-
await
|
|
7086
|
+
await import_coc12.window.moveTo({line: Math.max(this.conflicts[0].start - 1, 0), character: 0});
|
|
6958
7087
|
}
|
|
6959
7088
|
}
|
|
6960
7089
|
async conflictKeepPart(part) {
|
|
6961
|
-
const {nvim} =
|
|
7090
|
+
const {nvim} = import_coc12.workspace;
|
|
6962
7091
|
let conflicts = this.conflicts;
|
|
6963
7092
|
if (!conflicts || conflicts.length == 0) {
|
|
6964
|
-
|
|
7093
|
+
import_coc12.window.showMessage("No conflicts detected");
|
|
6965
7094
|
return;
|
|
6966
7095
|
}
|
|
6967
7096
|
let line = await nvim.call("line", ".");
|
|
@@ -6981,11 +7110,11 @@ var GitBuffer = class {
|
|
|
6981
7110
|
}
|
|
6982
7111
|
}
|
|
6983
7112
|
}
|
|
6984
|
-
|
|
7113
|
+
import_coc12.window.showMessage("Not positioned on a conflict");
|
|
6985
7114
|
}
|
|
6986
7115
|
async browser(action = "open", range, permalink = false) {
|
|
6987
|
-
let {nvim} =
|
|
6988
|
-
let config =
|
|
7116
|
+
let {nvim} = import_coc12.workspace;
|
|
7117
|
+
let config = import_coc12.workspace.getConfiguration("git");
|
|
6989
7118
|
let head = (await this.repo.safeRun(["rev-parse", "HEAD"])).trim();
|
|
6990
7119
|
let branch = config.get("browserBranchName", "").trim();
|
|
6991
7120
|
if (!branch.length) {
|
|
@@ -7004,7 +7133,7 @@ var GitBuffer = class {
|
|
|
7004
7133
|
}
|
|
7005
7134
|
let output = await this.repo.safeRun(["remote"]);
|
|
7006
7135
|
if (!output.trim()) {
|
|
7007
|
-
|
|
7136
|
+
import_coc12.window.showMessage(`No remote found`, "warning");
|
|
7008
7137
|
return;
|
|
7009
7138
|
}
|
|
7010
7139
|
let names = output.trim().split(/\r?\n/);
|
|
@@ -7013,7 +7142,7 @@ var GitBuffer = class {
|
|
|
7013
7142
|
if (names.includes(browserRemoteName)) {
|
|
7014
7143
|
names = [browserRemoteName];
|
|
7015
7144
|
} else {
|
|
7016
|
-
|
|
7145
|
+
import_coc12.window.showMessage("Configured git.browserRemoteName missing from remote list", "warning");
|
|
7017
7146
|
return;
|
|
7018
7147
|
}
|
|
7019
7148
|
}
|
|
@@ -7036,19 +7165,19 @@ var GitBuffer = class {
|
|
|
7036
7165
|
}
|
|
7037
7166
|
if (urls.length == 1) {
|
|
7038
7167
|
if (action == "open") {
|
|
7039
|
-
await
|
|
7168
|
+
await import_coc12.workspace.openResource(urls[0]);
|
|
7040
7169
|
} else {
|
|
7041
7170
|
nvim.command(`let @+ = '${urls[0]}'`, true);
|
|
7042
|
-
|
|
7171
|
+
import_coc12.window.showMessage("Copied url to clipboard");
|
|
7043
7172
|
}
|
|
7044
7173
|
} else if (urls.length > 1) {
|
|
7045
|
-
let idx = await
|
|
7174
|
+
let idx = await import_coc12.window.showQuickpick(urls, "Select url:");
|
|
7046
7175
|
if (idx >= 0) {
|
|
7047
7176
|
if (action == "open") {
|
|
7048
|
-
await
|
|
7177
|
+
await import_coc12.workspace.openResource(urls[idx]);
|
|
7049
7178
|
} else {
|
|
7050
7179
|
nvim.command(`let @+ = '${urls[idx]}'`, true);
|
|
7051
|
-
|
|
7180
|
+
import_coc12.window.showMessage("Copied url to clipboard");
|
|
7052
7181
|
}
|
|
7053
7182
|
}
|
|
7054
7183
|
}
|
|
@@ -7056,10 +7185,10 @@ var GitBuffer = class {
|
|
|
7056
7185
|
async showCommit() {
|
|
7057
7186
|
let indexed = await this.repo.isIndexed(this.relpath);
|
|
7058
7187
|
if (!indexed) {
|
|
7059
|
-
|
|
7188
|
+
import_coc12.window.showMessage(`"${this.relpath}" not indexed.`, "warning");
|
|
7060
7189
|
return;
|
|
7061
7190
|
}
|
|
7062
|
-
let nvim =
|
|
7191
|
+
let nvim = import_coc12.workspace.nvim;
|
|
7063
7192
|
let line = await nvim.eval('line(".")');
|
|
7064
7193
|
let args = ["--no-pager", "blame", "-l", "--root", "-t", `-L${line},${line}`, this.relpath];
|
|
7065
7194
|
let res = await this.repo.exec(args);
|
|
@@ -7068,7 +7197,7 @@ var GitBuffer = class {
|
|
|
7068
7197
|
return;
|
|
7069
7198
|
let commit = output.match(/^\S+/)[0];
|
|
7070
7199
|
if (/^0+$/.test(commit)) {
|
|
7071
|
-
|
|
7200
|
+
import_coc12.window.showMessage("not committed yet!", "warning");
|
|
7072
7201
|
return;
|
|
7073
7202
|
}
|
|
7074
7203
|
let useFloating = this.config.showCommitInFloating;
|
|
@@ -7099,16 +7228,16 @@ var GitBuffer = class {
|
|
|
7099
7228
|
}
|
|
7100
7229
|
}
|
|
7101
7230
|
async toggleFold() {
|
|
7102
|
-
let {nvim} =
|
|
7231
|
+
let {nvim} = import_coc12.workspace;
|
|
7103
7232
|
let buf = this.doc.buffer;
|
|
7104
7233
|
let win = await nvim.window;
|
|
7105
7234
|
let bufnr = buf.id;
|
|
7106
|
-
let doc =
|
|
7235
|
+
let doc = import_coc12.workspace.getDocument(bufnr);
|
|
7107
7236
|
if (!doc)
|
|
7108
7237
|
return;
|
|
7109
7238
|
let infos = this.currentSigns;
|
|
7110
7239
|
if (!infos || infos.length == 0) {
|
|
7111
|
-
|
|
7240
|
+
import_coc12.window.showMessage("No changes", "warning");
|
|
7112
7241
|
return;
|
|
7113
7242
|
}
|
|
7114
7243
|
let lnums = infos.map((o) => o.lnum);
|
|
@@ -7166,7 +7295,7 @@ var GitBuffer = class {
|
|
|
7166
7295
|
}
|
|
7167
7296
|
async toggleGutters(enabled) {
|
|
7168
7297
|
this.config.enableGutters = enabled;
|
|
7169
|
-
let {nvim} =
|
|
7298
|
+
let {nvim} = import_coc12.workspace;
|
|
7170
7299
|
if (!enabled) {
|
|
7171
7300
|
nvim.call("sign_unplace", [signGroup, {buffer: this.doc.bufnr}], true);
|
|
7172
7301
|
} else {
|
|
@@ -7251,7 +7380,7 @@ var GitBuffer = class {
|
|
|
7251
7380
|
let buffer = this.doc.buffer;
|
|
7252
7381
|
let currentHlGroup = this.config.conflict.currentHlGroup;
|
|
7253
7382
|
let incomingHlGroup = this.config.conflict.incomingHlGroup;
|
|
7254
|
-
let {nvim} =
|
|
7383
|
+
let {nvim} = import_coc12.workspace;
|
|
7255
7384
|
nvim.pauseNotification();
|
|
7256
7385
|
buffer.clearNamespace(this.config.conflictSrcId, 0, -1);
|
|
7257
7386
|
conflicts.map((conflict) => {
|
|
@@ -7272,12 +7401,16 @@ var GitBuffer = class {
|
|
|
7272
7401
|
nvim.resumeNotification(false, true);
|
|
7273
7402
|
}
|
|
7274
7403
|
async showDoc(content, filetype = "diff") {
|
|
7275
|
-
if (
|
|
7404
|
+
if (import_coc12.workspace.floatSupported) {
|
|
7276
7405
|
let docs = [{content, filetype}];
|
|
7277
|
-
|
|
7406
|
+
let floatConfig = {};
|
|
7407
|
+
if (import_coc12.workspace.getConfiguration("hover").get("floatConfig", {})["border"]) {
|
|
7408
|
+
floatConfig = {border: [1, 1, 1, 1]};
|
|
7409
|
+
}
|
|
7410
|
+
await this.floatFactory.show(docs, floatConfig);
|
|
7278
7411
|
} else {
|
|
7279
7412
|
const lines = content.split("\n");
|
|
7280
|
-
|
|
7413
|
+
import_coc12.workspace.nvim.call("coc#util#preview_info", [lines, "diff"], true);
|
|
7281
7414
|
}
|
|
7282
7415
|
}
|
|
7283
7416
|
setBufferStatus(status) {
|
|
@@ -7285,7 +7418,7 @@ var GitBuffer = class {
|
|
|
7285
7418
|
if (exists == status)
|
|
7286
7419
|
return;
|
|
7287
7420
|
this.gitStatus = status;
|
|
7288
|
-
let {nvim} =
|
|
7421
|
+
let {nvim} = import_coc12.workspace;
|
|
7289
7422
|
let buffer = nvim.createBuffer(this.doc.bufnr);
|
|
7290
7423
|
nvim.pauseNotification();
|
|
7291
7424
|
buffer.setVar("coc_git_status", status, true);
|
|
@@ -7311,7 +7444,7 @@ var GitBuffer = class {
|
|
|
7311
7444
|
return this.config.addGBlameToVirtualText || this.config.addGBlameToBufferVar;
|
|
7312
7445
|
}
|
|
7313
7446
|
dispose() {
|
|
7314
|
-
let {nvim} =
|
|
7447
|
+
let {nvim} = import_coc12.workspace;
|
|
7315
7448
|
let {bufnr} = this.doc;
|
|
7316
7449
|
let buffer = nvim.createBuffer(bufnr);
|
|
7317
7450
|
buffer.setVar("coc_git_status", "", true);
|
|
@@ -7339,10 +7472,10 @@ var import_path7 = __toModule(require("path"));
|
|
|
7339
7472
|
var GitService = class {
|
|
7340
7473
|
constructor(gitInfo) {
|
|
7341
7474
|
this.repos = new Map();
|
|
7342
|
-
const outputChannel = this.outputChannel =
|
|
7475
|
+
const outputChannel = this.outputChannel = import_coc13.window.createOutputChannel("git");
|
|
7343
7476
|
this._git = new git_default(gitInfo, outputChannel);
|
|
7344
7477
|
this._resolver = new resolver_default(this._git, outputChannel);
|
|
7345
|
-
this.floatFactory = new
|
|
7478
|
+
this.floatFactory = new import_coc13.FloatFactory(import_coc13.workspace.nvim);
|
|
7346
7479
|
}
|
|
7347
7480
|
getRepoFromRoot(root) {
|
|
7348
7481
|
if (this.repos.has(root)) {
|
|
@@ -7368,11 +7501,11 @@ var GitService = class {
|
|
|
7368
7501
|
return new buffer_default(doc, config, relpath, repo, this.git, this.outputChannel, this.floatFactory);
|
|
7369
7502
|
}
|
|
7370
7503
|
async getCurrentRepo() {
|
|
7371
|
-
let {nvim} =
|
|
7504
|
+
let {nvim} = import_coc13.workspace;
|
|
7372
7505
|
let [fullpath, buftype] = await nvim.eval('[expand("%:p"),&buftype]');
|
|
7373
7506
|
if (!import_path7.default.isAbsolute(fullpath) || buftype != "")
|
|
7374
7507
|
return void 0;
|
|
7375
|
-
let root = await this.resolver.resolveGitRoot({uri:
|
|
7508
|
+
let root = await this.resolver.resolveGitRoot({uri: import_coc13.Uri.file(fullpath).toString(), schema: "file", buftype: ""});
|
|
7376
7509
|
if (root == null)
|
|
7377
7510
|
return void 0;
|
|
7378
7511
|
return this.getRepoFromRoot(root);
|
|
@@ -7396,15 +7529,15 @@ var GitService = class {
|
|
|
7396
7529
|
var service_default = GitService;
|
|
7397
7530
|
|
|
7398
7531
|
// src/source.ts
|
|
7399
|
-
var
|
|
7400
|
-
var
|
|
7532
|
+
var import_coc14 = __toModule(require("coc.nvim"));
|
|
7533
|
+
var import_safe4 = __toModule(require_safe());
|
|
7401
7534
|
function byteSlice(content, start, end) {
|
|
7402
7535
|
let buf = Buffer.from(content, "utf8");
|
|
7403
7536
|
return buf.slice(start, end).toString("utf8");
|
|
7404
7537
|
}
|
|
7405
7538
|
var issuesMap = new Map();
|
|
7406
7539
|
function issuesFiletypes() {
|
|
7407
|
-
return
|
|
7540
|
+
return import_coc14.workspace.getConfiguration().get("coc.source.issues.filetypes");
|
|
7408
7541
|
}
|
|
7409
7542
|
function getOrganizationNameAndRepoNameFromGitHubRemoteUrl(remoteUrl) {
|
|
7410
7543
|
try {
|
|
@@ -7443,7 +7576,7 @@ function renderWord(issue, issueFormat) {
|
|
|
7443
7576
|
}
|
|
7444
7577
|
function addSource(context, resolver) {
|
|
7445
7578
|
let {subscriptions, logger} = context;
|
|
7446
|
-
let statusItem =
|
|
7579
|
+
let statusItem = import_coc14.window.createStatusBarItem(0, {progress: true});
|
|
7447
7580
|
statusItem.text = "loading issues";
|
|
7448
7581
|
let statusItemCounter = 0;
|
|
7449
7582
|
function onStartLoading() {
|
|
@@ -7486,7 +7619,7 @@ function addSource(context, resolver) {
|
|
|
7486
7619
|
const pageUri = `${uri}&page=${pageIndex}`;
|
|
7487
7620
|
pageIndex++;
|
|
7488
7621
|
try {
|
|
7489
|
-
let info = await
|
|
7622
|
+
let info = await import_coc14.fetch(pageUri, {headers: {"Private-Token": token}});
|
|
7490
7623
|
if (!info.length) {
|
|
7491
7624
|
break;
|
|
7492
7625
|
}
|
|
@@ -7522,7 +7655,7 @@ function addSource(context, resolver) {
|
|
|
7522
7655
|
let page_uri = `${uri}&page=${page_idx}`;
|
|
7523
7656
|
page_idx++;
|
|
7524
7657
|
try {
|
|
7525
|
-
let info = await
|
|
7658
|
+
let info = await import_coc14.fetch(page_uri, {headers});
|
|
7526
7659
|
if (info.length == 0) {
|
|
7527
7660
|
break;
|
|
7528
7661
|
}
|
|
@@ -7547,7 +7680,7 @@ function addSource(context, resolver) {
|
|
|
7547
7680
|
return issues;
|
|
7548
7681
|
}
|
|
7549
7682
|
async function loadIssues(root) {
|
|
7550
|
-
let config =
|
|
7683
|
+
let config = import_coc14.workspace.getConfiguration("git");
|
|
7551
7684
|
const issueSources = (await safeRun(`git config --get coc-git.issuesources`, {cwd: root}) || "").trim();
|
|
7552
7685
|
if (issueSources) {
|
|
7553
7686
|
return Array.prototype.concat.apply([], await Promise.all(issueSources.split(",").map((issueSource) => {
|
|
@@ -7590,14 +7723,14 @@ function addSource(context, resolver) {
|
|
|
7590
7723
|
}
|
|
7591
7724
|
}).catch(onError);
|
|
7592
7725
|
};
|
|
7593
|
-
for (let doc of
|
|
7726
|
+
for (let doc of import_coc14.workspace.documents) {
|
|
7594
7727
|
if (issuesFiletypes().includes(doc.filetype)) {
|
|
7595
7728
|
loadIssuesFromDocument(doc);
|
|
7596
7729
|
}
|
|
7597
7730
|
}
|
|
7598
|
-
|
|
7731
|
+
import_coc14.workspace.onDidOpenTextDocument(async (e) => {
|
|
7599
7732
|
if (issuesFiletypes().includes(e.languageId)) {
|
|
7600
|
-
let doc =
|
|
7733
|
+
let doc = import_coc14.workspace.getDocument(e.uri);
|
|
7601
7734
|
loadIssuesFromDocument(doc);
|
|
7602
7735
|
}
|
|
7603
7736
|
}, null, subscriptions);
|
|
@@ -7606,7 +7739,7 @@ function addSource(context, resolver) {
|
|
|
7606
7739
|
async doComplete(opt) {
|
|
7607
7740
|
let pre = byteSlice(opt.line, 0, opt.colnr - 1);
|
|
7608
7741
|
if (pre && pre.endsWith("#")) {
|
|
7609
|
-
const config =
|
|
7742
|
+
const config = import_coc14.workspace.getConfiguration("git");
|
|
7610
7743
|
const issueFormat = config.get("issueFormat", "#%i");
|
|
7611
7744
|
let issues = issuesMap.get(opt.bufnr);
|
|
7612
7745
|
if (!issues || issues.length == 0)
|
|
@@ -7632,14 +7765,14 @@ function addSource(context, resolver) {
|
|
|
7632
7765
|
};
|
|
7633
7766
|
}
|
|
7634
7767
|
};
|
|
7635
|
-
subscriptions.push(
|
|
7768
|
+
subscriptions.push(import_coc14.sources.createSource(source));
|
|
7636
7769
|
let list = {
|
|
7637
7770
|
name: "issues",
|
|
7638
7771
|
actions: [{
|
|
7639
7772
|
name: "open",
|
|
7640
7773
|
execute: async (item) => {
|
|
7641
7774
|
let {url} = item.data;
|
|
7642
|
-
await
|
|
7775
|
+
await import_coc14.workspace.openResource(url);
|
|
7643
7776
|
},
|
|
7644
7777
|
multiple: false
|
|
7645
7778
|
}, {
|
|
@@ -7649,7 +7782,7 @@ function addSource(context, resolver) {
|
|
|
7649
7782
|
let {body, id} = item.data;
|
|
7650
7783
|
let lines = body.split(/\r?\n/);
|
|
7651
7784
|
let mod = context2.options.position == "top" ? "below" : "above";
|
|
7652
|
-
let {nvim} =
|
|
7785
|
+
let {nvim} = import_coc14.workspace;
|
|
7653
7786
|
nvim.pauseNotification();
|
|
7654
7787
|
nvim.command("pclose", true);
|
|
7655
7788
|
nvim.command(`${mod} ${lines.length}sp +setl\\ previewwindow [issue ${id}]`, true);
|
|
@@ -7668,135 +7801,142 @@ function addSource(context, resolver) {
|
|
|
7668
7801
|
description: "issues on github/gitlab",
|
|
7669
7802
|
loadItems: async (context2) => {
|
|
7670
7803
|
let buf = await context2.window.buffer;
|
|
7671
|
-
let root = await resolver.resolveGitRoot(
|
|
7804
|
+
let root = await resolver.resolveGitRoot(import_coc14.workspace.getDocument(buf.id));
|
|
7672
7805
|
if (!root)
|
|
7673
7806
|
return [];
|
|
7674
7807
|
let issues = await loadIssues(root);
|
|
7675
7808
|
return issues.map((o) => {
|
|
7676
7809
|
return {
|
|
7677
|
-
label: `${
|
|
7810
|
+
label: `${import_safe4.default.red("#" + o.id.toFixed(0))} ${o.title} (${import_safe4.default.green(o.createAt.toUTCString())}) <${import_safe4.default.blue(o.creator)}>`,
|
|
7678
7811
|
data: {id: o.id, url: o.url, body: o.body}
|
|
7679
7812
|
};
|
|
7680
7813
|
});
|
|
7681
7814
|
}
|
|
7682
7815
|
};
|
|
7683
|
-
subscriptions.push(
|
|
7816
|
+
subscriptions.push(import_coc14.listManager.registerList(list));
|
|
7684
7817
|
}
|
|
7685
7818
|
|
|
7686
7819
|
// src/index.ts
|
|
7687
7820
|
async function activate(context) {
|
|
7688
|
-
const config =
|
|
7821
|
+
const config = import_coc15.workspace.getConfiguration("git");
|
|
7689
7822
|
const {subscriptions} = context;
|
|
7690
7823
|
let gitInfo;
|
|
7691
7824
|
try {
|
|
7692
7825
|
let pathHint = config.get("command");
|
|
7693
7826
|
gitInfo = await findGit(pathHint, (path8) => context.logger.info(`Looking for git in: ${path8}`));
|
|
7694
7827
|
} catch (e) {
|
|
7695
|
-
|
|
7828
|
+
import_coc15.window.showMessage("git command required for coc-git", "error");
|
|
7696
7829
|
return;
|
|
7697
7830
|
}
|
|
7698
|
-
const virtualTextSrcId = await
|
|
7699
|
-
const conflictSrcId = await
|
|
7700
|
-
const {nvim} =
|
|
7831
|
+
const virtualTextSrcId = await import_coc15.workspace.nvim.createNamespace("coc-git-virtual");
|
|
7832
|
+
const conflictSrcId = await import_coc15.workspace.nvim.createNamespace("coc-git-conflicts");
|
|
7833
|
+
const {nvim} = import_coc15.workspace;
|
|
7701
7834
|
const service = new service_default(gitInfo);
|
|
7702
7835
|
const manager = new manager_default(nvim, service, virtualTextSrcId, conflictSrcId);
|
|
7703
7836
|
subscriptions.push(manager);
|
|
7704
7837
|
addSource(context, service.resolver);
|
|
7705
|
-
subscriptions.push(
|
|
7838
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.refresh", () => {
|
|
7706
7839
|
manager.refresh();
|
|
7707
7840
|
}));
|
|
7708
|
-
subscriptions.push(
|
|
7841
|
+
subscriptions.push(import_coc15.workspace.registerKeymap(["n"], "git-nextchunk", async () => {
|
|
7709
7842
|
await manager.nextChunk();
|
|
7710
7843
|
}, {sync: false}));
|
|
7711
|
-
subscriptions.push(
|
|
7844
|
+
subscriptions.push(import_coc15.workspace.registerKeymap(["n"], "git-prevchunk", async () => {
|
|
7712
7845
|
await manager.prevChunk();
|
|
7713
7846
|
}, {sync: false}));
|
|
7714
|
-
subscriptions.push(
|
|
7847
|
+
subscriptions.push(import_coc15.workspace.registerKeymap(["n"], "git-nextconflict", async () => {
|
|
7715
7848
|
await manager.nextConflict();
|
|
7716
7849
|
}, {sync: false}));
|
|
7717
|
-
subscriptions.push(
|
|
7850
|
+
subscriptions.push(import_coc15.workspace.registerKeymap(["n"], "git-prevconflict", async () => {
|
|
7718
7851
|
await manager.prevConflict();
|
|
7719
7852
|
}, {sync: false}));
|
|
7720
|
-
subscriptions.push(
|
|
7853
|
+
subscriptions.push(import_coc15.workspace.registerKeymap(["n"], "git-keepcurrent", async () => {
|
|
7721
7854
|
await manager.keepCurrent();
|
|
7722
7855
|
}, {sync: false}));
|
|
7723
|
-
subscriptions.push(
|
|
7856
|
+
subscriptions.push(import_coc15.workspace.registerKeymap(["n"], "git-keepincoming", async () => {
|
|
7724
7857
|
await manager.keepIncoming();
|
|
7725
7858
|
}, {sync: false}));
|
|
7726
|
-
subscriptions.push(
|
|
7859
|
+
subscriptions.push(import_coc15.workspace.registerKeymap(["n"], "git-keepboth", async () => {
|
|
7727
7860
|
await manager.keepBoth();
|
|
7728
7861
|
}, {sync: false}));
|
|
7729
|
-
subscriptions.push(
|
|
7862
|
+
subscriptions.push(import_coc15.workspace.registerKeymap(["n"], "git-chunkinfo", async () => {
|
|
7730
7863
|
await manager.chunkInfo();
|
|
7731
7864
|
}, {sync: false}));
|
|
7732
|
-
subscriptions.push(
|
|
7865
|
+
subscriptions.push(import_coc15.workspace.registerKeymap(["n"], "git-commit", async () => {
|
|
7733
7866
|
await manager.showCommit();
|
|
7734
7867
|
}, {sync: false}));
|
|
7735
|
-
subscriptions.push(
|
|
7868
|
+
subscriptions.push(import_coc15.workspace.registerKeymap(["n"], "git-showblamedoc", async () => {
|
|
7869
|
+
await manager.showBlameDoc();
|
|
7870
|
+
}, {sync: false}));
|
|
7871
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.keepCurrent", async () => {
|
|
7736
7872
|
await manager.keepCurrent();
|
|
7737
7873
|
}));
|
|
7738
|
-
subscriptions.push(
|
|
7874
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.keepIncoming", async () => {
|
|
7739
7875
|
await manager.keepIncoming();
|
|
7740
7876
|
}));
|
|
7741
|
-
subscriptions.push(
|
|
7877
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.keepBoth", async () => {
|
|
7742
7878
|
await manager.keepBoth();
|
|
7743
7879
|
}));
|
|
7744
|
-
subscriptions.push(
|
|
7880
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.chunkInfo", async () => {
|
|
7745
7881
|
await manager.chunkInfo();
|
|
7746
7882
|
}));
|
|
7747
|
-
subscriptions.push(
|
|
7883
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.chunkStage", async () => {
|
|
7748
7884
|
await manager.chunkStage();
|
|
7749
7885
|
}));
|
|
7750
|
-
subscriptions.push(
|
|
7886
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.chunkUnstage", async () => {
|
|
7751
7887
|
await manager.chunkUnstage();
|
|
7752
7888
|
}));
|
|
7753
|
-
subscriptions.push(
|
|
7889
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.chunkUndo", async () => {
|
|
7754
7890
|
await manager.chunkUndo();
|
|
7755
7891
|
}));
|
|
7756
|
-
subscriptions.push(
|
|
7892
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.showCommit", async () => {
|
|
7757
7893
|
await manager.showCommit();
|
|
7758
7894
|
}));
|
|
7759
|
-
subscriptions.push(
|
|
7895
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.browserOpen", async () => {
|
|
7760
7896
|
await manager.browser();
|
|
7761
7897
|
}));
|
|
7762
|
-
subscriptions.push(
|
|
7898
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.copyUrl", async (...args) => {
|
|
7763
7899
|
await manager.browser("copy", args);
|
|
7764
7900
|
}));
|
|
7765
|
-
subscriptions.push(
|
|
7901
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.copyPermalink", async (...args) => {
|
|
7766
7902
|
await manager.browser("copy", args, true);
|
|
7767
7903
|
}));
|
|
7768
|
-
subscriptions.push(
|
|
7904
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.push", async (...args) => {
|
|
7769
7905
|
await manager.push(args);
|
|
7770
7906
|
}));
|
|
7771
|
-
subscriptions.push(
|
|
7907
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.diffCached", async () => {
|
|
7772
7908
|
await manager.diffCached();
|
|
7773
7909
|
}));
|
|
7774
|
-
subscriptions.push(
|
|
7910
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.toggleGutters", async () => {
|
|
7775
7911
|
await manager.toggleGutters();
|
|
7776
7912
|
}));
|
|
7777
|
-
subscriptions.push(
|
|
7913
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.foldUnchanged", async () => {
|
|
7778
7914
|
await manager.toggleFold();
|
|
7779
7915
|
}));
|
|
7780
|
-
subscriptions.push(
|
|
7781
|
-
|
|
7782
|
-
|
|
7783
|
-
subscriptions.push(
|
|
7784
|
-
subscriptions.push(
|
|
7785
|
-
subscriptions.push(
|
|
7916
|
+
subscriptions.push(import_coc15.commands.registerCommand("git.showBlameDoc", async () => {
|
|
7917
|
+
await manager.showBlameDoc();
|
|
7918
|
+
}));
|
|
7919
|
+
subscriptions.push(import_coc15.listManager.registerList(new gstatus_default(nvim, manager)));
|
|
7920
|
+
subscriptions.push(import_coc15.listManager.registerList(new branches_default(nvim, manager)));
|
|
7921
|
+
subscriptions.push(import_coc15.listManager.registerList(new commits_default(nvim, manager)));
|
|
7922
|
+
subscriptions.push(import_coc15.listManager.registerList(new bcommits_default(nvim, manager)));
|
|
7923
|
+
subscriptions.push(import_coc15.listManager.registerList(new gfiles_default(nvim, manager)));
|
|
7924
|
+
subscriptions.push(import_coc15.listManager.registerList(new gchunks_default(nvim, manager)));
|
|
7925
|
+
subscriptions.push(import_coc15.languages.registerCompletionItemProvider("semantic-commit", "Commit", config.get("semanticCommit.filetypes"), {
|
|
7786
7926
|
provideCompletionItems: async (document, position) => {
|
|
7787
7927
|
if (position.line !== 0) {
|
|
7788
7928
|
return [];
|
|
7789
7929
|
}
|
|
7790
|
-
const text = document.getText(
|
|
7930
|
+
const text = document.getText(import_coc15.Range.create(import_coc15.Position.create(position.line, 0), position));
|
|
7791
7931
|
if (/^[a-z]*$/.test(text)) {
|
|
7792
7932
|
const scope = config.get("semanticCommit.scope");
|
|
7793
7933
|
const text2 = scope ? "(${1:scope}): ${2:commit}" : ": ${1:commit}";
|
|
7794
7934
|
return DEFAULT_TYPES.map((o) => {
|
|
7795
7935
|
return {
|
|
7796
7936
|
label: o.value,
|
|
7797
|
-
kind:
|
|
7937
|
+
kind: import_coc15.CompletionItemKind.Snippet,
|
|
7798
7938
|
documentation: {kind: "plaintext", value: o.name},
|
|
7799
|
-
insertTextFormat:
|
|
7939
|
+
insertTextFormat: import_coc15.InsertTextFormat.Snippet,
|
|
7800
7940
|
insertText: o.value + text2 + "\n\n"
|
|
7801
7941
|
};
|
|
7802
7942
|
});
|
|
@@ -7804,13 +7944,13 @@ async function activate(context) {
|
|
|
7804
7944
|
return [];
|
|
7805
7945
|
}
|
|
7806
7946
|
}));
|
|
7807
|
-
subscriptions.push(
|
|
7947
|
+
subscriptions.push(import_coc15.workspace.registerKeymap(["o", "x"], "git-chunk-inner", async () => {
|
|
7808
7948
|
let diff = await manager.getCurrentChunk();
|
|
7809
7949
|
if (!diff)
|
|
7810
7950
|
return;
|
|
7811
7951
|
await nvim.command(`normal! ${diff.start}GV${diff.end}G`);
|
|
7812
7952
|
}, {sync: true, silent: true}));
|
|
7813
|
-
subscriptions.push(
|
|
7953
|
+
subscriptions.push(import_coc15.workspace.registerKeymap(["o", "x"], "git-chunk-outer", async () => {
|
|
7814
7954
|
let diff = await manager.getCurrentChunk();
|
|
7815
7955
|
if (!diff)
|
|
7816
7956
|
return;
|