Skip to content

A dynamic Neovim colorscheme that adapts to your terminal's color palette, inspired by the bat command-line tool's approach to color theming.

Notifications You must be signed in to change notification settings

omacom-io/pixel.nvim

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Pixel.nvim

A dynamic Neovim colorscheme that adapts to your terminal's color palette, inspired by the bat command-line tool's approach to color theming.

Philosophy

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.

Features

  • 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

How It Works

ANSI Color Mapping

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

Technical Implementation

The colorscheme works by:

  1. Disabling termguicolors: Forces Neovim to use terminal ANSI colors instead of 24-bit GUI colors
  2. Using only ctermfg/ctermbg: All highlight groups use terminal color indices
  3. No GUI definitions: No guifg/guibg attributes that would override terminal colors

Installation

Using lazy.nvim

{
  "bjarneo/pixel.nvim",
  priority = 1000,
  config = function()
    vim.cmd.colorscheme("pixel")
  end,
}

Using packer.nvim

use {
  "bjarneo/pixel.nvim",
  config = function()
    vim.cmd.colorscheme("pixel")
  end,
}

Using vim-plug

Plug 'bjarneo/pixel.nvim'

Then in your init.vim or init.lua:

colorscheme pixel

Usage

Basic Usage

Simply set the colorscheme in your Neovim configuration:

-- init.lua
vim.cmd.colorscheme("pixel")
" init.vim
colorscheme pixel

Terminal Configuration

The beauty of Pixel.nvim is that you configure colors in your terminal, not in Neovim:

Alacritty Example

# ~/.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'

iTerm2 Example

  1. Open iTerm2 Preferences
  2. Go to Profiles → Colors
  3. Configure your ANSI colors
  4. Pixel.nvim will automatically use these colors

Switching Themes

Want to change your Neovim colors? Just change your terminal's color scheme:

# Switch terminal theme
# Pixel.nvim automatically adapts - no Neovim restart needed!

Supported Plugins

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

Comparison with Traditional Themes

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

Examples

With Different Terminal Themes

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!

Philosophy: Why Terminal Colors?

  1. Consistency: Your entire terminal environment uses the same color palette
  2. Simplicity: One place to configure colors for everything
  3. Flexibility: Easy to experiment with different themes
  4. Performance: No overhead from color calculations
  5. Universality: Works the same way across all terminal applications

Troubleshooting

Colors appear wrong

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

Theme not updating

Ensure termguicolors is disabled:

-- In your init.lua, before setting colorscheme
vim.opt.termguicolors = false
vim.cmd.colorscheme("pixel")

Need GUI colors

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

Contributing

Contributions are welcome! Since this theme uses ANSI colors, focus on:

  • Adding support for new plugins
  • Improving ANSI color mappings
  • Documentation improvements
  • Bug fixes

License

MIT License.

Author

Follow @iamdothash on X for updates and more projects.

Inspiration

  • bat - Command-line tool that inspired the ANSI color approach
  • Terminal color schemes that prioritize consistency across applications

About

A dynamic Neovim colorscheme that adapts to your terminal's color palette, inspired by the bat command-line tool's approach to color theming.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Vim Script 73.1%
  • Lua 26.9%