Repository navigation
feat(providers): add the jumplist and changelist providers - #143
Merged
Merged
Conversation
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.
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.
Adds two built-in providers that show where the history keys go from each window, as asked in discussion #64.
jumplistmarks the<C-o>and<C-i>targets.changelistmarks theg;andg,targets. Both are off by default.Changes
New mark types:
JumpOlder<C-o><1SpecialJumpNewer<C-i>>1SpecialChangeOlderg;«1ChangedChangeNewerg,»1ChangedThe change marks use other glyphs, because the default colorscheme gives
ChangedandSpecialthe same color.«and»are one cell wide also withambiwidth=double.No provider options: each provider takes
true,false, or thescrollbarandminimapflags. To show one target only, hide the other type withmarks.<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 atpos + 2, withposfromgetjumplist()orgetchangelist().<C-i>then has no target, andg,goes to the same line asg;. Neither case shows a newer mark.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, andInsertLeave. After an edit, they read the windows of the buffer:changelistreads all of them, andjumplistreads only the windows whose line count changed. They dropCursorMovedIandTextChangedIfrom the scheduler dispatch, so typing in Insert mode reads no list.:clearjumpsshows at the next cursor move or at:ScrollbarRefresh.Shared module:
lua/scrollbar/providers/position_targets.luaholds the target rule, the window read, and the events.jumplist.luaandchangelist.luaonly give their mark types and their read function.Docs: new pages
docs/providers/jumplist.mdanddocs/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:
jumpoptions=stack;E663state ofg,;InsertLeave;dispose.Behavior change
None for an existing config.
jumplistandchangelistare new built-in names. A custom provider with one of these names that registers beforesetup()still shadows the built-in, as the custom provider docs say.Checks
make cipasses: StyLua, selene, LuaLS (no problems), and 1283 test cases with 0 failures.<,>,«, and»on the expected scrollbar rows, and the new types in the minimap.