/ˌpriːkɒɡˈnɪʃn/ noun
- foreknowledge of an event, especially as a form of extrasensory perception.
precognition.nvim assists with discovering motions (Both vertical and horizontal) to navigate your current buffer
Visual/Change/Delete a/i Hints

Comma and Semi-Colon Repeat Hints

Installation with any package manager, Lazy example below:
return {
"tris203/precognition.nvim",
--event = "VeryLazy",
opts = {
-- startVisible = true,
-- debounceMs = 0,
-- showBlankVirtLine = true,
-- highlightFullVirtLine = false,
-- highlightColor = { link = "Comment" },
-- targetedMotionHighlightColor = { link = "PrecognitionTargetedMotionDefault" },
-- textObjectHighlightColors = {
-- { link = "DiffText" },
-- { link = "DiffChange" },
-- { link = "Visual" },
-- },
-- targetedMotionHints = {
-- enabled = true,
-- prio = 1,
-- },
-- hints = {
-- Caret = { text = "^", prio = 2 },
-- Dollar = { text = "$", prio = 1 },
-- MatchingPair = { text = "%", prio = 5 },
-- Zero = { text = "0", prio = 1 },
-- w = { text = "w", prio = 10 },
-- b = { text = "b", prio = 9 },
-- e = { text = "e", prio = 8 },
-- W = { text = "W", prio = 7 },
-- B = { text = "B", prio = 6 },
-- E = { text = "E", prio = 5 },
-- },
-- gutterHints = {
-- G = { text = "G", prio = 10 },
-- gg = { text = "gg", prio = 9 },
-- PrevParagraph = { text = "{", prio = 8 },
-- NextParagraph = { text = "}", prio = 8 },
-- },
-- disabled_fts = {
-- "startify",
-- },
},
}-
hintscan be hidden by setting their priority to 0. If you want to hide the entire virtual line, set all elements toprio = 0in combination with the below. -
debounceMs = 0Debounces hint updates after cursor movement by the given number of milliseconds. The default0disables debouncing so hints update immediately. -
showBlankVirtLine = falseSetting this option will mean that if a Virtual Line would be blank it won't be rendered -
highlightFullVirtLine = truePads Inline Hint virtual lines to the current window width. This is useful whenhighlightColorincludes a background color and you want that background to extend across the whole visible row. -
gutterHintscan be hidden by setting their priority to 0. -
highlightColorcan be set in two ways:- As a table containing a link property pointing to an existing highlight group (see
:highlightfor valid options). - As a table specifying custom highlight values, such as foreground and background colors. (more info)
- As a table containing a link property pointing to an existing highlight group (see
-
textObjectHighlightColorscontrols the nested text object range highlight groups. Each entry uses the same format ashighlightColorand maps toPrecognitionTextObjectRange1,PrecognitionTextObjectRange2, etc. -
targetedMotionHighlightColorcontrols the highlight used for targeted motion key hints such asfandF. It uses the same format ashighlightColor. The default links toPrecognitionTargetedMotionDefault, which blendsCommentwithSpecialCommentso targeted motion hints stay subtle while remaining distinguishable from regular hints. -
targetedMotionHintscontrols dynamic same-line targeted motion hints. By default Precognition shows first-occurrencef/Fhints for single-width printable non-whitespace characters. These hints render asforFuntil that motion is pending, then render the target character. Leading counts are supported, so2fpreviews the second reachable occurrence of each target character. Afterf,F,t, orThas been used, repeat targets are shown as;and,. Setenabled = falseto hide these hints.priois a number that defaults to1and is used when an individual targeted hint does not provide its own priority; higher-priority hints win when multiple hints share a destination. -
disabled_ftscan be used to disableprecognitionon specific filetypes.
Any hints that could appear in the same place as others should have unique priorities to avoid conflicts.
precognition can be controlled with the Precognition user command, as well as programmatically via the Lua API.
The hints can be toggled on and off with
:Precognition toggleor
require("precognition").toggle()The return value indicating the visible state can be used to produce a notification.
if require("precognition").toggle() then
vim.notify("precognition on")
else
vim.notify("precognition off")
endThe subcommands and functions show and hide are also available.
The hints can be peeked, this means that the hint will be show until the next cursor movement.
:Precognition peekor
require("precognition").peek()This plugin supports stable and nightly. >0.9 at the time of writing.
Contributions are what makes the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion to improve the plugin, please open an issue first, fork the repo, and create a pull request.
If you have found a bug please open an issue, and submit a pull request with a failing test if possible.
If you’re interested in adding custom motions to Precognition, take a look at interface.lua for the available integration points.
More details on how to contribute can be found in CONTRIBUTING.md. Please read this prior to creating a pull request.
Don't forget to give the project a star! Thanks again!
