Render ANSI terminal colors as native highlights in ordinary Neovim buffers.
Many CLIs print color with ANSI SGR escape sequences like \27[31m. Those
sequences are useful in a terminal, but they are noisy in normal Neovim buffers.
This plugin hides or removes the codes while preserving their colors and text
styles—without a terminal buffer, external process, or runtime dependency.
- Pure Lua, no runtime dependencies.
:AnsiColorize [bufnr]command for quick use.- Lua API for plugin integrations.
- Conceal mode: keep ANSI codes in the buffer but hide them and highlight text.
- Strip mode: remove ANSI codes from the buffer and highlight the cleaned text.
- Optional Overseer.nvim component for task output buffers.
- Supports reset, bold, italic, underline styles and colors, strikethrough, reverse, 16-color, 256-color, and truecolor SGR sequences.
- Neovim 0.9 or newer.
conceallevelsupport for non-destructive conceal mode.
With lazy.nvim:
{
"Foxinio/term-color-parser.nvim",
cmd = "AnsiColorize",
config = true,
}The default setup is enough for manual use:
require("ansi-colorize").setup()Enable the optional Overseer template hook:
require("ansi-colorize").setup({
overseer = {
preserve_ansi = true, -- keep ANSI until this plugin colorizes it
mode = "conceal", -- "conceal" or "strip"
on = "output", -- "output" or "complete"
},
})Colorize the current buffer without changing its text:
:AnsiColorizeColorize a specific buffer:
:AnsiColorize 12Strip ANSI codes and colorize the remaining text:
:AnsiColorize!local ansi = require("ansi-colorize")
ansi.colorize(0) -- conceal ANSI codes and highlight text
ansi.strip(0) -- remove ANSI codes and highlight text
ansi.clear(0) -- remove plugin highlights0, nil, or an omitted buffer number means the current buffer.
For all Overseer tasks, add the component to Overseer's default alias:
require("overseer").setup({
component_aliases = {
default = {
"on_exit_set_status",
"on_complete_notify",
{ "on_complete_dispose", require_view = { "SUCCESS", "FAILURE" } },
{ "ansi_colorize", mode = "conceal", on = "output" },
},
},
})Use strip mode if you prefer permanent cleanup:
{ "ansi_colorize", mode = "strip", on = "complete" }The setup({ overseer = ... }) helper preserves ANSI in non-terminal output
while keeping parsed output such as quickfix entries clean, then adds the
component through Overseer's template hook. It only adds the component to tasks
created from templates; for every task, add it to
component_aliases.default as shown above. Set preserve_ansi = false to keep
Overseer's default output cleaning.