Skip to content

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

term-color-parser.nvim

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.

Features

  • 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.

Requirements

  • Neovim 0.9 or newer.
  • conceallevel support for non-destructive conceal mode.

Installation

With lazy.nvim:

{
  "Foxinio/term-color-parser.nvim",
  cmd = "AnsiColorize",
  config = true,
}

Configuration

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"
  },
})

Usage

Colorize the current buffer without changing its text:

:AnsiColorize

Colorize a specific buffer:

:AnsiColorize 12

Strip ANSI codes and colorize the remaining text:

:AnsiColorize!

Lua API

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 highlights

0, nil, or an omitted buffer number means the current buffer.

Overseer.nvim

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.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages