coc-git 2.7.9 → 2.7.11
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/AGENTS.md +61 -0
- package/LICENCE +19 -0
- package/Readme.md +58 -13
- package/history.md +13 -1
- package/lib/index.js +1599 -267
- package/package.json +21 -1
package/AGENTS.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
## Repository purpose
|
|
4
|
+
|
|
5
|
+
`coc-git` is the Git integration extension for `coc.nvim`. Its runtime entry point is `src/index.ts`; the published entry point is the bundled `lib/index.js`. The extension owns Git-backed buffer state, gutters and blame text, conflict actions, Coc lists, GitHub/GitLab issue completion, and the commands/keymaps declared in `package.json`.
|
|
6
|
+
|
|
7
|
+
## Code map
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
- `src/index.ts` is the activation and registration layer. Register new Coc commands, `<Plug>` keymaps, lists, completion providers, and disposables here.
|
|
11
|
+
- `src/manager.ts` coordinates editor events, live `GitBuffer` instances, configuration, and user-facing operations.
|
|
12
|
+
- `src/model/git.ts` is the low-level child-process wrapper around the configured Git executable.
|
|
13
|
+
- `src/model/repo.ts` implements repository-scoped Git operations; put Git command construction and output parsing there rather than in the activation layer.
|
|
14
|
+
- `src/model/resolver.ts` resolves documents and working directories to repositories and relative paths.
|
|
15
|
+
- `src/model/buffer.ts` owns per-buffer diffs, signs, blame, folds, and conflict state.
|
|
16
|
+
- `src/model/service.ts` owns resolver/repository lifetimes and constructs `GitBuffer` instances.
|
|
17
|
+
- `src/lists/` contains Coc list implementations (`gstatus`, `gfiles`, `gchanges`, `gchunks`, `branches`, `commits`, and `bcommits`). List-specific actions and rendering belong in the corresponding list class.
|
|
18
|
+
- `src/source.ts` implements GitHub/GitLab issue loading plus the `issues` list/completion source.
|
|
19
|
+
- `src/types.ts` is the shared contract for diffs, conflicts, and the configuration object passed into buffer/model code.
|
|
20
|
+
- `package.json` is also the Coc extension manifest: command names, activation, and all user-visible configuration schemas live there.
|
|
21
|
+
- `Readme.md` documents the public commands, keymaps, lists, environment variables, and settings.
|
|
22
|
+
|
|
23
|
+
## Public-contract synchronization
|
|
24
|
+
|
|
25
|
+
When changing a user-facing feature, update every surface that represents the same contract:
|
|
26
|
+
|
|
27
|
+
- A new `git.*` command needs a `commands.registerCommand` registration in `src/index.ts` and an entry under `contributes.commands` in `package.json`. Add it to `Readme.md` when it is intended for direct use.
|
|
28
|
+
- A new `<Plug>(coc-git-...)` mapping needs a `workspace.registerKeymap` registration in `src/index.ts` and matching usage documentation in `Readme.md`.
|
|
29
|
+
- A new `git.*` setting needs a schema entry under `contributes.configuration.properties` in `package.json`, a typed field in `src/types.ts` when consumed beyond the registration layer, and loading/default logic in `DocumentManager.loadConfiguration()` in `src/manager.ts`. Keep defaults identical across those locations and `Readme.md`.
|
|
30
|
+
- A new list must be implemented under `src/lists/`, registered through `listManager` in `src/index.ts`, and added to the documented list names.
|
|
31
|
+
- Preserve the exported `ExtensionApi` shape in `src/index.ts` unless the API change is intentional; other Coc extensions can consume `git`, `resolver`, and `manager` from activation.
|
|
32
|
+
|
|
33
|
+
## Git and editor behavior
|
|
34
|
+
|
|
35
|
+
- Use the configured executable discovered from `git.command`; do not hard-code an executable path. Model-layer Git execution should flow through `Git`, `GitRepo`, or the existing command helpers.
|
|
36
|
+
- Keep Git work asynchronous. Do not introduce synchronous child-process calls into buffer refresh, cursor movement, completion, or list loading paths.
|
|
37
|
+
- Pass arguments as arrays to `Git.exec`, `Git.stream`, or `spawnCommand` when filenames or revisions are involved. The repository already supports paths containing spaces; avoid building an unescaped shell string unless the operation specifically requires an interactive terminal command.
|
|
38
|
+
- Preserve cancellation and disposal behavior around spawned processes and Coc event listeners. Anything registered during activation or manager construction must be owned by the existing `subscriptions`/`disposables` lifecycle.
|
|
39
|
+
- Buffer refreshes are event-driven (`TextChange`, writes when realtime gutters are disabled, `FocusGained`, and `BufEnter`). Changes to diff or blame behavior must account for stale async results and for buffers disposed while repository resolution is still running.
|
|
40
|
+
- Keep Vim and Neovim compatibility. Virtual text, floating windows, namespaces, terminal operations, and popup behavior must retain the existing capability checks or Coc abstractions; do not use a Neovim-only API on an unconditional path.
|
|
41
|
+
- Git output is normalized under `LC_ALL`/`LANG=en_US.UTF-8` and decoded through `iconv-lite`. Parsing code must not depend on the user's localized Git messages.
|
|
42
|
+
- GitHub issue access uses `GITHUB_API_TOKEN`; GitLab access uses `GITLAB_PRIVATE_TOKEN` and `git.gitlab.hosts`. Do not log tokens or put them into rendered list/completion items.
|
|
43
|
+
|
|
44
|
+
## Generated output and dependencies
|
|
45
|
+
|
|
46
|
+
- Do not edit or commit `lib/index.js`; `lib/` is generated and ignored. Change TypeScript under `src/` and rebuild it with `npm run build`.
|
|
47
|
+
- `esbuild.js` must continue to bundle `src/index.ts` for Node while leaving `coc.nvim` external. The bundle target is `node10.12`; avoid emitting runtime syntax or APIs that violate that target unless the target is deliberately raised.
|
|
48
|
+
- Use npm for dependency and lockfile changes. CI installs with `npm ci`, so `package.json` and `package-lock.json` must stay synchronized.
|
|
49
|
+
- `npm run lint` is TypeScript checking (`tsc -p tsconfig.json`), not an ESLint formatting pass. The project enables `noUnusedLocals` and emits nothing during this check.
|
|
50
|
+
|
|
51
|
+
## Verification
|
|
52
|
+
|
|
53
|
+
Run checks according to the affected subsystem:
|
|
54
|
+
|
|
55
|
+
- Type/config/registration changes: `npm run lint` and `npm run build`.
|
|
56
|
+
- Git parsing, repository, buffer, manager, list, source, command, or keymap behavior: `npm test`.
|
|
57
|
+
- Vim-specific behavior: `npm run test:integration:vim`.
|
|
58
|
+
- Neovim-specific behavior: `npm run test:integration:nvim`.
|
|
59
|
+
- Changes intended to pass CI must succeed in both editor variants. The GitHub Actions matrix uses Node 22 and runs typechecking plus the Vim and Neovim integration suites.
|
|
60
|
+
|
|
61
|
+
For manual editor verification, load the rebuilt extension through Coc and exercise the exact public surface changed: the relevant `:CocCommand git.*`, `<Plug>(coc-git-*)` mapping, `:CocList` list, gutter/blame update, conflict action, or issue completion flow. Use a temporary Git repository containing the required staged, unstaged, untracked, renamed, conflicted, or non-UTF-8-path state rather than testing against this checkout's working tree.
|
package/LICENCE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright 2026 chemzqm@gmail.com
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the "Software"),
|
|
5
|
+
to deal in the Software without restriction, including without limitation
|
|
6
|
+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
7
|
+
and/or sell copies of the Software, and to permit persons to whom the
|
|
8
|
+
Software is furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included
|
|
11
|
+
in all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
14
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
15
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
16
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
17
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
18
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
|
19
|
+
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/Readme.md
CHANGED
|
@@ -26,6 +26,7 @@ In your vim/neovim, run command:
|
|
|
26
26
|
- Always refresh on TextChange.
|
|
27
27
|
- Powerful list support.
|
|
28
28
|
- Semantic commit and github issues completion support.
|
|
29
|
+
- Undo, stage & unstage change chunk under current cursor.
|
|
29
30
|
|
|
30
31
|
## Features
|
|
31
32
|
|
|
@@ -39,6 +40,7 @@ In your vim/neovim, run command:
|
|
|
39
40
|
- Keymaps & commands for git conflicts.
|
|
40
41
|
- Completion support for semantic commit.
|
|
41
42
|
- Completion support for GitHub/GitLab issues.
|
|
43
|
+
- Browse files changed by any commit in a read-only `Commit Files` TreeView.
|
|
42
44
|
|
|
43
45
|
**Note** for GitHub issues completion support:
|
|
44
46
|
|
|
@@ -148,6 +150,10 @@ In your vim/neovim, run command:
|
|
|
148
150
|
|
|
149
151
|
- `git.showCommitInFloating`: Show commit in floating or popup window, default: `false`
|
|
150
152
|
|
|
153
|
+
- `git.commitFiles.splitCommand`: Command used to open the changed-files TreeView for a commit, default: `"belowright 40vs"`
|
|
154
|
+
|
|
155
|
+
- `git.statusTree.splitCommand`: Command used to open the Git status TreeView, default: `"belowright 40vs"`
|
|
156
|
+
|
|
151
157
|
- `git.floatConfig`: Configure style of float window/popup, extends from floatFactory.floatConfig, default: `{}`.
|
|
152
158
|
|
|
153
159
|
- `git.gitlab.hosts`: Custom GitLab hosts, default: `["gitlab.com"]`
|
|
@@ -275,6 +281,7 @@ related commands.
|
|
|
275
281
|
- `:CocCommand git.copyUrl` Copy url of current line to clipboard.
|
|
276
282
|
- `:CocCommand git.copyPermalink` Copy a permalink for the current line to clipboard.
|
|
277
283
|
- `:CocCommand git.refresh` Refresh Git information for all buffers.
|
|
284
|
+
- `:CocCommand git.statusTree` Open files reported by Git status in a TreeView. File nodes show staged and unstaged status; opening a file jumps to its first changed line when Git can determine one.
|
|
278
285
|
- `:CocCommand git.nextChunk` Navigate to the next chunk.
|
|
279
286
|
- `:CocCommand git.prevChunk` Navigate to the previous chunk.
|
|
280
287
|
- `:CocCommand git.chunkInfo` Show chunk info under cursor.
|
|
@@ -287,6 +294,7 @@ related commands.
|
|
|
287
294
|
- `:CocCommand git.chunkUnstage` Unstage chunk that contains current line.
|
|
288
295
|
- `:CocCommand git.diffCached` Show cached diff in preview window.
|
|
289
296
|
- `:CocCommand git.showCommit` Show commit of current chunk.
|
|
297
|
+
- `:CocCommand git.showCommitTree` Open the commit associated with the current tracked line in the `Commit Files` TreeView, show the historical file, and jump to its blamed line.
|
|
290
298
|
- `:CocCommand git.showBlameDoc` Show blame details for the current line.
|
|
291
299
|
- `:CocCommand git.browserOpen` Open current line in browser
|
|
292
300
|
- `:CocCommand git.foldUnchanged` Fold unchanged lines of current buffer.
|
|
@@ -311,6 +319,56 @@ To move up&down on insertmode, use `<C-j>` and `<C-k>`
|
|
|
311
319
|
|
|
312
320
|
To run a action, press `<tab>` and select the action.
|
|
313
321
|
|
|
322
|
+
#### Commit Files TreeView
|
|
323
|
+
|
|
324
|
+
The `commits` and `bcommits` lists provide a `changes` action that opens the
|
|
325
|
+
selected commit in the `Commit Files` TreeView. The existing `files` action
|
|
326
|
+
continues to open the complete file snapshot through the `gfiles` list.
|
|
327
|
+
|
|
328
|
+
The tree compares an ordinary commit with its parent and an initial commit with
|
|
329
|
+
the empty tree. Merge commits use the first parent by default; choose
|
|
330
|
+
`Select parent…` from the root node actions to compare another parent. The root
|
|
331
|
+
node starts expanded, and pressing `<CR>` on it runs `Show commit`. Pressing
|
|
332
|
+
`<CR>` on a directory toggles it, while pressing `<CR>` on a file runs
|
|
333
|
+
`Show code`.
|
|
334
|
+
|
|
335
|
+
`Show code`, `Open before version`, `Open after version`, and
|
|
336
|
+
`Open working tree file` open in the editor window that was active before the
|
|
337
|
+
TreeView. For a text file, `Show code` opens a read-only
|
|
338
|
+
`coc-git://<commit>/<path>` buffer with `buftype=nofile` and detects the
|
|
339
|
+
filetype from its path. Added lines use the `DiffAdd` background, and deleted
|
|
340
|
+
lines are rendered as virtual text using `DiffDelete`. Deleted files open their
|
|
341
|
+
complete parent version; binary and non-blob entries show object metadata
|
|
342
|
+
instead of text decorations.
|
|
343
|
+
|
|
344
|
+
Use `<Plug>(coc-git-nextchunk)`, `<Plug>(coc-git-prevchunk)`, `git.nextChunk`,
|
|
345
|
+
or `git.prevChunk` to navigate changed blocks in a `coc-git://` buffer. The
|
|
346
|
+
navigation wraps when Vim's `wrapscan` option is enabled.
|
|
347
|
+
|
|
348
|
+
When the buffer that opened the TreeView is one of the changed files, its
|
|
349
|
+
parent directories are expanded and the file is focused. `git.showCommitTree`
|
|
350
|
+
also opens that file's historical code automatically and places the cursor on
|
|
351
|
+
the original line reported by `git blame`. The command reports the existing
|
|
352
|
+
untracked or uncommitted-line warning when Git cannot associate the current
|
|
353
|
+
line with a commit.
|
|
354
|
+
|
|
355
|
+
Use `git.commitFiles.splitCommand` to configure how the TreeView split opens.
|
|
356
|
+
|
|
357
|
+
#### Git Status TreeView
|
|
358
|
+
|
|
359
|
+
Use `:CocCommand git.statusTree` to display staged, unstaged, conflicted, and
|
|
360
|
+
untracked files grouped by directory. Each file shows Git's two-column status
|
|
361
|
+
and a readable staged/unstaged description. Press `<CR>` on a file to open its
|
|
362
|
+
working-tree version in the previous editor window. For tracked files, the
|
|
363
|
+
cursor moves to the first changed line when Git provides a diff location;
|
|
364
|
+
otherwise it opens at line 1. Files deleted from the working tree open the
|
|
365
|
+
read-only `HEAD` version through the `coc-git:` scheme. The root node refreshes
|
|
366
|
+
the status snapshot. File actions follow each file's status: `Add` stages
|
|
367
|
+
unstaged or untracked files, `Restore staged changes` unstages a file, and
|
|
368
|
+
`Restore working tree changes` discards its tracked working-tree changes.
|
|
369
|
+
|
|
370
|
+
Use `git.statusTree.splitCommand` to configure how the TreeView split opens.
|
|
371
|
+
|
|
314
372
|
For more advance usage, checkout `:h coc-list`.
|
|
315
373
|
|
|
316
374
|
### Issue autocomplete from multiple GitHub repositories
|
|
@@ -324,19 +382,6 @@ An issue repository specifier looks like this: `github/neoclide/coc-git`.
|
|
|
324
382
|
|
|
325
383
|
Multiple repositories can be specified using comma separation, like this: `github/neoclide/coc-git,github/neoclide/coc.nvim`
|
|
326
384
|
|
|
327
|
-
## F.A.Q
|
|
328
|
-
|
|
329
|
-
Q: Virtual text not working.
|
|
330
|
-
|
|
331
|
-
A: Make sure your neovim/vim support virtual text by command `:echo has('nvim-0.5.0') || has('patch-9.0.0067')`.
|
|
332
|
-
|
|
333
|
-
## Supporting
|
|
334
|
-
|
|
335
|
-
If you like my extension, consider supporting me on Patreon or PayPal:
|
|
336
|
-
|
|
337
|
-
<a href="https://www.patreon.com/chemzqm"><img src="https://c5.patreon.com/external/logo/become_a_patron_button.png" alt="Patreon donate button" /> </a>
|
|
338
|
-
<a href="https://www.paypal.com/paypalme/chezqm"><img src="https://werwolv.net/assets/paypal_banner.png" alt="PayPal donate button" /> </a>
|
|
339
|
-
|
|
340
385
|
## License
|
|
341
386
|
|
|
342
387
|
MIT
|
package/history.md
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
|
+
## 2.7.11
|
|
2
|
+
|
|
3
|
+
- add AGENTS.md (34ea156)
|
|
4
|
+
- feat: add git status tree view (4bc3f6e)
|
|
5
|
+
|
|
6
|
+
## 2.7.10
|
|
7
|
+
|
|
8
|
+
- docs: add MIT license (172bdca)
|
|
9
|
+
- feat: add commit files TreeView (189d331)
|
|
10
|
+
|
|
1
11
|
## 2.7.9
|
|
2
12
|
|
|
13
|
+
- show complete commit files as decorated coc-git virtual documents with chunk navigation
|
|
3
14
|
- docs: add coc-git logo (992064f)
|
|
4
15
|
- feat: show staged git gutters and navigate chunks (9410092)
|
|
5
16
|
- jump to the current code (641396b)
|
|
6
17
|
- fix typo in warning (#222) (9317050)
|
|
7
18
|
|
|
8
19
|
## 2.7.8
|
|
9
|
-
|
|
20
|
+
- add git.showCommitTree for the commit associated with the current line
|
|
21
|
+
- fix historical code cursor positioning after virtual document loading
|
|
10
22
|
- use node24 for CI (eacd2a2)
|
|
11
23
|
- fix uuid, use commonjs version (8ab1a44)
|
|
12
24
|
- fix: narrow vim call results (b72ad90)
|