Highly customisable Neovim theme. With support for custom colors, styles and highlights by filetype
Inspired by VS Code's One Dark Pro
- β¨ Features
- β‘ Requirements
- π¦ Installation
- π Usage
- π§ Configuration
- π§ Default configuration
- π§ Setting a theme
- π§ Configuring colors
- π§ Configuring highlight groups
- π§ Configuring semantic tokens
- π§ Configuring filetype highlighting
- π§ Configuring plugins
- π§ Configuring styles
- π§ Configuring options
- π Helpers
- π Supported Plugins
- πΈ Screenshots
- π Extras
- β FAQs
- π Credits
- π© Automatic caching for faster load times
- π² Full Treesitter support
- ποΈ Support for LSP semantic tokens
- π Support for many popular plugins
- π¦ Filetype highlighting to allow for greater customisation across different languages
- π Override everything - styles, colors, tokens, highlight groups and filetype groups
- ποΈ Create custom highlight groups and even highlight groups by filetypes
- Neovim 0.8+
termguicolorsenabled for true color supporttreesitterfor full syntax highlighting- For semantic tokens, Neovim 0.9+ and an LSP server that supports them
Install with your package manager of choice:
-- Lazy
{
"olimorris/onedarkpro.nvim",
priority = 1000 -- Ensure it loads first
}-- Packer
use "olimorris/onedarkpro.nvim"" Vim-Plug
Plug "olimorris/onedarkpro.nvim"Use the built-in :colorscheme command to load:
-- Lua
vim.cmd("colorscheme onedark")" Vimscript
colorscheme onedarkAdditional commands:
:OnedarkproCachegenerates new cache files for the themes:OnedarkproCleanremoves existing cache files for the themes:OnedarkproColorsoutputs all of the colors in the currently loaded theme to a scratch buffer
βΌοΈ You only need to the call thesetupfunction if you wish to change any of the defaults
Click to see the default configuration
require("onedarkpro").setup({
colors = {}, -- Override default colors or create your own
filetypes = { -- Override which filetype highlight groups are loaded
javascript = true,
lua = true,
markdown = true,
php = true,
python = true,
ruby = true,
rust = true,
toml = true,
typescript = true,
typescriptreact = true,
vue = true,
yaml = true,
},
plugins = { -- Override which plugin highlight groups are loaded
aerial = true,
barbar = true,
copilot = true,
dashboard = true,
gitsigns = true,
hop = true,
indentline = true,
leap = true,
lsp_saga = true,
marks = true,
native_lsp = true,
neotest = true,
neo_tree = true,
nvim_cmp = true,
nvim_bqf = true,
nvim_dap = true,
nvim_dap_ui = true,
nvim_hlslens = true,
nvim_navic = true,
nvim_notify = true,
nvim_tree = true,
nvim_ts_rainbow = true,
op_nvim = true,
packer = true,
polygot = true,
startify = true,
telescope = true,
toggleterm = true,
treesitter = true,
trouble = true,
vim_ultest = true,
which_key = true,
},
semantic_tokens = { -- Override semantic tokens
default = {
["@class"] = { fg = "${yellow}" },
["@property"] = { fg = "${red}" },
["@global"] = { fg = "${red}" },
["@defaultLibrary"] = { fg = "${cyan}" },
},
},
highlights = {}, -- Override default highlight groups or create your own
styles = { -- For example, to apply bold and italic, use "bold,italic"
types = "NONE", -- Style that is applied to types
methods = "NONE", -- Style that is applied to methods
numbers = "NONE", -- Style that is applied to numbers
strings = "NONE", -- Style that is applied to strings
comments = "NONE", -- Style that is applied to comments
keywords = "NONE", -- Style that is applied to keywords
constants = "NONE", -- Style that is applied to constants
functions = "NONE", -- Style that is applied to functions
operators = "NONE", -- Style that is applied to operators
variables = "NONE", -- Style that is applied to variables
parameters = "NONE", -- Style that is applied to parameters
conditionals = "NONE", -- Style that is applied to conditionals
virtual_text = "NONE", -- Style that is applied to virtual text
},
options = {
cursorline = false, -- Use cursorline highlighting?
transparency = false, -- Use a transparent background?
terminal_colors = true, -- Use the theme's colors for Neovim's :terminal?
highlight_inactive_windows = false, -- When the window is out of focus, change the normal background?
}
})Currently, there are four themes in the colorscheme:
onedarkonelightonedark_vividonedark_dark
A theme can be set with:
vim.cmd("colorscheme onedark")
βΌοΈ See the helpers section for information on how to darken, lighten and brighten colors
A theme has a palette of 13 core colors alongside many additional ones which are used for menus and git diffs for example. These colors can be found in the themes.
The default colors can be changed by specifying the name of the color and a new hex code:
colors = {
red = "#FF0000"
}New colors may be created which will then be merged into a theme's color palette:
colors = {
my_new_red = "#f44336"
}These can then be used for custom highlight groups if desired:
highlights = {
Error = {
fg = "${my_new_red}",
},
}It's possible to override default colors within a theme such as the bg color. This is a common question for those who wish to have a darker background than the default. Of course it would make sense to have different bg colors for the onedark and onelight themes. This can be achieved by specifying the theme name as a table, followed by the color:
colors = {
onedark = {
bg = "#FFFF00" -- yellow
},
onelight = {
bg = "#00FF00" -- green
}
}Alternatively, you can specify colors by the theme's background color:
colors = {
dark = {
bg = "#FFFF00" -- yellow
},
light = {
bg = "#00FF00" -- green
}
}The editor, syntax, filetype and plugin files use a large array of highlight groups. There are three ways to customize or override them:
- Using specific hex colors:
highlights = {
Comment = { fg = "#FF0000", bg = "#FFFF00" }
}- Referencing the name of colors:
highlights = {
Comment = { fg = "${my_new_red}" bg = "${yellow}" }
}- Linking to other highlight groups:
highlights = {
Comment = { link = "Substitute" }
}
βΌοΈ Semantic tokens are only available in Neovim 0.9+ and with LSP servers which support it
In Neovim, semantic tokens are highlight groups which have a priority greater than those of Treesitter and the base vim highlight groups (see :h lsp-semantic_tokens for more information). A full list of available semantic tokens can be found here.
The colorscheme defines some semantic tokens and applies them by default as per the default configuration. If required, tokens can be overriden or new tokens added:
semantic_tokens = {
default = {
["@class"] = { fg = "${green}" },
}
}At present the
defaultkey is used to define semantic token highlights for all LSP servers
The theme supports opinionated highlighting for filetypes, just like the original VS Code theme. By default, all of the filetypes supported are loaded at runtime. The theme currently has support for:
javascriptluamarkdownphppythonrubyrusttomltypescripttypescriptreactvueyaml
Please see the Contributing guide if you would like add support for new filetypes.
Specific filetypes can be disabled as follows:
filetypes = {
markdown = false,
ruby = false,
}Alternatively, all of the filetypes can be disabled:
filetypes = {
all = false
}Or, all of the filetypes can be disabled with a select few enabled:
filetypes = {
all = false
markdown = true
ruby = true,
}It's likely that you'll wish to add additional filetype highlights or even change the defaults. This can be achieved by adding them as custom highlight groups in the theme:
highlights = {
["@field.yaml"] = { fg = "${blue}", style = "italic" }
}In the example above, we have set the field treesitter highlight group to be blue, but only when the filetype is yaml. More information can be found via :h treesitter-highlight-groups.
To determine which highlight group to add or modify, see the FAQ section for instructions on using Treesitter Playground.
βΌοΈ The theme's defaults can be found in the/lua/onedarkpro/highlights/filetypesdirectory
By default, all of the plugins supported by the theme are loaded at runtime. Specific plugins can be disabled as follows:
plugins = {
native_lsp = false,
polygot = false,
treesitter = false
}Alternatively, all of the plugins can be disabled:
plugins = {
all = false
}Or, all of the plugins can be disabled with a select few enabled:
plugins = {
all = false
native_lsp = true,
treesitter = true
}
βΌοΈ For a full list of plugins supported, and their names, see the plugins section
Within the theme, collections of highlight groups have been grouped together into styles. For users who use monospaced fonts with nice italics, this can go someway to enhancing the aesthetic of a theme. These styles may be configured as shown in the example below:
styles = {
types = "NONE",
methods = "NONE",
numbers = "NONE",
strings = "NONE",
comments = "italic",
keywords = "bold,italc",
constants = "NONE",
functions = "italic",
operators = "NONE",
variables = "NONE",
parameters = "NONE",
conditionals = "italic",
virtual_text = "NONE",
}
βΌοΈ See the Neovim help for a full list of styles
Cursorline highlighting is supported in the theme using a cursorline color (which may of course be overridden). This can be enabled with the following:
colors = {
cursorline = "#FF0000" -- This is optional. The default cursorline color is based on the background
},
options = {
cursorline = true
}The theme supports transparent backgrounds:
options = {
transparency = true
}By setting the transparency option to true, the Normal, Folded, SignColumn, Statusline and Tabline groups will have NONE as the background color. Additional transparency may be achieved by overriding more highlight groups.
By default, the colorscheme changes the colors for Neovim's :terminal to the current theme. This can be turned off if required.
options = {
terminal_colors = false
}The theme supports changing the color of the main window in Neovim when the focus is lost. For example, when a telescope or packer pop up appears:
options = {
highlight_inactive_windows = true
}The theme comes with a set of helpers which enable you to interact with and modify colors. The helper file can be accessed via require("onedarkpro.helpers").
It can be useful to access a theme's colors for use within other plugins (such as your statusline) after its loaded. For this, the get_colors helper can be used:
local color = require("onedarkpro.helpers")
local colors = color.get_colors()
print(colors.purple) -- #c678dd (if using the Onedark theme)Without specifying a theme name, the helper will get the colors for the currently loaded theme. Alternatively, specify a theme name, such as get_colors("onelight").
You can also use the command :OnedarkproColors to open a scratch buffer with the colors from the currently loaded theme. This then allows a colorizer plugin to highlight the colors.
βΌοΈ Please ensure that the colorscheme loads ahead of any plugins which may wish to use the colors
Whilst the get_colors method is useful in most cases, it may be neccessary to get a theme's colors before it has fully loaded. The common use case is for creating custom colors when configuring the theme. For this the get_preloaded_colors method can be used:
local color = require("onedarkpro.helpers")
local colors = color.get_preloaded_colors()
print(colors.purple) -- #c678dd (if using the Onedark theme)
βΌοΈ This will only output the theme's core color palette and not any generated colors
The theme also contain helpers darken, lighten and brighten, to allow you to modify custom colors or the theme's own. All three helpers follow the same format and take three parameters:
- color (string) - The name of the color to load (if specifying a theme) or a hex value
- amount (number) - The amount to darken/lighten/brighten the color by (range from -100 to 100)
- theme (string) (optional) - The name of the theme to load a color from
To use this in practice:
local color = require("onedarkpro.helpers")
-- Load the red color from the onedark theme and lighten it by an amount of 7
print(color.lighten("red", 7, "onedark")) -- #e68991Alternatively:
local color = require("onedarkpro.helpers")
-- Darken Red1 by an amount of 10
print(color.darken("#FF0000", 10)) -- #cc0000Of course, you're likely to wish to modify colors before the colorscheme loads. There are a number of ways to accomplish this and the most efficient is to pass a function (as a string) to the colors table in the theme's configuration:
require("onedarkpro").setup({
colors = {
dark_red = "require('onedarkpro.helpers').darken('red', 10, 'onedark')",
},
highlights = {
CustomRedHighlight = {
fg = "${dark_red}",
},
}
})This prevents the theme from trying to resolve the color before the whole of the configuration has been parsed. This also ensures that the startup time for the theme remains small too.
The theme supports the following plugins:
- aerial.nvim (
aerial) - barbar.nvim (
barbar) - Copilot.vim (
copilot) - Dashboard (
dashboard) - gitsigns.nvim (
gitsigns) - Hop.nvim (
hop) - Indent Blankline (
indentline) - leap.nvim (
leap) - lspsaga.nvim (
lsp_saga) - marks.nvim (
marks) - Neotest (
neotest) - neo-tree (
neo_tree) - nvim-cmp (
nvim_cmp) - nvim-bqf (
nvim_bqf) - nvim-dap (
nvim_dap) - nvim-dap-ui (
nvim_dap_ui) - nvim-hlslens (
nvim_hlslens) - nvim-lspconfig (
native_lsp) - nvim-navic (
nvim_navic) - nvim-notify (
nvim_notify) - nvim-tree (
nvim_tree) - nvim-ts-rainbow (
nvim_ts_rainbow) - op.nvim (
op_nvim) - packer.nvim (
packer) - polygot (
polygot) - startify (
startify) - telescope.nvim (
telescope) - toggleterm.nvim (
toggleterm) - Treesitter (
treesitter) - Trouble (
trouble) - Vim Ultest (
vim_ultest) - Which Key (
which_key)
The theme has Lualine support out of the box for all of its themes. This can be found in the Lualine folder.
The theme comes with Alacritty and Kitty colorschemes. These can be found in the extras folder.
To enable the easy switching between dark and light colorschemes, the following helper function could be used:
function ToggleTheme()
if vim.o.background == "dark" then
vim.cmd("colorscheme onelight")
else
vim.cmd("colorscheme onedark")
end
endWhen configuring the theme, it may be useful to apply different colors or styles depending on whether onedark or onelight is active. This can be achieved by applying a conditional in the configuration:
highlights = {
TSField = {
fg = (vim.o.background == "dark" and "${red}" or "${green}")
}
}If you're using Neovim 0.9+, the :Inspect command is available.
If you're on an earlier version of Neovim and are using Treesitter, install Playground as this gives you access to the powerful :TSHighlightCapturesUnderCursor command. This shows any treesitter or syntax highlight groups under the cursor.
I've tried to ensure that the theme resembles the original VS Code theme as much as possible, however there are some differences. This is mainly due to Neovim not currently supporting semantic tokens. However this will be addressed in Neovim 0.9. Also, differences between how Treesitter applies highlight groups will always create differences.
Thanks to the following contributors for their work on the colorscheme:
The following colorschemes were used as an inspiration:
- One Dark Pro - The inspiration for this colorscheme
- Nightfox - For the initial structure of the code base
- GitHub nvim theme - For the logo inspiration









