Rearchitect the plugin, with mini.test specs #1

Merged
eleith merged 22 commits from rearchitecture into main 2026-09-22 17:52:49 +00:00
22 Commits
Author SHA1 Message Date
eleith 03f44cac0b Check the docs against the code, and add a development section
ci/woodpecker/pr/ci Pipeline was successful
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.
2026-09-22 10:23:15 -07:00
eleith 537221dd0c Require Neovim 0.12
ci/woodpecker/pr/ci Pipeline was successful
The comment window reads 'winborder', which needs 0.11, and CI tests on
0.12. :checkhealth, the README and the help file now say 0.12.
2026-09-22 10:00:58 -07:00
eleith f5da74b756 Describe locations one way, and put columns in quickfix
ci/woodpecker/pr/ci Pipeline was successful
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.
2026-09-22 09:51:06 -07:00
eleith 4e6987f08e Define the commands in plugin/, without setup()
ci/woodpecker/pr/ci Pipeline was successful
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.
2026-09-22 09:48:03 -07:00
eleith 3cb710ee68 Name lists of comments views, and find them one way
ci/woodpecker/pr/ci Pipeline was successful
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.
2026-09-22 09:44:29 -07:00
eleith 991230b4fa Split the commands into actions, export and quickfix
ci/woodpecker/pr/ci Pipeline was successful
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.
2026-09-22 09:42:09 -07:00
eleith eb4e08c186 Move next and prev into navigate.lua
ci/woodpecker/pr/ci Pipeline was successful
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.
2026-09-22 09:36:50 -07:00
eleith 966409c759 Move the comment window and notifications into ui/
ci/woodpecker/pr/ci Pipeline was successful
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.
2026-09-22 09:25:32 -07:00
eleith b60ab66161 Change comments only through comments.lua
ci/woodpecker/pr/ci Pipeline was successful
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.
2026-09-22 09:22:27 -07:00
eleith 8ef9e7e0fb Split render.lua into anchors and signs
ci/woodpecker/pr/ci Pipeline was successful
model/anchors.lua keeps the extmarks that track where comments are.
ui/signs.lua draws the signs from them and holds their visibility.
2026-09-22 09:16:21 -07:00
eleith aaf7470d4c Group the export modules in export/
ci/woodpecker/pr/ci Pipeline was successful
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.
2026-09-22 09:12:15 -07:00
eleith 2605e731e2 Rename context.lua to paths.lua
ci/woodpecker/pr/ci Pipeline was successful
It finds a file's git root and its path relative to that root, so the
name says so. Its own trim gives way to vim.trim.
2026-09-22 09:10:21 -07:00
eleith a5d15bd89a Describe locations in location.lua
ci/woodpecker/pr/ci Pipeline was successful
The window title's location format becomes location.describe, with
title and fit beside it. A comment view is now a comment plus a
location.
2026-09-22 09:05:12 -07:00
eleith be805ea1bf Order comments on the same lines by their number
ci/woodpecker/pr/ci Pipeline was successful
Ids were compared as text, so comment-10 sorted before comment-2. They
now compare by the number in the id, the order they were added.
2026-09-22 09:02:30 -07:00
eleith 6a7f5d3620 Move the comment list into model/store.lua
ci/woodpecker/pr/ci Pipeline was successful
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.
2026-09-22 08:59:20 -07:00
eleith 360002021f Cover the behavior that had no specs
ci/woodpecker/pr/ci Pipeline was successful
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.
2026-09-22 08:55:08 -07:00
eleith 353f7dc4d9 Split the smoke suite into feature specs
ci/woodpecker/pr/ci Pipeline was successful
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.
2026-09-22 08:52:28 -07:00
eleith ecedd926a7 Port the anchoring and span suites to specs
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.
2026-09-22 08:50:11 -07:00
eleith 63245276bb Run specs with mini.test
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.
2026-09-22 08:48:10 -07:00
eleith c608404576 Make :CommentShow the one comment window
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]".
2026-09-22 07:48:53 -07:00
eleith 5feecab097 Report failing test suites
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.
2026-09-22 07:48:44 -07:00
eleith b723bfe8d0 Color the comment window's padding like its background
The padding column is a statuscolumn, which draws in LineNr, so it
showed as a strip in colorschemes that give LineNr its own background.
2026-09-22 07:19:00 -07:00