🔧 Beta stage – under active development. Changes possible.
A Neovim plugin for colorful highlighting of ASCII art in Markdown code blocks with automatic language detection, custom highlights, and predefined color schemes.
ascii code blocks in Markdown filesascii-c`, ascii lua, ````ascii:pythonword() pattern()[]{}`...`:checkhealth color_my_ascii:ColorMyAsciiCheckFences to detect unmatched blocks:h color_my_ascii{
'StefanBartl/color_my_ascii.nvim',
ft = 'markdown',
opts = {
-- Optional: Configuration here
}
}
use {
'StefanBartl/color_my_ascii.nvim',
ft = 'markdown',
config = function()
require('color_my_ascii').setup({
-- Optional: Configuration here
})
end
}
require('color_my_ascii').setup()
The plugin activates automatically for Markdown files.
```ascii
┌─────────────────────┐
│ Hello World! │
└─────────────────────┘
```
→ Box-drawing characters are automatically highlighted in color
require('color_my_ascii').setup({
debug_enabled = false,
debug_verbose = false,
scheme = 'default',
-- Character-specific overrides (highest priority)
overrides = {},
-- Default highlighting for unmatched characters
default_hl = 'Normal',
-- Optional: Default highlighting for normal text in blocks
default_text_hl = nil, -- e.g., 'Comment' for dimmed display
-- Feature toggles
enable_keywords = true,
enable_language_detection = true,
language_detection_threshold = 2,
enable_function_names = true,
enable_bracket_highlighting = true,
treat_empty_fence_as_ascii = true,
enable_inline_code = true,
})
-- Matrix style (green hacker look)
require('color_my_ascii').setup(
require('color_my_ascii.schemes.matrix')
)
-- Nord theme (cool blue/cyan)
require('color_my_ascii').setup(
require('color_my_ascii.schemes.nord')
)
-- Gruvbox (warm retro colors)
require('color_my_ascii').setup(
require('color_my_ascii.schemes.gruvbox')
)
-- Dracula (vibrant purple/pink)
require('color_my_ascii').setup(
require('color_my_ascii.schemes.dracula')
)
require('color_my_ascii').setup({
overrides = {
-- String: Built-in highlight group
['┌'] = 'Special',
-- Table: Custom definition with RGB/Hex
['└'] = { fg = '#ff0000', bold = true },
['→'] = { fg = '#00ff00', italic = true },
},
-- Dimmed text in blocks
default_text_hl = { fg = '#808080' },
})
require('color_my_ascii').setup({
enable_keywords = true,
enable_language_detection = true,
enable_function_names = true,
enable_bracket_highlighting = true,
treat_empty_fence_as_ascii = true,
enable_inline_code = true,
default_text_hl = 'Comment',
})
The plugin includes predefined keyword definitions for:
| Language | Unique Keywords | Example |
|---|---|---|
| C | restrict, _Bool, _Complex |
int, void, char |
| C++ | class, namespace, template |
virtual, override, nullptr |
| Lua | then, elseif, end |
function, local, nil |
| Go | func, chan, defer |
go, :=, <- |
| Rust | fn, mut, impl |
trait, match, loop |
| TypeScript | interface, namespace |
async, await, Promise |
| Python | def, elif, pass |
lambda, self, yield |
| Bash | fi, esac, done |
if, then, else |
| Zig | comptime, errdefer |
anytype, unreachable |
| LLVM IR | getelementptr, phi |
alloca, icmp, zext |
Additional languages can be easily added (see Contributing).
| Command | Description |
|---|---|
:ColorMyAscii |
Manually update highlighting |
:ColorMyAsciiToggle |
Enable/disable plugin |
:ColorMyAsciiDebug |
Show debug information (basic) |
:ColorMyAsciiShowConfig |
Show detailed configuration |
:checkhealth color_my_ascii |
Run health check |
:h color_my_ascii |
Open Vim help |
| Command | Description |
|---|---|
:ColorMyAsciiCheckFences |
Check for unmatched fences |
:ColorMyAsciiEnsureBlankLines |
Ensure blank lines around code blocks |
| Command | Description |
|---|---|
:ColorMyAsciiListSchemes |
List available color schemes |
:ColorMyAsciiSwitchScheme <name> |
Switch to a different scheme |
:ColorMyAsciiSchemes |
Pick scheme with Telescope (live preview) |
default - Built-in Neovim highlightsmatrix - Green hacker stylenord - Cool blue/cyangruvbox - Warm retro colorsdracula - Vibrant purple/pinkcatppuccin - Soft pastel colorsonedark - Dark theme with subtle highlightssolarized - Solarized color palettetokyonight - Dark theme with blue accentsmonokai - # Classic Monokai color scheme-- Scheme switcher
vim.keymap.set('n', '<leader>as', '<cmd>ColorMyAsciiSchemes<cr>', {
desc = 'Switch color scheme'
})
-- Format code blocks
vim.keymap.set('n', '<leader>af', '<cmd>ColorMyAsciiEnsureBlankLines<cr>', {
desc = 'Format code blocks'
})
-- Show config
vim.keymap.set('n', '<leader>ac', '<cmd>ColorMyAsciiShowConfig<cr>', {
desc = 'Show config'
})
`...`Pick one scheme from the list of available schemes and set it in the initialization like:
Example with Matrix Scheme:
require('color_my_ascii').setup(
scheme = "matrix",
)
Dark background with bright green elements. All features enabled.
require('color_my_ascii').setup({
groups = {
box_drawing = {
chars = "─│┌┐└┘",
hl = { fg = '#00ff00', bold = true },
},
},
overrides = {
['★'] = { fg = '#ffff00' },
},
enable_keywords = true,
})
See Color Schemes Guide for details.
The plugin uses:
Even large documents (>1000 lines) should not cause performance issues.
Note: enable_inline_code may cause slowdowns in very large files (>5000 lines).
:ColorMyAsciiDebug
:set filetype?
:checkhealth color_my_ascii
Use explicit language specification:
```ascii-c
int x = 42;
```
Or adjust detection threshold:
require('color_my_ascii').setup({
language_detection_threshold = 3, -- Stricter
})
Disable features:
require('color_my_ascii').setup({
enable_function_names = false,
enable_inline_code = false,
})
Issues and pull requests are welcome. For major changes, please open an issue first.
lua/color_my_ascii/languages/NAME.lua---@module 'color_my_ascii.languages.NAME'
---@type ColorMyAscii.KeywordGroup
return {
words = { 'keyword1', 'keyword2', ... },
unique_words = { 'unique1', 'unique2', ... },
hl = 'Function',
}
lua/color_my_ascii/groups/NAME.lua---@module 'color_my_ascii.groups.NAME'
---@type ColorMyAscii.CharGroup
local group = {
chars = '',
hl = 'Keyword',
}
local chars = { '⚡', '★', '☆' }
group.chars = table.concat(chars, '')
return group