Skip to content

feat(providers): add the jumplist and changelist providers - #143

Merged
petertriho merged 1 commit into
mainfrom
feat/jumplist-changelist-providers
Nov 23, 2026
Merged

petertriho merged 1 commit into
mainfrom
feat/jumplist-changelist-providers

Conversation

@petertriho

Copy link
Copy Markdown
Owner

Adds two built-in providers that show where the history keys go from each window, as asked in discussion #64. jumplist marks the <C-o> and <C-i> targets. changelist marks the g; and g, targets. Both are off by default.

require("scrollbar").setup({
    providers = { jumplist = true, changelist = true },
    marks = {
        JumpNewer = false, -- optional: show only the <C-o> target
    },
})

Changes

  • New mark types:

    Mark type Key Text Priority Highlight
    JumpOlder <C-o> < 1 Special
    JumpNewer <C-i> > 1 Special
    ChangeOlder g; « 1 Changed
    ChangeNewer g, » 1 Changed

    The change marks use other glyphs, because the default colorscheme gives Changed and Special the same color. « and » are one cell wide also with ambiwidth=double.

  • No provider options: each provider takes true, false, or the scrollbar and minimap flags. To show one target only, hide the other type with marks.<Type> = false. A hidden type also stays out of label mode and the glance list.

  • Window marks: each list keeps its index in the window, so the marks belong to the window. One rule serves both lists: the older target is at the Lua index pos, and the newer target is at pos + 2, with pos from getjumplist() or getchangelist().

    • A jump target in another buffer gets no mark.
    • After a jump or an edit, the index is at the end of the list. <C-i> then has no target, and g, goes to the same line as g;. Neither case shows a newer mark.
    • A window that is not current is read through nvim_win_call, because both functions read the index of the current window.
  • Updates: a read of a jumplist of 100 entries costs about 55 µs, and no cheaper signal shows a change. The providers read the list of the current window on CursorMoved, BufWinEnter, WinEnter, and InsertLeave. After an edit, they read the windows of the buffer: changelist reads all of them, and jumplist reads only the windows whose line count changed. They drop CursorMovedI and TextChangedI from the scheduler dispatch, so typing in Insert mode reads no list. :clearjumps shows at the next cursor move or at :ScrollbarRefresh.

  • Shared module: lua/scrollbar/providers/position_targets.lua holds the target rule, the window read, and the events. jumplist.lua and changelist.lua only give their mark types and their read function.

  • Docs: new pages docs/providers/jumplist.md and docs/providers/changelist.md, and the new providers and mark types in the README table, the provider index, the configuration defaults, and the list of built-in names.

  • Tests: the provider tests press the real key and check that the cursor goes to the marked line. They also cover:

    • targets in another buffer and jumpoptions=stack;
    • two windows of one buffer, and a line delete that moves the targets of both;
    • the E663 state of g,;
    • no read for Insert-mode events, and a read on InsertLeave;
    • manual refresh, an excluded buffer, and dispose.

Behavior change

None for an existing config. jumplist and changelist are new built-in names. A custom provider with one of these names that registers before setup() still shadows the built-in, as the custom provider docs say.

Checks

  • make ci passes: StyLua, selene, LuaLS (no problems), and 1283 test cases with 0 failures.
  • A headless render showed <, >, «, and » on the expected scrollbar rows, and the new types in the minimap.

Discussion #64 asked for a mark on the line that <C-o> goes to. The
`jumplist` provider shows the <C-o> target as a `JumpOlder` mark and
the <C-i> target as a `JumpNewer` mark. The `changelist` provider shows
the g; target as a `ChangeOlder` mark and the g, target as a
`ChangeNewer` mark. Both providers are off by default and target both
renderers. To show one target only, hide the other type with
`marks.<Type> = false`.

Each list keeps its index in the window, so the marks are window
marks. One index rule serves both lists: the older target is the entry
at the Lua index `pos`, and the newer target is the entry at
`pos + 2`. A jump target in another buffer gets no mark. After an
edit, g, goes to the same line as g;, so the change list shows no
`ChangeNewer` mark there. The shared module `position_targets.lua`
holds the rule, the read of a window that is not current (through
`nvim_win_call`), and the events.

A read of a jumplist of 100 entries costs about 55 µs, and no cheaper
signal shows a change. The providers read the current window on
CursorMoved, BufWinEnter, WinEnter, and InsertLeave, and the windows of
a buffer after an edit. They drop CursorMovedI and TextChangedI, so
typing in Insert mode reads no list. The jumplist reads the windows of
an edited buffer only when the line count changed.

The provider tests press the real key and check that the cursor goes
to the marked line.

make ci passes with 1283 cases.
@petertriho
petertriho merged commit 57fc5fe into main Nov 23, 2026
6 checks passed
@petertriho
petertriho deleted the feat/jumplist-changelist-providers branch November 23, 2026 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant