petertriho/nvim-scrollbar

github github
scrollingscrollbar
stars 1,080
issues 3
subscribers 7
forks 25
CREATED

UPDATED


The default scrollbar and minimap while scrolling past diagnostics, Git hunks, and search matches

nvim-scrollbar adds a floating scrollbar to each window. Marks on the scrollbar show where the diagnostics, search matches, Git changes, and other items are. A click on a mark moves the cursor there. An optional minimap shows a compressed view of the buffer. The plugin adds less than 0.1 ms to a keystroke.

Jump and Glance

Label mode puts a label on each scrollbar mark. Type a label to jump to its mark, or type it in uppercase to peek at the lines first. Glance lists the marks in a builtin window, snacks.nvim, Telescope, or a custom picker. With scrollbar.hover, the peek also opens when the pointer rests on a mark. Label mode is inspired by flash.nvim, and the glance window by glance.nvim.

Label mode: labels on the scrollbar marks, a peek float from an uppercase label, and a jump

The glance window: a list of the marks, a preview that follows the selection, an edit in the preview, and a jump

Hover: the peek float opens while the pointer rests on a mark of the scrollbar

vim.keymap.set("n", "<leader>j", function()
    require("scrollbar").jump()
end, { desc = "Jump to a scrollbar mark" })

vim.keymap.set("n", "<leader>p", function()
    require("scrollbar").peek()
end, { desc = "Peek at a scrollbar mark" })

vim.keymap.set("n", "<leader>g", function()
    require("scrollbar").glance()
end, { desc = "Glance at the marks" })

The commands are :ScrollbarJump [types], :ScrollbarPeek [types], and :ScrollbarGlance [types]. See Jump and Glance.

Requirements

Installation

If you upgrade from v1, read the migration guide, or pin branch = "v1".

lazy.nvim:

{
    "petertriho/nvim-scrollbar",
    lazy = false,
    opts = {},
}

If you add keys to the spec, keep lazy = false. Otherwise no scrollbar shows until the first key press.

vim-plug, then call setup() from Lua:

Plug 'petertriho/nvim-scrollbar'
require("scrollbar").setup()

Quick Start

require("scrollbar").setup({
    providers = {
        search = { incsearch = true },
        marks = { numbers = true },
    },
    scrollbar = {
        preset = "zed",
        autohide = true,
    },
})

With autohide, a scrollbar shows when its window scrolls or its cursor moves, and hides after 1 second without activity.

Scrollbar presets: vscode, zed, intellij, minimal, review, search, navigate, gvim, eclipse, sublime, emacs, and xcode. The showcase shows each scrollbar and minimap preset.

Profiles change the appearance of matching windows. The first match applies:

require("scrollbar").setup({
    scrollbar = {
        preset = "zed",
        profiles = {
            {
                match = { filetypes = { "markdown", "text" } },
                preset = "minimal",
            },
            {
                match = { filetypes = { "lua" } },
                preset = "review",
            },
        },
    },
})

Setup rejects unknown keys and invalid values. See the configuration reference.

Minimap

The minimap is off by default. It uses the same providers, marks, and exclude tables as the scrollbar:

require("scrollbar").setup({
    minimap = {
        enabled = true,
    },
})

By default, it draws the buffer as Braille dots, with Treesitter colors when the buffer has a parser. Its presets are vscode, sublime, zed, xcode, overview, compact, minimal, and blocks. See the minimap documentation.

Pickers and Floats

With floats = true in the scrollbar or minimap block, that bar also shows on the list and preview of the snacks.nvim and Telescope pickers, and on the snacks.nvim zen and zoom windows. A when function adds other floats:

require("scrollbar").setup({
    scrollbar = {
        floats = {
            snacks = true,
            telescope = true,
            when = require("scrollbar.recipes").when.filetypes({ "lazy" }),
        },
    },
})

Jump, peek, glance, and hover also work on these floats. See Floats.

Providers

Provider Scrollbar Minimap Source Dependency
cursor on on Source-window cursor None
diagnostic on on Neovim vim.diagnostic None
search on on Native / and ? search None
marks on on Letter marks, and optional numbered marks None
gitsigns off off Git hunks gitsigns.nvim
mini_diff off off mini.diff hunks mini.diff
signify off off vim-signify hunks vim-signify
vgit off off vgit hunks vgit.nvim
ale off off ALE location list ALE
coc off off Coc diagnostic list coc.nvim
qflist off off Quickfix list None
loclist off off Location list of each window None
jumplist off off <C-o> and <C-i> targets of each window None
changelist off off g; and g, targets of each window None
treesitter unavailable on Treesitter highlight captures Installed parser
lsp_semantic_tokens unavailable off LSP semantic tokens Attached LSP client

Set each provider in providers to true, false, or a table of options. See the provider overview, or add your own with the custom provider API.

Documentation

License

MIT