highlight_range
Add a colored line highlight to a Neovim buffer for visual annotation without modifying content. Specify file, start and end lines, and a hex color or highlight group.
Instructions
Add a colored line highlight to a Neovim buffer. This is a visual annotation only — it does not modify buffer content and is not persisted to disk. Highlights stack; calling this multiple times adds more highlights without removing previous ones.
file: path relative to Neovim's cwd (as shown in get_state buffers).
The buffer must already be open in Neovim; returns an error otherwise.
start_line: first line to highlight (1-indexed, inclusive).
end_line: last line to highlight (1-indexed, inclusive). Out-of-range
values are clamped. If start_line > end_line they are swapped.
color: a hex color (e.g. "#3b4048") or a Neovim highlight group name
(e.g. "Comment", "DiagnosticError"). For groups, the resolved
foreground color becomes the line background — so highlights adapt
to the user's colorscheme. Defaults to "Comment". Unknown names
(including bare color literals like "Red") return an error.
Use this for a single highlight. Use highlight_ranges to apply
multiple highlights in one call. Use clear_highlights to remove
all highlights from a buffer.
Returns {highlighted} with the number of lines highlighted, or {error} with a message on failure.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | ||
| start_line | Yes | ||
| end_line | Yes | ||
| color | No | Comment |