navarasu/onedark.nvim
关于
为 Neovim 提供 One Dark 和 One Light 主题,并为 VS Code、Ghostty、kitty、Alacritty、WezTerm、iTerm2、Windows Terminal 和 tmux 提供配套主题。共有 6 种样式,每种都提供浅色版本。
开发工具可以做什么
- 12 theme styles: 6 dark styles (dark, darker, cool, deep, warm, warmer), each with a light version (Refer Themes)
- Supporting multiple plugins with hand picked proper colors
- Customize Colors, Highlights and Code style of the theme as you like (Refer Customization)
- Matching themes for Ghostty, kitty, Alacritty, WezTerm, iTerm2, Windows Terminal, tmux, fzf, lazygit and delta (Refer Extras)
实测星标增长
- 24小时
- 0
- 7天
- +2
- 15天
- +4
- 1个月
- +8
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文Dark and Light themes for Neovim >= 0.9, based on Atom One Dark & Atom One Light, written in Lua with TreeSitter syntax highlighting.
Also available for Ghostty, kitty, Alacritty, WezTerm, iTerm2, Windows Terminal, tmux, fzf, lazygit and delta, in every style. See Extras.
Requirements
- Neovim 0.9.0+ - For modern TreeSitter captures, LSP semantic tokens, and full feature support
- For Neovim 0.5-0.8, use v0.1.0
- For Vim / Neovim < 0.5, prefer joshdick/onedark.vim
Features
- 12 theme styles: 6 dark styles (dark, darker, cool, deep, warm, warmer), each with a light version (Refer Themes)
- Supporting multiple plugins with hand picked proper colors
- Customize
Colors,HighlightsandCode styleof the theme as you like (Refer Customization) - Matching themes for Ghostty, kitty, Alacritty, WezTerm, iTerm2, Windows Terminal, tmux, fzf, lazygit and delta (Refer Extras)
- Toggle the theme style without exiting Neovim using
toggle_style_key(Refer Config)
Themes
Light versions
Every style has a light version. It's used when Neovim's background is light (:set background=light,
or a light terminal that Neovim detects), so you keep one style name for both.
Installation
For Neovim 0.9+ (Latest Version)
Install the latest version from master:
-- Using vim.pack
vim.pack.add({
"https://github.com/navarasu/onedark.nvim",
})
require('onedark').setup {
style = 'darker'
}
require('onedark').load()
-- Using Lazy
{
"navarasu/onedark.nvim",
priority = 1000, -- make sure to load this before all the other start plugins
config = function()
require('onedark').setup {
style = 'darker'
}
require('onedark').load()
end
}
" Using Vim-Plug
Plug 'navarasu/onedark.nvim'
-- Using Packer
use 'navarasu/onedark.nvim'
For Neovim 0.5-0.8 (Legacy Version)
Pin to v0.1.0 for compatibility with older Neovim:
-- Using Lazy
{
"navarasu/onedark.nvim",
version = "v0.1.0", -- Pin to legacy version
priority = 1000,
config = function()
require('onedark').setup {
style = 'darker'
}
require('onedark').load()
end
}
" Using Vim-Plug
Plug 'navarasu/onedark.nvim', { 'tag': 'v0.1.0' }
-- Using Packer
use { 'navarasu/onedark.nvim', tag = 'v0.1.0' }
Configuration
Enable theme
-- Lua
require('onedark').load()
" Vim
colorscheme onedark
Change default style
-- Lua
require('onedark').setup {
style = 'darker'
}
require('onedark').load()
" Vim
let g:onedark_config = {
\ 'style': 'darker',
\}
colorscheme onedark
Options: dark, darker, cool, deep, warm, warmer, light
Each style follows Neovim's background:
| Style | Dark background | Light background |
|---|---|---|
dark |
One Dark | One Light (same as style = 'light') |
darker |
One step darker | One step dimmer: soft grey |
cool |
Blue tint | White with a blue tint |
deep |
Deeper, bluish | Dimmer, bluish |
warm |
Neutral grey | Cream paper |
warmer |
Darker neutral grey | Deeper cream paper |
style = 'light' always uses the light background. To switch at any time, run :set background=light or
:set background=dark; your style stays the same.
Changed in v1.1: before v1.1, a light background always loaded the
lighttheme, whatever the style. If you useddarker,cool,deep,warmorwarmerwith a light background and want that look back, setstyle = 'light'(light only) orstyle = 'dark'(One Dark, with One Light on a light background).
Default Configuration
-- Lua
require('onedark').setup {
-- Main options --
style = 'dark', -- Default theme style. Choose between 'dark', 'darker', 'cool', 'deep', 'warm', 'warmer' and 'light'
transparent = false, -- Show/hide background
term_colors = true, -- Change terminal color as per the selected theme style
ending_tildes = false, -- Show the end-of-buffer tildes. By default they are hidden
cmp_itemkind_reverse = false, -- reverse item kind highlights in cmp menu
-- toggle theme style ---
toggle_style_key = nil, -- keybind to toggle theme style. Leave it nil to disable it, or set it to a string, for example "<leader>ts"
toggle_style_list = {'dark', 'darker', 'cool', 'deep', 'warm', 'warmer', 'light'}, -- List of styles to toggle between
-- Change code style ---
-- Options are italic, bold, underline, none
-- You can configure multiple style with comma separated, For e.g., keywords = 'italic,bold'
code_style = {
comments = 'italic',
keywords = 'none',
functions = 'none',
strings = 'none',
variables = 'none'
},
-- Lualine options --
lualine = {
transparent = false, -- lualine center bar transparency
},
-- Custom Highlights --
colors = {}, -- Override default colors
theme_colors = {}, -- Override colors for one style only, e.g. { darker = { bg0 = "#1a1a1a" } }
highlights = {}, -- Override highlight groups
-- Plugins Config --
diagnostics = {
darker = true, -- darker colors for diagnostic
undercurl = true, -- use undercurl instead of underline for diagnostics
background = true, -- use background color for virtual text
},
}
Vimscript configuration
Onedark can be configured also with Vimscript, using the global dictionary g:onedark_config.
NOTE: when setting boolean values use v:true and v:false instead of 0 and 1
Example:
let g:onedark_config = {
\ 'style': 'deep',
\ 'toggle_style_key': '<leader>ts',
\ 'ending_tildes': v:true,
\ 'diagnostics': {
\ 'darker': v:false,
\ 'background': v:false,
\ },
\ }
colorscheme onedark
Customization
Example custom colors and Highlights config
require('onedark').setup {
colors = {
bright_orange = "#ff8800", -- define a new color
green = '#00ffaa', -- redefine an existing color
},
highlights = {
["@lsp.type.keyword"] = { fg = "$green" },
["@lsp.type.property"] = {fg = '$bright_orange', bg = '#00ff00', fmt = 'bold'},
["@lsp.type.function"] = {fg = '#0000ff', sp = '$cyan', fmt = 'underline,italic'},
["@lsp.type.method"] = { link = "@function" },
-- To add language specific config
["@lsp.type.variable.go"] = { fg = "none" },
}
}
To change a colour for one style only, use theme_colors. Other styles keep their defaults.
require('onedark').setup {
style = 'darker',
theme_colors = {
darker = { bg0 = '#1a1a1a' }, -- only the darker style gets this background
light = { fg = '#202020' },
},
}
Note that TreeSitter keywords have been changed after neovim version 0.8 and onwards. TS prefix is trimmed and lowercase words should be used separated with '.'
The old way before neovim 0.8 looks like this. For all keywords see this file from line 133 to 257
require('onedark').setup {
colors = {
bright_orange = "#ff8800", -- define a new color
green = '#00ffaa', -- redefine an existing color
},
highlights = {
TSKeyword = {fg = '$green'},
TSString = {fg = '$bright_orange', bg = '#00ff00', fmt = 'bold'},
TSFunction = {fg = '#0000ff', sp = '$cyan', fmt = 'underline,italic'},
TSFuncBuiltin = {fg = '#0059ff'}
}
}
Plugins Configuration
Enable lualine
To Enable the onedark theme for Lualine, specify theme as onedark:
require('lualine').setup {
options = {
theme = 'onedark'
-- ... your lualine config
}
}
Plugins Supported
- TreeSitter
- LSPDiagnostics
- NvimTree
- Telescope
- WhichKey
- Dashboard
- Lualine
- GitGutter
- GitSigns
- VimFugitive
- DiffView
- Hop
- Mini
- Neo-tree
- Neotest
- Barbecue
- IndentBlankline
- vim-illuminate
- indentmini
- Snacks
- sneak.vim
Extras
Matching themes for your terminal and tools, for every style and its light version, are in extras/.
Each file is named onedark_<style>, and light versions onedark_light_<style>. The examples below use dark:
replace it with darker, cool, deep, warm, warmer, light, or a light version such as light_deep.
VS Code
Install One Dark Classic from the VS Code Marketplace or Open VSX, then pick a theme with Preferences: Color Theme. It has all 12 themes: One Dark Classic, One Darker, One Dark Cool, Deep, Warm and Warmer, and One Light Classic, Darker, Cool, Deep, Warm and Warmer.
Ghostty
mkdir -p ~/.config/ghostty/themes
curl -fsSL -o ~/.config/ghostty/themes/onedark_dark https://raw.githubusercontent.com/navarasu/onedark.nvim/master/extras/ghostty/onedark_dark
Then add theme = onedark_dark to ~/.config/ghostty/config.
kitty
mkdir -p ~/.config/kitty
curl -fsSL -o ~/.config/kitty/onedark_dark.conf https://raw.githubusercontent.com/navarasu/onedark.nvim/master/extras/kitty/onedark_dark.conf
Then add include onedark_dark.conf to ~/.config/kitty/kitty.conf.
Alacritty
mkdir -p ~/.config/alacritty/themes
curl -fsSL -o ~/.config/alacritty/themes/onedark_dark.toml https://raw.githubusercontent.com/navarasu/onedark.nvim/master/extras/alacritty/onedark_dark.toml
Then add this to ~/.config/alacritty/alacritty.toml (Alacritty 0.14+; on older versions put import at the top level):
[general]
import = ["~/.config/alacritty/themes/onedark_dark.toml"]
Alacritty reloads the config as soon as you save.
WezTerm
mkdir -p ~/.config/wezterm/colors
curl -fsSL -o ~/.config/wezterm/colors/onedark_dark.toml https://raw.githubusercontent.com/navarasu/onedark.nvim/master/extras/wezterm/onedark_dark.toml
Then set config.color_scheme = "OneDark Dark" in ~/.wezterm.lua (the name is OneDark Darker, OneDark Cool and so on for the other styles).
iTerm2
Download onedark_dark.itermcolors, then in iTerm2 open Settings → Profiles → Colors → Color Presets → Import, and pick the file.
Windows Terminal
Open Settings → Open JSON file, and paste the contents of
onedark_dark.json into the schemes list.
Then set "colorScheme": "OneDark Dark" in your profile.
tmux
mkdir -p ~/.config/tmux
curl -fsSL -o ~/.config/tmux/onedark_dark.tmux https://raw.githubusercontent.com/navarasu/onedark.nvim/master/extras/tmux/onedark_dark.tmux
echo 'source-file ~/.config/tmux/onedark_dark.tmux' >> ~/.tmux.conf
tmux source-file ~/.tmux.conf
Only colours are set; your status line layout is kept.
fzf
mkdir -p ~/.config/fzf
curl -fsSL -o ~/.config/fzf/onedark_dark.sh https://raw.githubusercontent.com/navarasu/onedark.nvim/master/extras/fzf/onedark_dark.sh
echo 'source ~/.config/fzf/onedark_dark.sh' >> ~/.zshrc # or ~/.bashrc
lazygit
Copy the gui.theme block from onedark_dark.yml into lazygit's
config.yml (run lazygit --print-config-dir to find it).
delta
curl -fsSL -o ~/.config/delta-onedark_dark.gitconfig https://raw.githubusercontent.com/navarasu/onedark.nvim/master/extras/delta/onedark_dark.gitconfig
git config --global --add include.path ~/.config/delta-onedark_dark.gitconfig
git config --global delta.features onedark-dark
The files are generated from the theme's palette, so they always match the editor. After changing
lua/onedark/palette.lua, run nvim -l scripts/extras.lua.
Reference
Contributing
Pull requests are welcome 🎉👍.
License
Made by Navarasu · navarasu.com
探索相关项目
加载中…