A highly customizable theme for vim and neovim with support for lsp, treesitter and a variety of plugins.
Nightfox has recently been rewritten and has depricated most of the previous interface. If you are not
ready to update yet you can point your package manager to use the tag v1.0.0
for the mean time.
Plugin Managers
use { "EdenEast/nightfox.nvim", tag = "v1.0.0" } -- Packer
Plug 'EdenEast/nightfox.nvim', { 'tag': 'v1.0.0' } " Vim-Plug
nightfox.load()
has been removed in favour of setting colorschemes using the builtin:colorscheme
commandnightfox.setup()
function now takes configuration options as an optional keyfox
has been removed in favour of setting colorschemes using the builtin:colorscheme
commandtransparent
has been moved tooptions.transparent
terminal_color
has been moved tooptions.terminal_color
alt_nc
has been moved tooptions.dim_inactive
styles
has been moved tooptions.styles
inverse
has been moved tooptions.inverse
colors
has been replaced with the concept of palletshlgroups
has been replaced with the concept of groups
Color Migration table
V1 color | V2 pallet |
---|---|
bg | bg1 |
bg_alt | bg0 |
bg_sidebar | bg0 |
bg_float | bg0 |
bg_popup | bg0 |
bg_highlight | bg3 |
bg_visual | sel0 |
bg_search | sel1 |
fg | fg1 |
fg_alt | fg2 |
fg_gutter | fg3 |
- Support both vim and neovim
- Highly configurable with template overriding
- Support for multiple plugins and status lines
- And many others should "just work"!
- Compile user's configuration
- Export Color library utility
- Neovim >= 0.5 or Vim with lua >= 5.2
- True color support
- Undercurl terminal support (optional)
Note for MacOS: The default
terminal
does not supporttrue color
. Use eitherIterm2
or another terminal that supports true color.
Download with your favorite package manager.
use "EdenEast/nightfox.nvim" -- Packer
Plug 'EdenEast/nightfox.nvim' " Vim-Plug
Simply set the colorscheme with the builtin command :colorscheme
colorscheme nightfox
vim.cmd("colorscheme nightfox")
There is no need to call setup
if you don't require to change the default options and settings.
-- Default options
require('nightfox').setup({
options = {
-- Compiled file's destination location
compile_path = vim.fn.stdpath("cache") .. "/nightfox",
compile_file_suffix = "_compiled", -- Compiled file suffix
transparent = false, -- Disable setting background
terminal_colors = true, -- Set terminal colors (vim.g.terminal_color_*) used in `:terminal`
dim_inactive = false, -- Non focused panes set to alternative background
styles = { -- Style to be applied to different syntax groups
comments = "NONE", -- Value is any valid attr-list value `:help attr-list`
functions = "NONE",
keywords = "NONE",
numbers = "NONE",
strings = "NONE",
types = "NONE",
variables = "NONE",
},
inverse = { -- Inverse highlight for different types
match_paren = false,
visual = false,
search = false,
},
modules = { -- List of various plugins and additional options
-- ...
},
}
})
-- setup must be called before loading
vim.cmd("colorscheme nightfox")
If you would like to change any of the default options above you only have to define the options that change. If an option is not present in your options table the default option will be used. For example if chaning the styles of certain syntax is the only desired change then your options table would look like:
require('nightfox').setup({
options = {
styles = {
commnets = "italic",
keywords = "bold"
types = "italic,bold",
}
}
})
To see a detailed explanation of nightfox's config settings consult either the builtin help :help nightfox
or
Usage.
Nightfox's modules store configuration information for various plugins and other neovim modules. To enable a module
either set the module to true
or if the module has additional configuration information set enable
to true
.
To see a list of modules check, see Usage or :help
for more information.
You can change the color pallet
and the highlight group
of nightfox. Here is a brief example:
-- Pallets are the base color defines of a colorscheme.
-- You can override these pallets for each colorscheme defined by nightfox
local pallets = {
nightfox = {
-- Each pallet defines these colors:
-- black, red, green, yellow, blue, magenta, cyan, white, orange, pink
--
-- These colors have 3 shades: base, bright, and dim
--
-- Defining just a color defines it's base color
red = "#c94f6d",
},
dayfox = {
-- Defining multiple shades is done by passing a table
blue = { base = "#4d688e", bright = "#4e75aa", dim = "#485e7d", }
},
nordfox = {
-- A pallet also defines the following:
-- bg0, bg1, bg2, bg3, bg4, fg0, fg1, fg2, fg3, sel0, sel1, comment
--
-- These are the different foreground and background shades used by the theme.
-- The base bg and fg is 1, 0 is normally the dark alternative. The others are
-- incrementally lighter versions.
bg1 = "#2e3440",
-- sel is different types of selection colors.
sel0 = "#3e4a5b", -- Popup bg, visual selection bg
sel1 = "#4f6074", -- Popup sel bg, search bg
-- comment is the definition of the comment color.
comment = "#60728a",
}
}
-- Spec's (specifications) are a mapping of pallets to logical groups that will be
-- used by the groups. Some examples of the groups that specs map would be:
-- - syntax groups (functions, types, keywords, ...)
-- - diagnostic groups (error, warning, info, hints)
-- - git groups (add, removed, changed)
--
-- You can override these just like pallets
local specs = {
nightfox = {
syntax = {
-- Specs allow you to define a value using either a color or template. If the string does
-- start with `#` the string will be used as the path of the pallet table. Defining just
-- a color uses the base version of that color.
keyword = "magenta",
-- Adding either `.bright` or `.dim` will change the value
conditional = "magenta.bright",
number = "orange.dim",
},
git = {
-- A color define can also be used
changed = "#f4a261",
}
}
}
-- Groups are the highlight group definitions. The keys of this table are the name of the highlight
-- groups that will be overridden. The value is a table with the following values:
-- - fg, bg, style, sp, link,
--
-- Just like `spec` groups support templates. This time the template is based on a spec object.
local groups = {
-- By default nightfox links some groups together. `CursorColumn` is one of these groups. When overriding
-- Make sure `link` is cleared to `""` so that the link will be removed.
CursorColumn = { bg = "sel0", link = "" },
-- Specs are used for the template. Specs have their pallet's as a field that can be accessed
IncSearch = { bg = "pallet.cyan" },
}
require("nightfox").setup({ pallets = pallets, specs = specs, groups = groups })
-- setup must be called before loading
vim.cmd("colorscheme nightfox")
To get more information check out Usage or the help file :help nightfox
for more detailed information.
Nightfox exposes some Api's and utility classes that let you fetch data from nightfox.
You can get the pallets used by each colorscheme:
-- Returns a table with each colorscheme and the pallet associated with it
local pallets = require('nightfox.pallet').load()
-- Returns the pallet of the specified colorscheme
local pallet = require('nightfox.pallet').load("nightfox")
print(vim.inspect(pallet.red))
-- {
-- base = "#c94f6d",
-- bright = "#d16983",
-- dim = "#ab435d",
-- }
See Usage for more information on pallets.
You can get the spec used by each colorscheme:
-- Returns a table with each colorscheme and the spec associated with it
local specs require('nightfox.spec').load()
-- Returns the spec of the specified colorscheme
local spec = require('nightfox.spec').load("nightfox")
print(vim.inspect(spec.git))
-- {
-- add = "#81b29a",
-- changed = "#dbc074",
-- removed = "#c94f6d"
-- }
See Usage for more information on specs.
Nightfox uses a color library internally to manipulate colors. You can use this library as well.
local pallet = require('nightfox.pallet').load('nightfox')
local Color = require("nightfox.lib.color")
local bg = Color.from_hex(pallet.bg1)
local red = Color.from_hex("#ff0000")
-- Blend the bg with red. The blend factor is from 0 to 1
-- with 0 being full bg and 1 being full red
local red_bg = bg:blend(red, 0.2)
print(red_bg:to_css())
-- "#471c26"
-- Brighten bg by adding 10 to the value of the color as a hsv
local alt_bg = bg:brighten(10)
print(vim.inspect(alt_bg:to_hsv()))
-- {
-- hue = 213.91304347826,
-- saturation = 47.916666666667,
-- value = 28.823529411765
-- }
There are a lot of useful functions to manipulate and work with colors in different color spaces.
See Usage for more information on Color
.
Nightfox is a highly customizable and configurable colorscheme. There are endless ways to customize nightfox. This does however come at the cost of complexity and execution time. Nightfox can pre compute the results of your configuration and store the results in a compiled lua file. After nightfox use these precached values to set it's highlights.
By default nightfox writes the compiled results into the system's cache
directory. On unix this is
$XDG_CACHE_HOME/nvim/nightfox
and on windows this is %localappdata%\\Temp\\nvim\\nightfox
.
Nightfox provides functions to work with the nightfox compiler.
local nightfox = require('nightfox')
-- Create/update the compile files
nightfox.compile()
-- Delete compiled files
nightfox.clean()
Nightfox provides the following commands that wrap these functions above:
:NightfoxCompile
:NightfoxClean
- barbar.nvim
- nvim-cmp
- dashboard-nvim
- fern.vim
- fidget.nvim
- vim-gitgutter
- gitsigns.nvim
- glyph-palette.vim
- hop.nvim
- vim-illuminate
- lightspeed.nvim
- lspsaga.nvim
- lsp-trouble.nvim
- modes.nvim
- neogit
- nvim-tree.lua
- pounce.nvim
- vim-sneak
- symbols-outline.nvim
- telescope.nvim
- nvim-ts-rainbow
- which-key.nvim
Lualine checks the value of vim.g.colors_name
(set when using :colorscheme
command) to determine the theme to load.
Set your colorscheme before calling setup.
vim.cmd("colorscheme nightfox")
require('lualine').setup({ ... })
There are extra configuration files for the following: