Skip to main content
The lua/user/colorscheme.lua file manages the active colorscheme for your Neovim configuration.

Overview

This simple but essential file sets the default colorscheme and handles errors gracefully if the theme isn’t available.

Default Configuration

lua/user/colorscheme.lua
local colorscheme = "tokyonight"

local status_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme)
if not status_ok then
  return
end
The configuration uses a protected call (pcall) to prevent errors if the colorscheme isn’t installed.

How It Works

1

Define colorscheme

The colorscheme variable stores the name of the desired theme:
local colorscheme = "tokyonight"
2

Protected call

pcall (protected call) attempts to execute the colorscheme command:
local status_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme)
This prevents Neovim from throwing an error if the colorscheme isn’t installed.
3

Error handling

If the colorscheme fails to load, the function returns silently:
if not status_ok then
  return
end
Neovim will fall back to its default colorscheme.

Available Colorschemes

The configuration comes with two colorschemes pre-installed:

Tokyo Night

Repository: folke/tokyonight.nvimA clean, dark colorscheme inspired by the Tokyo Night theme for VS Code.
local colorscheme = "tokyonight"
Variants:
  • tokyonight-night (default)
  • tokyonight-storm
  • tokyonight-day
  • tokyonight-moon

DarkPlus

Repository: lunarvim/darkplus.nvimA port of VS Code’s Dark+ theme.
local colorscheme = "darkplus"
Provides a familiar look for users coming from VS Code.

Changing Colorschemes

Temporary Change

To try a different colorscheme without editing files:
:colorscheme darkplus
This change won’t persist after restarting Neovim.

Permanent Change

  1. Open the colorscheme file:
    :e ~/.config/nvim/lua/user/colorscheme.lua
    
  2. Change the colorscheme variable:
    local colorscheme = "darkplus"  -- or any other installed theme
    
  3. Save and reload:
    :w
    :luafile %
    

Tokyo Night Configuration

Tokyo Night offers several customization options beyond just choosing a variant.
To customize Tokyo Night, add configuration before setting the colorscheme:
lua/user/colorscheme.lua
-- Configure Tokyo Night before loading
require("tokyonight").setup({
  style = "night",           -- storm, moon, night, day
  transparent = false,        -- Enable transparent background
  terminal_colors = true,     -- Configure terminal colors
  styles = {
    comments = { italic = true },
    keywords = { italic = true },
    functions = {},
    variables = {},
  },
  sidebars = { "qf", "help" }, -- Darker sidebar for specific windows
  day_brightness = 0.3,       -- Brightness for day variant
  hide_inactive_statusline = false,
  dim_inactive = false,       -- Dim inactive windows
  lualine_bold = false,       -- Bold section headers in lualine
})

local colorscheme = "tokyonight"

local status_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme)
if not status_ok then
  return
end

Installing Additional Colorschemes

1

Add to plugins.lua

Open lua/user/plugins.lua and add your colorscheme plugin:
use { "catppuccin/nvim", as = "catppuccin" }
2

Install the plugin

Save the file and run:
:PackerSync
3

Update colorscheme.lua

Change the colorscheme variable to use the new theme:
local colorscheme = "catppuccin"
4

Reload configuration

Restart Neovim or source the colorscheme file:
:luafile ~/.config/nvim/lua/user/colorscheme.lua
-- In plugins.lua
use { "ellisonleao/gruvbox.nvim" }

-- In colorscheme.lua
local colorscheme = "gruvbox"
Retro groove colorscheme with warm, earthy tones.
-- In plugins.lua
use { "catppuccin/nvim", as = "catppuccin" }

-- In colorscheme.lua
local colorscheme = "catppuccin"
Soothing pastel theme with multiple flavors (latte, frappe, macchiato, mocha).
-- In plugins.lua
use { "shaunsingh/nord.nvim" }

-- In colorscheme.lua
local colorscheme = "nord"
Arctic, north-bluish color palette.
-- In plugins.lua
use { "EdenEast/nightfox.nvim" }

-- In colorscheme.lua
local colorscheme = "nightfox"
Multiple fox-themed variants (nightfox, dayfox, dawnfox, duskfox, nordfox, terafox).
-- In plugins.lua
use { "rebelot/kanagawa.nvim" }

-- In colorscheme.lua
local colorscheme = "kanagawa"
Dark colorscheme inspired by the colors of Kanagawa’s famous painting.

Listing Available Colorschemes

To see all installed colorschemes:
:colorscheme <Tab>
Press <Tab> to cycle through available options. Or use this command to get a list:
:lua print(vim.inspect(vim.fn.getcompletion('', 'color')))

Troubleshooting

If your colorscheme isn’t loading, check these common issues.
Problem: Error message about colorscheme not being found.Solution:
  1. Ensure the plugin is installed in plugins.lua
  2. Run :PackerSync to install/update plugins
  3. Restart Neovim
  4. Verify the exact colorscheme name (some require - or have variants)
Problem: Colors don’t match screenshots or documentation.Solution:
  1. Ensure your terminal supports true colors
  2. Enable true color support in options.lua:
    termguicolors = true
    
  3. Check your terminal emulator’s color settings
Problem: Theme loads but elements are invisible or poorly colored.Solution:
  1. Some themes require specific configuration
  2. Check the theme’s GitHub README for setup instructions
  3. Clear Neovim’s cache:
    rm -rf ~/.cache/nvim
    

Advanced: Creating Colorscheme Switcher

Create a function to easily switch between colorschemes:
local colorschemes = { "tokyonight", "darkplus", "gruvbox" }
local current_index = 1

function _G.cycle_colorscheme()
  current_index = current_index % #colorschemes + 1
  local scheme = colorschemes[current_index]
  vim.cmd("colorscheme " .. scheme)
  print("Colorscheme: " .. scheme)
end

-- Add keymap in keymaps.lua
keymap("n", "<leader>cs", ":lua cycle_colorscheme()<CR>", opts)

See Also

Plugins

Manage and install colorscheme plugins

Options

Configure terminal colors and UI settings

Build docs developers (and LLMs) love