Same plugin, reorganized so it's easier to follow and change.
Code
model/ holds the comments and where they are, ui/ what's drawn, export/ the output formats.
comments.lua is the only place comments change, and it keeps the signs in sync.
plugin/ defines the commands. setup() is no longer needed but still works.
Files stay under about 200 lines.
Tests
mini.test replaces the homemade runner. make clones it, pinned, into deps/.
tests/unit covers single modules. tests/features runs the commands.
129 specs, one per behavior, each starting from a clean editor.
Behavior changes
Comments on the same lines sort in the order they were added (comment-10 used to sort before comment-2).
The picker and Markdown export describe locations the way the window title does ("lines 3–5", "line 3, col 5–12"). Quickfix jumps to the selected text.
Neovim 0.12 is the minimum.
Also includes three earlier commits from main: the padding color, the test runner fix, and the single comment window.
Description:
Same plugin, reorganized so it's easier to follow and change.
Code
- model/ holds the comments and where they are, ui/ what's drawn, export/ the output formats.
- comments.lua is the only place comments change, and it keeps the signs in sync.
- plugin/ defines the commands. setup() is no longer needed but still works.
- Files stay under about 200 lines.
Tests
- mini.test replaces the homemade runner. make clones it, pinned, into deps/.
- tests/unit covers single modules. tests/features runs the commands.
- 129 specs, one per behavior, each starting from a clean editor.
Behavior changes
- Comments on the same lines sort in the order they were added (comment-10 used to sort before comment-2).
- The picker and Markdown export describe locations the way the window title does ("lines 3–5", "line 3, col 5–12"). Quickfix jumps to the selected text.
- Neovim 0.12 is the minimum.
Also includes three earlier commits from main: the padding color, the test runner fix, and the single comment window.
The test runner matched FAIL only at the start of a line, but Neovim can
print mode messages before it, so failures showed as ok. It now finds
FAIL anywhere and treats a suite that never reports ok as failed.
That exposed two failures: the padding test still expected the old
winhighlight, and the long title test expected the wrong columns and
measured with strdisplaywidth, which counts linebreak padding in the
current window. Title fitting now uses nvim_strwidth too.
A comment opens in one window, as in Google Docs: :CommentShow shows it
in normal mode, and you edit it there and :w to save. :CommentEdit and
scratch.edit() are gone, and :Comment on a commented range opens the
same window.
:CommentNext and :CommentPrev move any open comment window to the next
or previous comment, a new one included. With unsaved changes they
refuse, like :bnext, so nothing is lost. The title shows the count and
the mode: "comment (3 of 4) [NORMAL]".
make test clones mini.test at a pinned version into deps/, once per
version, and runs tests/**/*_spec.lua in-process before the old suites.
Specs use describe/it/before_each with mini.test's expect, and each one
starts from a reset editor through tests/helpers.lua.
The export suite is the first one ported, as list_export_spec.lua.
reflow.lua and orphans.lua become anchoring_spec.lua, and spans.lua
becomes spans_spec.lua. Each case builds its own buffer instead of
continuing from the edits before it.
In-process specs are enough: helpers fire TextChanged and break undo
blocks where headless Neovim doesn't, and answer vim.ui.select.
smoke.lua becomes commenting, window, show_delete, navigation and signs
specs, plus cases in list_export and anchoring. :e! gets a fixture file
instead of the repo's LICENSE. The old runner and minimal_init.lua go,
so make test runs mini.test only.
Specs for the unnamed-buffer warning, the window border, cancelled
pickers, deleting with nothing to delete, :CommentToggle usage,
navigation with other files or a changed comment, clipboard failure,
sorting across files, nested code fences and :checkhealth.
helpers.notified() runs scheduled notifications before reading them,
and reset flushes them so none reach the next spec.
The store holds the comments and their ids and makes no Neovim calls.
One remove(predicate) replaces remove_ids and remove_buffer. state.lua
keeps only the views: where each comment is now, and its snippet.
markdown.lua, json.lua and the clipboard copy (export.lua) move into
export/, unchanged. Unit specs check the whole markdown output and the
json fields.
Adding, editing, deleting, clearing and forgetting a buffer's comments
go through comments.lua, which keeps anchors and signs in sync, so the
hand-written sign redraws go. state.lua becomes model/views.lua.
ui/window.lua has the two-pane frame and tracks the open comment window,
so the frame no longer needs an on_close hook. ui/notify.lua replaces
notify(message, kind) with info, warn and error.
navigate.jump either cycles the open comment window or moves the cursor
to the next comment's line. Cycling shows a comment, so navigate calls
annotate.show. The buffer's views and index_of move into model/views.
annotate.lua becomes actions.lua, with toggle and clear from init.lua.
Rendering and :CommentExport move into export/init.lua, and ui.lua
becomes ui/quickfix.lua for :CommentList. init.lua is the Lua API and
setup.
Lists that were called items are views, anchored or comments. actions
finds a buffer's comments through views.in_buffer, so views.find and
find_all go. Helpers used only inside their module become local.
plugin/scratch-comments.lua defines the commands and loads the plugin
when one runs. The autocmds and the sign highlight are set when their
modules first load, so nothing runs on text changes before a comment
command has. setup() is kept as a no-op for configs that call it.
The picker and the markdown export use location.describe, the window
title's format: "line 3", "lines 3–5", "line 3, col 5–12". This fixes the
picker's "lines 3" for one line. Quickfix gets a span's columns, so ]q
lands on the text.
Only a new comment opens in insert mode, and :CommentList lands on a
span's text. The wording is plainer throughout. The README now maps the
code layout and says how to run the checks.
eleith
changed title from Rearchitecture to Rearchitect the plugin, with mini.test specs2026-09-22 17:52:24 +00:00
eleith
merged commit 962a2c7f17 into main2026-09-22 17:52:49 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Description:
Same plugin, reorganized so it's easier to follow and change.
Code
Tests
Behavior changes
Also includes three earlier commits from main: the padding color, the test runner fix, and the single comment window.
b9785b3d71to8ef9e7e0fbRearchitectureto Rearchitect the plugin, with mini.test specs