/ˌ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
Installation with any package manager, Lazy example below:
return {
"tris203/precognition.nvim",
--event = "VeryLazy",
opts = {
-- startVisible = true,
-- showBlankVirtLine = true,
-- highlightColor = { link = "Comment" },
-- 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. -
showBlankVirtLine = falseSetting this option will mean that if a Virtual Line would be blank it won't be rendered -
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
-
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!
