Repository navigation
feat: complete the autosquash prefixes and the commit titles - #92
Merged
Merged
Conversation
On line 1 of a commit message, cmp-git now completes the subjects that `git rebase --autosquash` reads: - The prefix words: `fi`, `sq`, and `am` give `fixup!`, `squash!`, and `amend!`. `git.autosquash.prefixes` sets the words and the minimum number of letters (default 2). After a prefix item, the menu opens again with the commit titles. - The commit titles after `fixup!`, `squash!`, and `amend!`, newest first, with one item for each title. The list hides the titles that start with an autosquash prefix. It uses the commit cache and the `git.commits` config, so a cached history starts no new git process. The edit starts after the prefix and its spaces, so a `:`, `#`, `@`, or `!` in the title starts no other completion. The completion works only on line 1, in the filetypes of `git.autosquash.filetypes` (`gitcommit` and `NeogitCommitMessage`). Two new default entries come before the trailer entries: `git_autosquash_prefixes` shares the regex of the trailer keys, and `git_autosquash` has its own pattern and keyword pattern. Core loads only the line checks, which run before the reads of the buffer. Only the git source loads the autosquash capability. The menu reopen uses the `execute` hook of each engine: - nvim-cmp `2ffe79f`: `source.execute(self, item, callback)` calls `self.source:execute(item, callback)` after the insert. cmp-git calls `callback`, then `cmp.complete()` with only the `git` source. - blink.cmp `v1.10.0-258-geece1c5`: `module:execute(context, item, resolve, default_implementation)`. cmp-git calls `default_implementation` and `resolve`, then `blink.show()` with the provider of the item. A test runs `git rebase -i --autosquash` on completed subjects and checks that each commit comes right after its target with `fixup`, `squash`, or `fixup -C`. The keystroke benchmarks get an autosquash line and a declined line 1 request. Fixes #42
petertriho
force-pushed
the
feat/autosquash-completion
branch
from
November 2, 2026 11:05
b620f54 to
87c03ef
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On line 1 of a commit message, cmp-git now completes the subjects that
git rebase --autosquashreads.fi,sq, andamgivefixup!,squash!, andamend!.git.autosquash.prefixessets the words and the minimum number of letters (default 2). After a prefix item, the menu opens again with the commit titles.fixup!,squash!, andamend!, the menu shows the commit titles, newest first, one item for each title. Titles that start with an autosquash prefix are hidden. The list uses the commit cache, so a cached history starts no new git process. A:,#,@, or!in the title starts no other completion.git.autosquash.filetypes(gitcommitandNeogitCommitMessage).README.mdanddocs/configuration.mddescribe the feature, the config, and how to turn off each part.Engine API used for the menu reopen
2ffe79f:source.execute(self, item, callback)callsself.source:execute(item, callback)after the insert. cmp-git callscallback, thencmp.complete()with only thegitsource.v1.10.0-258-geece1c5:module:execute(context, item, resolve, default_implementation). cmp-git callsdefault_implementationandresolve, thenblink.show()with the provider of the item.Test plan
make ci(StyLua, Selene, lua-language-server, 314 tests, 0 fails)make testin thenvim-0_12_0shell (v0.12.0) and thenightlyshell (v0.13.0-nightly+1cfebe9)git rebase -i --autosquashon completed subjects. Each commit comes right after its target withfixup,squash, orfixup -C.make bench-compare: no regression in thekeystroke/groupKnown limits
fwithmin_length = 1: no item until the second letter. nvim-cmp starts no request for the first character typed after insert mode starts, for any source.squash! fixup! x: no item shows. cmp-git gives the titles with the edit aftersquash!, but nvim-cmp filters them onfixup! x, and no title matches. blink.cmp filters on the last word, so it shows the list.require/setupallocates about 23 KB more (+12%), andnew_sourceabout 2.8 KB more.new_source_with_overridesallocates about 2.6 KB more and takes 26% longer. Setup loads the new code, copies the larger defaults, and compiles two more regexes.Fixes #42