@statiolake/coc-git 0.1.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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 statiolake
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
package/README.md ADDED
@@ -0,0 +1,6 @@
1
+ # coc-git
2
+
3
+ Git integration for coc.nvim: buffer signs, hunk actions, current-line blame,
4
+ and a VS Code-style Source Control container with Changes and History views in
5
+ the primary sidebar supplied by `@statiolake/coc-ui`. The Activity Bar switches
6
+ to Source Control, then Changes and History remain mounted as stacked Views.
package/lib/index.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ import { ExtensionContext } from "coc.nvim";
2
+ export type GitFile = {
3
+ root: string;
4
+ path: string;
5
+ status: string;
6
+ };
7
+ export type GitCommit = {
8
+ root: string;
9
+ hash: string;
10
+ subject: string;
11
+ decoration: string;
12
+ };
13
+ export type GitHunk = {
14
+ header: string;
15
+ start: number;
16
+ count: number;
17
+ oldStart: number;
18
+ oldCount: number;
19
+ preamble: string;
20
+ body: string;
21
+ patch: string;
22
+ };
23
+ export interface CocGitApi {
24
+ repositoryRoot(filename?: string): Promise<string | undefined>;
25
+ changedFiles(root?: string): Promise<GitFile[]>;
26
+ history(root?: string, filename?: string): Promise<GitCommit[]>;
27
+ diff(root: string, args: string[]): Promise<string>;
28
+ showChanges(): Promise<void>;
29
+ showHistory(): Promise<void>;
30
+ }
31
+ export declare function activate(context: ExtensionContext): Promise<CocGitApi>;
package/lib/index.js ADDED
@@ -0,0 +1,524 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ activate: () => activate
34
+ });
35
+ module.exports = __toCommonJS(index_exports);
36
+ var import_node_child_process = require("node:child_process");
37
+ var import_node_util = require("node:util");
38
+ var import_node_path = __toESM(require("node:path"));
39
+ var import_coc = require("coc.nvim");
40
+ var execFileAsync = (0, import_node_util.promisify)(import_node_child_process.execFile);
41
+ var signGroup = "CocGit";
42
+ var GitChangesProvider = class {
43
+ constructor(git) {
44
+ this.git = git;
45
+ }
46
+ changeEmitter = new import_coc.Emitter();
47
+ onDidChangeTreeData = this.changeEmitter.event;
48
+ refresh() {
49
+ this.changeEmitter.fire();
50
+ }
51
+ async getChildren() {
52
+ return this.git.changedFiles();
53
+ }
54
+ getTreeItem(file) {
55
+ const item = new import_coc.TreeItem(
56
+ import_coc.Uri.file(import_node_path.default.join(file.root, file.path)),
57
+ import_coc.TreeItemCollapsibleState.None
58
+ );
59
+ item.description = file.status;
60
+ item.tooltip = `${file.status} ${file.path}`;
61
+ item.command = {
62
+ command: "coc-git.openFile",
63
+ title: "Open",
64
+ arguments: [file]
65
+ };
66
+ return item;
67
+ }
68
+ };
69
+ var GitHistoryProvider = class {
70
+ constructor(git) {
71
+ this.git = git;
72
+ }
73
+ changeEmitter = new import_coc.Emitter();
74
+ onDidChangeTreeData = this.changeEmitter.event;
75
+ refresh() {
76
+ this.changeEmitter.fire();
77
+ }
78
+ async getChildren() {
79
+ return this.git.history();
80
+ }
81
+ getTreeItem(commit) {
82
+ const item = new import_coc.TreeItem(`${commit.hash.slice(0, 10)} ${commit.subject}`);
83
+ item.description = commit.decoration;
84
+ item.tooltip = `${commit.hash}
85
+ ${commit.subject}`;
86
+ item.command = {
87
+ command: "coc-git.showCommit",
88
+ title: "Show Commit",
89
+ arguments: [commit]
90
+ };
91
+ return item;
92
+ }
93
+ };
94
+ var Git = class {
95
+ constructor(ui, context) {
96
+ this.ui = ui;
97
+ const container = ui.registerViewContainer({
98
+ id: "git",
99
+ title: "Source Control",
100
+ icon: "\uE702",
101
+ location: "primarySidebar",
102
+ order: 2
103
+ });
104
+ const changesView = ui.registerView({
105
+ id: "git.changes",
106
+ containerId: "git",
107
+ name: "Changes",
108
+ order: 1
109
+ });
110
+ const changesTree = ui.createTreeView("git.changes", {
111
+ treeDataProvider: this.changes
112
+ });
113
+ const historyView = ui.registerView({
114
+ id: "git.history",
115
+ containerId: "git",
116
+ name: "History",
117
+ order: 2
118
+ });
119
+ const historyTree = ui.createTreeView("git.history", {
120
+ treeDataProvider: this.commits
121
+ });
122
+ context.subscriptions.push(
123
+ container,
124
+ changesView,
125
+ changesTree,
126
+ historyView,
127
+ historyTree,
128
+ import_coc.commands.registerCommand("coc-git.showChanges", () => this.showChanges()),
129
+ import_coc.commands.registerCommand("coc-git.showHistory", () => this.showHistory()),
130
+ import_coc.commands.registerCommand(
131
+ "coc-git.refresh",
132
+ () => this.refreshCurrentDocument()
133
+ ),
134
+ import_coc.commands.registerCommand("coc-git.nextHunk", () => this.moveHunk(1)),
135
+ import_coc.commands.registerCommand("coc-git.prevHunk", () => this.moveHunk(-1)),
136
+ import_coc.commands.registerCommand(
137
+ "coc-git.stageHunk",
138
+ () => this.applyCurrentHunk("stage")
139
+ ),
140
+ import_coc.commands.registerCommand(
141
+ "coc-git.stageSelection",
142
+ () => this.applySelection("stage")
143
+ ),
144
+ import_coc.commands.registerCommand(
145
+ "coc-git.unstageHunk",
146
+ () => this.applyCurrentHunk("unstage")
147
+ ),
148
+ import_coc.commands.registerCommand(
149
+ "coc-git.resetHunk",
150
+ () => this.applyCurrentHunk("reset")
151
+ ),
152
+ import_coc.commands.registerCommand(
153
+ "coc-git.resetSelection",
154
+ () => this.applySelection("reset")
155
+ ),
156
+ import_coc.commands.registerCommand("coc-git.stageBuffer", () => this.stageBuffer()),
157
+ import_coc.commands.registerCommand("coc-git.resetBuffer", () => this.resetBuffer()),
158
+ import_coc.commands.registerCommand("coc-git.previewHunk", () => this.previewHunk()),
159
+ import_coc.commands.registerCommand("coc-git.blameLine", () => this.blameLine()),
160
+ import_coc.commands.registerCommand("coc-git.toggleBlame", () => this.toggleBlame()),
161
+ import_coc.commands.registerCommand(
162
+ "coc-git.openFile",
163
+ (file) => this.openFile(file)
164
+ ),
165
+ import_coc.commands.registerCommand(
166
+ "coc-git.showCommit",
167
+ (commit) => this.showCommit(commit)
168
+ ),
169
+ import_coc.workspace.onDidOpenTextDocument(
170
+ (document) => this.scheduleRefresh(document.uri)
171
+ ),
172
+ import_coc.workspace.onDidSaveTextDocument(
173
+ (document) => this.scheduleRefresh(document.uri)
174
+ ),
175
+ import_coc.workspace.registerAutocmd({
176
+ event: "BufEnter",
177
+ callback: () => this.refreshCurrentDocument()
178
+ }),
179
+ import_coc.workspace.registerAutocmd({
180
+ event: "CursorHold",
181
+ callback: () => this.refreshBlame()
182
+ })
183
+ );
184
+ void this.defineSigns();
185
+ void this.refreshCurrentDocument();
186
+ }
187
+ changes = new GitChangesProvider(this);
188
+ commits = new GitHistoryProvider(this);
189
+ signBuffers = /* @__PURE__ */ new Set();
190
+ blameBuffers = /* @__PURE__ */ new Set();
191
+ blameNamespace;
192
+ refreshTimers = /* @__PURE__ */ new Map();
193
+ async repositoryRoot(filename) {
194
+ const target = filename ? import_node_path.default.dirname(filename) : import_coc.workspace.rootPath || import_coc.workspace.cwd;
195
+ try {
196
+ return (await this.git(target, ["rev-parse", "--show-toplevel"])).trim();
197
+ } catch {
198
+ return void 0;
199
+ }
200
+ }
201
+ async changedFiles(root) {
202
+ const repository = root ?? await this.repositoryRoot();
203
+ if (!repository) return [];
204
+ const output = await this.git(repository, [
205
+ "status",
206
+ "--porcelain=v1",
207
+ "-u"
208
+ ]);
209
+ return output.split("\n").filter(Boolean).map((line) => ({
210
+ root: repository,
211
+ status: line.slice(0, 2),
212
+ path: line.slice(3).split(" -> ").at(-1)
213
+ }));
214
+ }
215
+ async history(root, filename) {
216
+ const repository = root ?? await this.repositoryRoot(filename);
217
+ if (!repository) return [];
218
+ const maxEntries = Math.max(
219
+ 1,
220
+ import_coc.workspace.getConfiguration("coc-git").get("history.maxEntries", 100)
221
+ );
222
+ const args = [
223
+ "log",
224
+ `--max-count=${maxEntries}`,
225
+ "--format=%H%x1f%D%x1f%s"
226
+ ];
227
+ if (filename) args.push("--", import_node_path.default.relative(repository, filename));
228
+ const output = await this.git(repository, args);
229
+ return output.split("\n").filter(Boolean).map((line) => {
230
+ const [hash, decoration, subject] = line.split("");
231
+ return { root: repository, hash, decoration, subject };
232
+ });
233
+ }
234
+ async diff(root, args) {
235
+ return this.git(root, args);
236
+ }
237
+ async showChanges() {
238
+ this.changes.refresh();
239
+ await this.ui.showView("git.changes");
240
+ }
241
+ async showHistory() {
242
+ this.commits.refresh();
243
+ await this.ui.showView("git.history");
244
+ }
245
+ dispose() {
246
+ for (const timer of this.refreshTimers.values()) clearTimeout(timer);
247
+ this.refreshTimers.clear();
248
+ }
249
+ async refreshCurrentDocument() {
250
+ const document = await import_coc.workspace.document;
251
+ await this.refreshDocument(document.textDocument.uri);
252
+ }
253
+ scheduleRefresh(uri) {
254
+ const existing = this.refreshTimers.get(uri);
255
+ if (existing) clearTimeout(existing);
256
+ this.refreshTimers.set(
257
+ uri,
258
+ setTimeout(() => void this.refreshDocument(uri), 120)
259
+ );
260
+ }
261
+ async refreshDocument(uri) {
262
+ if (!import_coc.workspace.getConfiguration("coc-git").get("enable", true))
263
+ return;
264
+ const document = import_coc.workspace.getDocument(uri);
265
+ const resource = document && import_coc.Uri.parse(document.textDocument.uri);
266
+ if (!document || !resource || resource.scheme !== "file") return;
267
+ const filename = resource.fsPath;
268
+ const root = await this.repositoryRoot(filename);
269
+ if (!root) return;
270
+ const hunks = await this.hunks(root, filename);
271
+ document.buffer.unplaceSign({ group: signGroup });
272
+ this.signBuffers.add(document.bufnr);
273
+ for (const [index, hunk] of hunks.entries()) {
274
+ document.buffer.placeSign({
275
+ id: index + 1,
276
+ group: signGroup,
277
+ name: signName(hunk),
278
+ lnum: Math.max(1, hunk.start),
279
+ priority: 10
280
+ });
281
+ }
282
+ this.changes.refresh();
283
+ this.commits.refresh();
284
+ }
285
+ async hunks(root, filename, cached = false) {
286
+ const relative = import_node_path.default.relative(root, filename);
287
+ const args = ["diff", "--no-ext-diff", "--unified=0"];
288
+ if (cached) args.push("--cached");
289
+ args.push("--", relative);
290
+ return parseHunks(await this.git(root, args));
291
+ }
292
+ async moveHunk(direction) {
293
+ const state = await this.currentState();
294
+ if (!state) return;
295
+ const line = await import_coc.workspace.nvim.call("line", ["."]);
296
+ const hunks = await this.hunks(state.root, state.filename);
297
+ if (!hunks.length) return;
298
+ const target = direction > 0 ? hunks.find((hunk) => hunk.start > line) ?? hunks[0] : [...hunks].reverse().find((hunk) => hunk.start < line) ?? hunks.at(-1);
299
+ await import_coc.workspace.nvim.call("cursor", [target.start, 0]);
300
+ }
301
+ async applyCurrentHunk(action) {
302
+ const state = await this.currentState();
303
+ if (!state) return;
304
+ const cached = action === "unstage";
305
+ const hunk = await this.currentHunk(state.root, state.filename, cached);
306
+ if (!hunk) return;
307
+ await this.applyHunks(action, state, [hunk]);
308
+ }
309
+ async applySelection(action) {
310
+ const state = await this.currentState();
311
+ if (!state) return;
312
+ const start = await import_coc.workspace.nvim.call("line", ["'<"]);
313
+ const end = await import_coc.workspace.nvim.call("line", ["'>"]);
314
+ const hunks = (await this.hunks(state.root, state.filename)).filter(
315
+ (hunk) => {
316
+ const hunkEnd = hunk.start + Math.max(1, hunk.count) - 1;
317
+ return hunk.start <= end && hunkEnd >= start;
318
+ }
319
+ );
320
+ if (!hunks.length) return;
321
+ await this.applyHunks(action, state, hunks);
322
+ }
323
+ async applyHunks(action, state, hunks) {
324
+ const args = ["apply", "--unidiff-zero"];
325
+ if (action === "stage" || action === "unstage") args.push("--cached");
326
+ if (action === "unstage" || action === "reset") args.push("--reverse");
327
+ await this.gitInput(
328
+ state.root,
329
+ args,
330
+ hunks[0].preamble + hunks.map((hunk) => hunk.body).join("")
331
+ );
332
+ await this.refreshDocument(state.uri);
333
+ }
334
+ async stageBuffer() {
335
+ const state = await this.currentState();
336
+ if (!state) return;
337
+ await this.git(state.root, [
338
+ "add",
339
+ "--",
340
+ import_node_path.default.relative(state.root, state.filename)
341
+ ]);
342
+ await this.refreshDocument(state.uri);
343
+ }
344
+ async resetBuffer() {
345
+ const state = await this.currentState();
346
+ if (!state) return;
347
+ const answer = await import_coc.window.showWarningMessage(
348
+ "Discard all unstaged changes in this file?",
349
+ "Discard"
350
+ );
351
+ if (answer !== "Discard") return;
352
+ await this.git(state.root, [
353
+ "restore",
354
+ "--worktree",
355
+ "--",
356
+ import_node_path.default.relative(state.root, state.filename)
357
+ ]);
358
+ await import_coc.workspace.nvim.command(`edit ${fnameescape(state.filename)}`);
359
+ await this.refreshDocument(state.uri);
360
+ }
361
+ async previewHunk() {
362
+ const state = await this.currentState();
363
+ if (!state) return;
364
+ const hunk = await this.currentHunk(state.root, state.filename);
365
+ if (!hunk) return;
366
+ const output = import_coc.window.createOutputChannel("Coc Git Hunk");
367
+ output.clear();
368
+ output.append(hunk.patch);
369
+ output.show(false);
370
+ }
371
+ async blameLine() {
372
+ const state = await this.currentState();
373
+ if (!state) return void 0;
374
+ const line = await import_coc.workspace.nvim.call("line", ["."]);
375
+ const relative = import_node_path.default.relative(state.root, state.filename);
376
+ const output = await this.git(state.root, [
377
+ "blame",
378
+ "--porcelain",
379
+ "-L",
380
+ `${line},${line}`,
381
+ "--",
382
+ relative
383
+ ]);
384
+ const summary = output.match(/^summary (.+)$/m)?.[1] ?? "";
385
+ const author = output.match(/^author (.+)$/m)?.[1] ?? "";
386
+ const hash = output.match(/^([0-9a-f]{40})/)?.[1]?.slice(0, 10) ?? "";
387
+ const message = [hash, author, summary].filter(Boolean).join(" ");
388
+ if (message) await import_coc.window.showInformationMessage(message);
389
+ return message;
390
+ }
391
+ async toggleBlame() {
392
+ const document = await import_coc.workspace.document;
393
+ const buffer = document.bufnr;
394
+ if (this.blameBuffers.delete(buffer)) {
395
+ if (this.blameNamespace != null)
396
+ document.buffer.clearNamespace(this.blameNamespace);
397
+ return;
398
+ }
399
+ this.blameBuffers.add(buffer);
400
+ if (this.blameNamespace == null)
401
+ this.blameNamespace = await import_coc.workspace.nvim.createNamespace("coc-git-blame");
402
+ await this.refreshBlame();
403
+ }
404
+ async refreshBlame() {
405
+ const document = await import_coc.workspace.document;
406
+ if (!this.blameBuffers.has(document.bufnr)) return;
407
+ const text = await this.blameLine();
408
+ if (!text || this.blameNamespace == null) return;
409
+ const position = await import_coc.window.getCursorPosition();
410
+ document.buffer.clearNamespace(this.blameNamespace);
411
+ document.buffer.setExtMark(this.blameNamespace, position.line, 0, {
412
+ virt_text: [[` ${text}`, "CocGitBlame"]],
413
+ virt_text_pos: "eol"
414
+ });
415
+ }
416
+ async openFile(file) {
417
+ await this.ui.openLocation(
418
+ import_coc.Uri.file(import_node_path.default.join(file.root, file.path)).toString(),
419
+ 0,
420
+ 0
421
+ );
422
+ }
423
+ async showCommit(commit) {
424
+ await import_coc.commands.executeCommand(
425
+ "coc-diffview.showCommit",
426
+ commit.root,
427
+ commit.hash
428
+ );
429
+ }
430
+ async currentHunk(root, filename, cached = false) {
431
+ const line = await import_coc.workspace.nvim.call("line", ["."]);
432
+ const hunks = await this.hunks(root, filename, cached);
433
+ return hunks.find(
434
+ (hunk) => line >= hunk.start && line < hunk.start + Math.max(1, hunk.count)
435
+ );
436
+ }
437
+ async currentState() {
438
+ const document = await import_coc.workspace.document;
439
+ const resource = import_coc.Uri.parse(document.textDocument.uri);
440
+ if (resource.scheme !== "file") return void 0;
441
+ const filename = resource.fsPath;
442
+ const root = await this.repositoryRoot(filename);
443
+ return root ? { uri: document.textDocument.uri, filename, root } : void 0;
444
+ }
445
+ async defineSigns() {
446
+ const config = import_coc.workspace.getConfiguration();
447
+ const added = config.get("vimrc.core.signs.diff.added", "+");
448
+ const changed = config.get("vimrc.core.signs.diff.changed", "~");
449
+ const removed = config.get("vimrc.core.signs.diff.removed", "_");
450
+ await import_coc.workspace.nvim.command(
451
+ `sign define CocGitAdd text=${added} texthl=DiffAdd`
452
+ );
453
+ await import_coc.workspace.nvim.command(
454
+ `sign define CocGitChange text=${changed} texthl=DiffChange`
455
+ );
456
+ await import_coc.workspace.nvim.command(
457
+ `sign define CocGitDelete text=${removed} texthl=DiffDelete`
458
+ );
459
+ await import_coc.workspace.nvim.command("highlight default link CocGitBlame Comment");
460
+ }
461
+ async git(cwd, args) {
462
+ const { stdout } = await execFileAsync("git", args, {
463
+ cwd,
464
+ maxBuffer: 10 * 1024 * 1024
465
+ });
466
+ return stdout;
467
+ }
468
+ async gitInput(cwd, args, input) {
469
+ await new Promise((resolve, reject) => {
470
+ const child = (0, import_node_child_process.spawn)("git", args, {
471
+ cwd,
472
+ stdio: ["pipe", "ignore", "pipe"]
473
+ });
474
+ let stderr = "";
475
+ child.stderr.on("data", (chunk) => {
476
+ stderr += String(chunk);
477
+ });
478
+ child.on("error", reject);
479
+ child.on(
480
+ "close",
481
+ (code) => code === 0 ? resolve() : reject(new Error(stderr || `git exited with ${code}`))
482
+ );
483
+ child.stdin.end(input);
484
+ });
485
+ }
486
+ };
487
+ function parseHunks(diff) {
488
+ const matches = [
489
+ ...diff.matchAll(/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@.*$/gm)
490
+ ];
491
+ if (!matches.length) return [];
492
+ const prefix = diff.slice(0, matches[0].index);
493
+ return matches.map((match, index) => ({
494
+ header: match[0],
495
+ oldStart: Number(match[1]),
496
+ oldCount: Number(match[2] ?? 1),
497
+ start: Number(match[3]),
498
+ count: Number(match[4] ?? 1),
499
+ preamble: prefix,
500
+ body: diff.slice(match.index, matches[index + 1]?.index),
501
+ patch: prefix + diff.slice(match.index, matches[index + 1]?.index)
502
+ }));
503
+ }
504
+ function signName(hunk) {
505
+ if (hunk.oldCount === 0) return "CocGitAdd";
506
+ if (hunk.count === 0) return "CocGitDelete";
507
+ return "CocGitChange";
508
+ }
509
+ function fnameescape(filename) {
510
+ return filename.replace(/([\\\s|"'])/g, "\\$1");
511
+ }
512
+ async function activate(context) {
513
+ const extension = import_coc.extensions.getExtensionById("@statiolake/coc-ui");
514
+ if (!extension?.exports)
515
+ throw new Error("@statiolake/coc-ui must be activated before coc-git");
516
+ const git = new Git(extension.exports, context);
517
+ context.subscriptions.push(git);
518
+ return git;
519
+ }
520
+ // Annotate the CommonJS export names for ESM import in node:
521
+ 0 && (module.exports = {
522
+ activate
523
+ });
524
+ //# sourceMappingURL=index.js.map
package/package.json ADDED
@@ -0,0 +1,132 @@
1
+ {
2
+ "name": "@statiolake/coc-git",
3
+ "version": "0.1.0",
4
+ "description": "Git signs, hunk actions, and source control views for coc.nvim",
5
+ "author": "statiolake",
6
+ "license": "MIT",
7
+ "main": "lib/index.js",
8
+ "types": "lib/index.d.ts",
9
+ "engines": {
10
+ "coc": "^0.0.82"
11
+ },
12
+ "extensionDependencies": [
13
+ "@statiolake/coc-ui"
14
+ ],
15
+ "activationEvents": [
16
+ "*"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsc --project tsconfig.build.json && node esbuild.mjs",
20
+ "prepare": "node esbuild.mjs",
21
+ "typecheck": "tsc --noEmit"
22
+ },
23
+ "contributes": {
24
+ "commands": [
25
+ {
26
+ "command": "coc-git.showChanges",
27
+ "title": "Show Source Control Changes"
28
+ },
29
+ {
30
+ "command": "coc-git.showHistory",
31
+ "title": "Show Git History"
32
+ },
33
+ {
34
+ "command": "coc-git.refresh",
35
+ "title": "Refresh Git Decorations"
36
+ },
37
+ {
38
+ "command": "coc-git.nextHunk",
39
+ "title": "Go to Next Git Hunk"
40
+ },
41
+ {
42
+ "command": "coc-git.prevHunk",
43
+ "title": "Go to Previous Git Hunk"
44
+ },
45
+ {
46
+ "command": "coc-git.stageHunk",
47
+ "title": "Stage Git Hunk"
48
+ },
49
+ {
50
+ "command": "coc-git.stageSelection",
51
+ "title": "Stage Selected Git Hunks"
52
+ },
53
+ {
54
+ "command": "coc-git.unstageHunk",
55
+ "title": "Unstage Git Hunk"
56
+ },
57
+ {
58
+ "command": "coc-git.resetHunk",
59
+ "title": "Discard Git Hunk"
60
+ },
61
+ {
62
+ "command": "coc-git.resetSelection",
63
+ "title": "Discard Selected Git Hunks"
64
+ },
65
+ {
66
+ "command": "coc-git.stageBuffer",
67
+ "title": "Stage Current Buffer"
68
+ },
69
+ {
70
+ "command": "coc-git.resetBuffer",
71
+ "title": "Discard Current Buffer Changes"
72
+ },
73
+ {
74
+ "command": "coc-git.previewHunk",
75
+ "title": "Preview Git Hunk"
76
+ },
77
+ {
78
+ "command": "coc-git.blameLine",
79
+ "title": "Show Git Blame for Current Line"
80
+ },
81
+ {
82
+ "command": "coc-git.toggleBlame",
83
+ "title": "Toggle Current Line Git Blame"
84
+ },
85
+ {
86
+ "command": "coc-git.openFile",
87
+ "title": "Open Changed File"
88
+ },
89
+ {
90
+ "command": "coc-git.showCommit",
91
+ "title": "Show Commit"
92
+ }
93
+ ],
94
+ "configuration": {
95
+ "type": "object",
96
+ "title": "Coc Git",
97
+ "properties": {
98
+ "coc-git.enable": {
99
+ "type": "boolean",
100
+ "default": true
101
+ },
102
+ "coc-git.history.maxEntries": {
103
+ "type": "number",
104
+ "default": 100,
105
+ "minimum": 1
106
+ }
107
+ }
108
+ }
109
+ },
110
+ "devDependencies": {
111
+ "@statiolake/coc-ui": "git+https://github.com/statiolake/coc-ui.git",
112
+ "@types/node": "^16.18.0",
113
+ "coc.nvim": "^0.0.83-next.24",
114
+ "esbuild": "^0.25.0",
115
+ "typescript": "^5.3.3"
116
+ },
117
+ "repository": {
118
+ "type": "git",
119
+ "url": "git+https://github.com/statiolake/coc-git.git"
120
+ },
121
+ "bugs": {
122
+ "url": "https://github.com/statiolake/coc-git/issues"
123
+ },
124
+ "homepage": "https://github.com/statiolake/coc-git#readme",
125
+ "publishConfig": {
126
+ "access": "public"
127
+ },
128
+ "files": [
129
+ "lib/index.js",
130
+ "lib/index.d.ts"
131
+ ]
132
+ }