A dynamic Neovim colorscheme that adapts to your terminal's color palette, inspired by the bat command-line tool's approach to color theming.
Unlike traditional Neovim colorschemes that use hardcoded hex colors, Pixel.nvim uses only ANSI terminal colors (0-15). This means the theme automatically adapts to whatever color scheme you have configured in your terminal emulator - just like how bat
displays syntax highlighting that matches your terminal's aesthetic.
- Dynamic Color Adaptation: Automatically uses your terminal's color palette
- No Hardcoded Colors: Uses only ANSI color codes 0-15
- Terminal Agnostic: Works with any terminal emulator (Alacritty, iTerm2, Kitty, etc.)
- Bat-Compatible: Uses the same ANSI color mapping as the bat tool
- Lightweight: Minimal overhead with no GUI color definitions
- Consistent: Your Neovim theme will always match your terminal aesthetic
Pixel.nvim maps syntax elements to ANSI colors following this scheme:
- Color 0 (Black): Background
- Color 1 (Red): Errors, functions, booleans
- Color 2 (Green): Strings, additions
- Color 3 (Yellow): Types, warnings, classes
- Color 4 (Blue): Keywords, statements
- Color 5 (Magenta): Constants, variables
- Color 6 (Cyan): Numbers, special characters
- Color 7 (White): Normal text, identifiers
- Color 8 (Bright Black): Comments, hints
- Color 9-15 (Bright Colors): Enhanced versions of above
The colorscheme works by:
- Disabling
termguicolors
: Forces Neovim to use terminal ANSI colors instead of 24-bit GUI colors - Using only
ctermfg
/ctermbg
: All highlight groups use terminal color indices - No GUI definitions: No
guifg
/guibg
attributes that would override terminal colors
{
"bjarneo/pixel.nvim",
priority = 1000,
config = function()
vim.cmd.colorscheme("pixel")
end,
}
use {
"bjarneo/pixel.nvim",
config = function()
vim.cmd.colorscheme("pixel")
end,
}
Plug 'bjarneo/pixel.nvim'
Then in your init.vim
or init.lua
:
colorscheme pixel
Simply set the colorscheme in your Neovim configuration:
-- init.lua
vim.cmd.colorscheme("pixel")
" init.vim
colorscheme pixel
The beauty of Pixel.nvim is that you configure colors in your terminal, not in Neovim:
# ~/.config/alacritty/alacritty.yml
colors:
primary:
background: '#1e1e2e'
foreground: '#cdd6f4'
normal:
black: '#45475a'
red: '#f38ba8'
green: '#a6e3a1'
yellow: '#f9e2af'
blue: '#89b4fa'
magenta: '#f5c2e7'
cyan: '#94e2d5'
white: '#bac2de'
bright:
black: '#585b70'
red: '#f38ba8'
green: '#a6e3a1'
yellow: '#f9e2af'
blue: '#89b4fa'
magenta: '#f5c2e7'
cyan: '#94e2d5'
white: '#a6adc8'
- Open iTerm2 Preferences
- Go to Profiles → Colors
- Configure your ANSI colors
- Pixel.nvim will automatically use these colors
Want to change your Neovim colors? Just change your terminal's color scheme:
# Switch terminal theme
# Pixel.nvim automatically adapts - no Neovim restart needed!
Pixel.nvim includes highlight groups for popular Neovim plugins:
- LSP: Diagnostic colors, semantic highlighting
- Treesitter: All
@
capture groups - Telescope: Fuzzy finder interface
- NvimTree/Neo-tree: File explorers
- GitSigns: Git integration
- GitGutter: Git diff indicators
Feature | Traditional Themes | Pixel.nvim |
---|---|---|
Color Definition | Hardcoded hex values | Terminal ANSI colors |
Customization | Edit colorscheme file | Change terminal config |
Consistency | Varies per theme | Always matches terminal |
File Size | Large (all color definitions) | Small (ANSI references only) |
Portability | Theme-specific | Universal across terminals |
Since Pixel.nvim adapts to your terminal, here's how it looks with popular terminal themes:
- Catppuccin: Warm, pastel colors
- Dracula: Dark with vibrant accents
- Nord: Cool, arctic colors
- Gruvbox: Retro, warm colors
- Tokyo Night: Modern, dark blue theme
The same Neovim configuration works with all of them!
- Consistency: Your entire terminal environment uses the same color palette
- Simplicity: One place to configure colors for everything
- Flexibility: Easy to experiment with different themes
- Performance: No overhead from color calculations
- Universality: Works the same way across all terminal applications
Make sure your terminal supports 256 colors and ANSI colors are properly configured:
# Test ANSI colors in your terminal
for i in {0..15}; do echo -en "\e[48;5;${i}m \e[0m"; done; echo
Ensure termguicolors
is disabled:
-- In your init.lua, before setting colorscheme
vim.opt.termguicolors = false
vim.cmd.colorscheme("pixel")
If you need to use GUI colors for some reason, you can re-enable them after setting the colorscheme:
vim.cmd.colorscheme("pixel")
vim.opt.termguicolors = true -- Only if absolutely necessary
Contributions are welcome! Since this theme uses ANSI colors, focus on:
- Adding support for new plugins
- Improving ANSI color mappings
- Documentation improvements
- Bug fixes
MIT License.
Follow @iamdothash on X for updates and more projects.
- bat - Command-line tool that inspired the ANSI color approach
- Terminal color schemes that prioritize consistency across applications