coc-git 2.7.2 → 2.7.3
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 +4 -0
- package/lib/index.js +48 -23
- package/package.json +16 -1
package/Readme.md
CHANGED
|
@@ -50,6 +50,10 @@ In your vim/neovim, run command:
|
|
|
50
50
|
|
|
51
51
|
- `git.remoteName`: Remote name for fetch github issues., default: `"origin"`
|
|
52
52
|
|
|
53
|
+
- `git.diffOptions`: Options for git diff command, eg: `["--ignore-all-space"]`, default: `[]`
|
|
54
|
+
|
|
55
|
+
- `git.foldContext`: Line count to leave below and above the fold, default: `0`.
|
|
56
|
+
|
|
53
57
|
- `git.browserRemoteName`: Remote name for browserOpen and copyUrl., default: `""`
|
|
54
58
|
|
|
55
59
|
- `git.browserBranchName`: Branch name for browserOpen and copyUrl., default: `""`
|
package/lib/index.js
CHANGED
|
@@ -4653,7 +4653,7 @@ function spawnCommand(cmd, args, cwd) {
|
|
|
4653
4653
|
res += data.toString();
|
|
4654
4654
|
});
|
|
4655
4655
|
cp2.stderr.on("data", (data) => {
|
|
4656
|
-
import_coc.window.
|
|
4656
|
+
import_coc.window.showErrorMessage(`"${cmd} ${args.join(" ")}" error: ${data.toString()}`);
|
|
4657
4657
|
});
|
|
4658
4658
|
cp2.on("close", (code) => {
|
|
4659
4659
|
if (code != 0) {
|
|
@@ -4903,7 +4903,7 @@ var CommitsTask = class extends import_events.EventEmitter {
|
|
|
4903
4903
|
};
|
|
4904
4904
|
var Bcommits = class extends import_coc2.BasicList {
|
|
4905
4905
|
constructor(nvim, manager) {
|
|
4906
|
-
super(
|
|
4906
|
+
super();
|
|
4907
4907
|
this.manager = manager;
|
|
4908
4908
|
this.name = "bcommits";
|
|
4909
4909
|
this.description = "Commits of current file.";
|
|
@@ -5158,7 +5158,7 @@ var CommitsTask2 = class extends import_events2.EventEmitter {
|
|
|
5158
5158
|
};
|
|
5159
5159
|
var Commits = class extends import_coc4.BasicList {
|
|
5160
5160
|
constructor(nvim, manager) {
|
|
5161
|
-
super(
|
|
5161
|
+
super();
|
|
5162
5162
|
this.manager = manager;
|
|
5163
5163
|
this.name = "commits";
|
|
5164
5164
|
this.description = "Commits of current project.";
|
|
@@ -5251,7 +5251,7 @@ var Commits = class extends import_coc4.BasicList {
|
|
|
5251
5251
|
} else {
|
|
5252
5252
|
arg = `${list[1].data.commit} ${list[0].data.commit}`;
|
|
5253
5253
|
}
|
|
5254
|
-
let content = await runCommand(`git --no-pager diff --no-ext-diff ${arg}`, { cwd: list[0].data.root });
|
|
5254
|
+
let content = await runCommand(`git --no-pager diff --no-ext-diff ${this.manager.diffOptions.join(" ")} ${arg}`, { cwd: list[0].data.root });
|
|
5255
5255
|
let lines = content.replace(/\n$/, "").split("\n");
|
|
5256
5256
|
nvim.pauseNotification();
|
|
5257
5257
|
nvim.command(`tabe [diff ${arg}]`, true);
|
|
@@ -5275,7 +5275,7 @@ var Commits = class extends import_coc4.BasicList {
|
|
|
5275
5275
|
} else {
|
|
5276
5276
|
arg = `${list[1].data.commit} ${list[0].data.commit}`;
|
|
5277
5277
|
}
|
|
5278
|
-
let content = await runCommand(`git --no-pager diff --no-ext-diff ${arg}`, { cwd: list[0].data.root });
|
|
5278
|
+
let content = await runCommand(`git --no-pager diff ${this.manager.diffOptions.join(" ")} --no-ext-diff ${arg}`, { cwd: list[0].data.root });
|
|
5279
5279
|
let lines = content.replace(/\n$/, "").split("\n");
|
|
5280
5280
|
let winid = context.listWindow.id;
|
|
5281
5281
|
let mod = context.options.position == "tab" ? "below" : "above";
|
|
@@ -5330,7 +5330,7 @@ var import_coc5 = require("coc.nvim");
|
|
|
5330
5330
|
var import_path2 = __toESM(require("path"));
|
|
5331
5331
|
var Gfiles = class extends import_coc5.BasicList {
|
|
5332
5332
|
constructor(nvim, manager) {
|
|
5333
|
-
super(
|
|
5333
|
+
super();
|
|
5334
5334
|
this.manager = manager;
|
|
5335
5335
|
this.name = "gfiles";
|
|
5336
5336
|
this.description = "view files on different branches (or commits, or tags)";
|
|
@@ -5366,7 +5366,7 @@ var Gfiles = class extends import_coc5.BasicList {
|
|
|
5366
5366
|
this.addAction("preview", async (item, context) => {
|
|
5367
5367
|
let { root, sha, filepath, branch } = item.data;
|
|
5368
5368
|
if (!sha) return;
|
|
5369
|
-
let content = await runCommand(`git --no-pager diff --no-ext-diff ${branch} -- ${shellescape(filepath)}`, { cwd: root });
|
|
5369
|
+
let content = await runCommand(`git --no-pager diff ${this.manager.diffOptions.join(" ")} --no-ext-diff ${branch} -- ${shellescape(filepath)}`, { cwd: root });
|
|
5370
5370
|
let lines = content.replace(/\n$/, "").split("\n");
|
|
5371
5371
|
await this.preview({
|
|
5372
5372
|
lines,
|
|
@@ -5423,7 +5423,7 @@ var STATUS_MAP = {
|
|
|
5423
5423
|
};
|
|
5424
5424
|
var GStatus = class extends import_coc6.BasicList {
|
|
5425
5425
|
constructor(nvim, manager) {
|
|
5426
|
-
super(
|
|
5426
|
+
super();
|
|
5427
5427
|
this.manager = manager;
|
|
5428
5428
|
this.name = "gstatus";
|
|
5429
5429
|
this.description = "Git status of current project";
|
|
@@ -5450,7 +5450,7 @@ var GStatus = class extends import_coc6.BasicList {
|
|
|
5450
5450
|
try {
|
|
5451
5451
|
await nvim.command(`G commit -v ${filesArg}`);
|
|
5452
5452
|
} catch (e) {
|
|
5453
|
-
import_coc6.window.
|
|
5453
|
+
import_coc6.window.showErrorMessage(`G commit command failed, make sure fugitive installed.`);
|
|
5454
5454
|
}
|
|
5455
5455
|
});
|
|
5456
5456
|
this.addAction("reset", async (item) => {
|
|
@@ -5494,7 +5494,7 @@ var GStatus = class extends import_coc6.BasicList {
|
|
|
5494
5494
|
}, context);
|
|
5495
5495
|
return;
|
|
5496
5496
|
}
|
|
5497
|
-
let args = ["--no-pager", "diff", "--no-ext-diff"];
|
|
5497
|
+
let args = ["--no-pager", "diff", "--no-ext-diff", ...this.manager.diffOptions];
|
|
5498
5498
|
if (index_symbol == "M" && tree_symbol != "M") {
|
|
5499
5499
|
args.push("--cached");
|
|
5500
5500
|
}
|
|
@@ -5817,6 +5817,8 @@ var DocumentManager = class {
|
|
|
5817
5817
|
let obj = {
|
|
5818
5818
|
remoteName: config.get("remoteName", "origin"),
|
|
5819
5819
|
diffRevision: config.get("diffRevision", ""),
|
|
5820
|
+
foldContext: config.get("foldContext", 0),
|
|
5821
|
+
diffOptions: config.get("diffOptions", []),
|
|
5820
5822
|
issueFormat: config.get("issueFormat", "#%i"),
|
|
5821
5823
|
virtualTextPrefix: config.get("virtualTextPrefix", " "),
|
|
5822
5824
|
addGBlameToVirtualText: config.get("addGBlameToVirtualText", false),
|
|
@@ -5871,6 +5873,9 @@ var DocumentManager = class {
|
|
|
5871
5873
|
get git() {
|
|
5872
5874
|
return this.service.git;
|
|
5873
5875
|
}
|
|
5876
|
+
get diffOptions() {
|
|
5877
|
+
return this.config.diffOptions;
|
|
5878
|
+
}
|
|
5874
5879
|
async toggleGutters() {
|
|
5875
5880
|
let enabled = this.enableGutters;
|
|
5876
5881
|
let config = import_coc10.workspace.getConfiguration("git");
|
|
@@ -5978,7 +5983,7 @@ var DocumentManager = class {
|
|
|
5978
5983
|
let root = await this.resolveGitRootFromBufferOrCwd(bufnr);
|
|
5979
5984
|
let extra = this.config.pushArguments;
|
|
5980
5985
|
if (!root) {
|
|
5981
|
-
import_coc10.window.
|
|
5986
|
+
import_coc10.window.showWarningMessage(`not belongs to git repository.`);
|
|
5982
5987
|
return;
|
|
5983
5988
|
}
|
|
5984
5989
|
if (args && args.length) {
|
|
@@ -5989,12 +5994,12 @@ var DocumentManager = class {
|
|
|
5989
5994
|
let output = await repo.safeRun(["remote"]);
|
|
5990
5995
|
let remote = output.trim().split(/\r?\n/)[0];
|
|
5991
5996
|
if (!remote) {
|
|
5992
|
-
import_coc10.window.
|
|
5997
|
+
import_coc10.window.showWarningMessage(`remote not found`);
|
|
5993
5998
|
return;
|
|
5994
5999
|
}
|
|
5995
6000
|
output = await repo.safeRun(["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
5996
6001
|
if (!output) {
|
|
5997
|
-
import_coc10.window.
|
|
6002
|
+
import_coc10.window.showWarningMessage(`current branch not found`);
|
|
5998
6003
|
return;
|
|
5999
6004
|
}
|
|
6000
6005
|
await import_coc10.window.runTerminalCommand(`git push ${remote} ${output}${extra.length ? " " + extra.join(" ") : ""}`, root, true);
|
|
@@ -6002,7 +6007,7 @@ var DocumentManager = class {
|
|
|
6002
6007
|
get buffer() {
|
|
6003
6008
|
return import_coc10.workspace.nvim.call("bufnr", "%").then((bufnr) => {
|
|
6004
6009
|
let buf = this.buffers.get(bufnr);
|
|
6005
|
-
if (!buf) import_coc10.window.
|
|
6010
|
+
if (!buf) import_coc10.window.showWarningMessage(`Cant't resolve git repository for current buffer.`);
|
|
6006
6011
|
return buf;
|
|
6007
6012
|
});
|
|
6008
6013
|
}
|
|
@@ -6013,7 +6018,7 @@ var DocumentManager = class {
|
|
|
6013
6018
|
let bufnr = await import_coc10.workspace.nvim.call("bufnr", "%");
|
|
6014
6019
|
let root = await this.resolveGitRootFromBufferOrCwd(bufnr);
|
|
6015
6020
|
if (!root) {
|
|
6016
|
-
import_coc10.window.
|
|
6021
|
+
import_coc10.window.showWarningMessage(`not belongs to git repository.`);
|
|
6017
6022
|
return null;
|
|
6018
6023
|
}
|
|
6019
6024
|
let repo = this.service.getRepoFromRoot(root);
|
|
@@ -7064,7 +7069,7 @@ var GitBuffer = class {
|
|
|
7064
7069
|
let info;
|
|
7065
7070
|
for (let line of r.stdout.trim().split(/\r?\n/)) {
|
|
7066
7071
|
line = line.trim();
|
|
7067
|
-
if (
|
|
7072
|
+
if (/^(author |committer )?External file \(--contents\)/.test(line)) {
|
|
7068
7073
|
line = "Not committed yet.";
|
|
7069
7074
|
}
|
|
7070
7075
|
let ms = line.match(/^([A-Za-z0-9]+)\s(\d+)\s(\d+)\s(\d+)/);
|
|
@@ -7250,7 +7255,7 @@ var GitBuffer = class {
|
|
|
7250
7255
|
async showCommit() {
|
|
7251
7256
|
let indexed = await this.repo.isIndexed(this.relpath);
|
|
7252
7257
|
if (!indexed) {
|
|
7253
|
-
import_coc13.window.
|
|
7258
|
+
import_coc13.window.showWarningMessage(`"${this.relpath}" not indexed.`);
|
|
7254
7259
|
return;
|
|
7255
7260
|
}
|
|
7256
7261
|
let nvim = import_coc13.workspace.nvim;
|
|
@@ -7261,7 +7266,7 @@ var GitBuffer = class {
|
|
|
7261
7266
|
if (!output.length) return;
|
|
7262
7267
|
let commit = output.match(/^\S+/)[0];
|
|
7263
7268
|
if (/^0+$/.test(commit)) {
|
|
7264
|
-
import_coc13.window.
|
|
7269
|
+
import_coc13.window.showWarningMessage("not committed yet!");
|
|
7265
7270
|
return;
|
|
7266
7271
|
}
|
|
7267
7272
|
let useFloating = this.config.showCommitInFloating;
|
|
@@ -7298,12 +7303,20 @@ var GitBuffer = class {
|
|
|
7298
7303
|
if (!doc) return;
|
|
7299
7304
|
let infos = this.currentSigns;
|
|
7300
7305
|
if (!infos || infos.length == 0) {
|
|
7301
|
-
import_coc13.window.
|
|
7306
|
+
import_coc13.window.showWarningMessage("No changes");
|
|
7302
7307
|
return;
|
|
7303
7308
|
}
|
|
7304
7309
|
let lnums = infos.map((o) => o.lnum);
|
|
7310
|
+
let foldContext = this.config.foldContext;
|
|
7311
|
+
let max = this.doc.lineCount;
|
|
7305
7312
|
let ranges = [];
|
|
7306
7313
|
let start = null;
|
|
7314
|
+
const addRange = (from, to) => {
|
|
7315
|
+
let s = plus(from, foldContext, max);
|
|
7316
|
+
let e = minus(to, foldContext, 0);
|
|
7317
|
+
if (e - s <= 0) return;
|
|
7318
|
+
ranges.push([s, e]);
|
|
7319
|
+
};
|
|
7307
7320
|
for (let i = 1; i <= doc.lineCount; i++) {
|
|
7308
7321
|
let fold = lnums.indexOf(i) == -1;
|
|
7309
7322
|
if (fold && start == null) {
|
|
@@ -7311,11 +7324,11 @@ var GitBuffer = class {
|
|
|
7311
7324
|
continue;
|
|
7312
7325
|
}
|
|
7313
7326
|
if (start != null && !fold) {
|
|
7314
|
-
|
|
7327
|
+
addRange(start, i - 1);
|
|
7315
7328
|
start = null;
|
|
7316
7329
|
}
|
|
7317
7330
|
if (start != null && fold && i == doc.lineCount) {
|
|
7318
|
-
|
|
7331
|
+
addRange(start, i);
|
|
7319
7332
|
}
|
|
7320
7333
|
}
|
|
7321
7334
|
let enabled = this.foldEnabled;
|
|
@@ -7334,6 +7347,8 @@ var GitBuffer = class {
|
|
|
7334
7347
|
nvim.call("setpos", [".", cursor], true);
|
|
7335
7348
|
await nvim.resumeNotification();
|
|
7336
7349
|
} else {
|
|
7350
|
+
console.log(33);
|
|
7351
|
+
console.log(ranges);
|
|
7337
7352
|
this.foldEnabled = true;
|
|
7338
7353
|
let [foldmethod, foldenable, foldlevel] = await nvim.eval("[&foldmethod,&foldenable,&foldlevel]");
|
|
7339
7354
|
this.foldSettings = {
|
|
@@ -7521,6 +7536,16 @@ var GitBuffer = class {
|
|
|
7521
7536
|
this.currentSigns = void 0;
|
|
7522
7537
|
}
|
|
7523
7538
|
};
|
|
7539
|
+
function plus(val, count, max) {
|
|
7540
|
+
if (!count) return val;
|
|
7541
|
+
val = val + count;
|
|
7542
|
+
return Math.min(max, val);
|
|
7543
|
+
}
|
|
7544
|
+
function minus(val, count, min) {
|
|
7545
|
+
if (!count) return val;
|
|
7546
|
+
val = val - count;
|
|
7547
|
+
return Math.max(min, val);
|
|
7548
|
+
}
|
|
7524
7549
|
|
|
7525
7550
|
// src/model/service.ts
|
|
7526
7551
|
var import_path8 = __toESM(require("path"));
|
|
@@ -7873,10 +7898,10 @@ async function activate(context) {
|
|
|
7873
7898
|
const { subscriptions } = context;
|
|
7874
7899
|
let gitInfo;
|
|
7875
7900
|
try {
|
|
7876
|
-
let pathHint = config.get("command");
|
|
7901
|
+
let pathHint = config.get("command", "git");
|
|
7877
7902
|
gitInfo = await findGit(pathHint, (path9) => context.logger.info(`Looking for git in: ${path9}`));
|
|
7878
7903
|
} catch (e) {
|
|
7879
|
-
import_coc16.window.
|
|
7904
|
+
import_coc16.window.showErrorMessage("git command required for coc-git");
|
|
7880
7905
|
return;
|
|
7881
7906
|
}
|
|
7882
7907
|
const virtualTextSrcId = await import_coc16.workspace.nvim.createNamespace("coc-git-virtual");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "coc-git",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.3",
|
|
4
4
|
"description": "Git extension for coc.nvim",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"publisher": "chemzqm",
|
|
@@ -95,6 +95,21 @@
|
|
|
95
95
|
"scope": "window",
|
|
96
96
|
"description": "Remote name for fetch github issues."
|
|
97
97
|
},
|
|
98
|
+
"git.diffOptions": {
|
|
99
|
+
"type": "array",
|
|
100
|
+
"default": [],
|
|
101
|
+
"description": "Options for git diff command, eg: [\"--ignore-all-space\"]",
|
|
102
|
+
"scope": "window",
|
|
103
|
+
"items": {
|
|
104
|
+
"type": "string"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
"git.foldContext": {
|
|
108
|
+
"type": "number",
|
|
109
|
+
"default": 0,
|
|
110
|
+
"scope": "window",
|
|
111
|
+
"description": "Line count to leave below and above the fold."
|
|
112
|
+
},
|
|
98
113
|
"git.browserRemoteName": {
|
|
99
114
|
"type": "string",
|
|
100
115
|
"default": "",
|