Custom Handlers

You can extend nvim-scrollbar by registering custom handlers. This allows you to place arbitrary marks on the scrollbar based on your own logic.

Registration API

Use require("scrollbar.handlers").register(name, handler_function).

Arguments

  • name (string): A unique name for your handler.
  • handler_function (function): A function that accepts bufnr and returns a list of marks.

Return Format

The handler function must return a list of tables containing:

Key Type Description
line number The 0-indexed line number. Required.
text string The character to display. Defaults to global settings if omitted.
type string The marker type (e.g., "Error", "Warn", "Misc"). Default is "Misc".
level number The marker level/priority. Default is 1.

Example

The following example places marks on the first three lines of every buffer:

require("scrollbar.handlers").register("my_marks", function(bufnr)
    return {
        { line = 0 },
        { line = 1, text = "x", type = "Warn" },
        { line = 2, type = "Error" }
    }
end)