
Catppuccin for Neovim
这个 Catppuccin 的移植版本很特别,因为它是第一个,也是项目本身的起源。鉴于此,重要的是要认识到,这一切并非凭空而来,而是逐渐发展成如今的样子。因此,如果你有兴趣了解更多关于该主题早期阶段的信息,可以在 v0.1 标签下找到相关内容。
Previews
🌻 Latte
🪴 Frappé
🌺 Macchiato
🌿 Mocha
特性
安装
使用 Neovim 0.12 的 vim.pack
vim.pack.add { { src = "https://github.com/catppuccin/nvim", name = "catppuccin" } }
{ "catppuccin/nvim", name = "catppuccin", priority = 1000 }
use { "catppuccin/nvim", as = "catppuccin" }
:Rocks install catppuccin.nvim
Vim 支持
对 Vim 的支持通过 vim 分支提供。
Plug 'catppuccin/nvim', { 'branch': 'vim', 'as': 'catppuccin' }
[!NOTE] 请注意,Vim 支持已被移除 (#949),并且除非必要,此分支将不再 接收进一步更新。如需完整的 Vim 支持,请参阅 catppuccin/vim。从 Vim v9.2.0219 和 Neovim 0.12 开始,
catppuccin已随编辑器一同发布。请注意, 它不由 Catppuccin 组织维护,并遵循 Vim colorscheme rules 而非 the official Catppuccin style guide。
Usage
colorscheme catppuccin-nvim " catppuccin-latte, catppuccin-frappe, catppuccin-macchiato, catppuccin-mocha
vim.cmd.colorscheme "catppuccin-nvim"
配置
如果您不想更改默认选项和设置,则无需调用 setup。
require("catppuccin").setup({
flavour = "auto", -- latte, frappe, macchiato, mocha
background = { -- :h background
light = "latte",
dark = "mocha",
},
transparent_background = false, -- disables setting the background color.
float = {
transparent = false, -- enable transparent floating windows
solid = false, -- use solid styling for floating windows, see |winborder|
},
term_colors = false, -- sets terminal colors (e.g. `g:terminal_color_0`)
dim_inactive = {
enabled = false, -- dims the background color of inactive window
shade = "dark",
percentage = 0.15, -- percentage of the shade to apply to the inactive window
},
no_italic = false, -- Force no italic
no_bold = false, -- Force no bold
no_underline = false, -- Force no underline
styles = { -- Handles the styles of general hi groups (see `:h highlight-args`):
comments = { "italic" }, -- Change the style of comments
conditionals = { "italic" },
loops = {},
functions = {},
keywords = {},
strings = {},
variables = {},
numbers = {},
booleans = {},
properties = {},
types = {},
operators = {},
-- miscs = {}, -- Uncomment to turn off hard-coded styles
},
lsp_styles = { -- Handles the style of specific lsp hl groups (see `:h lsp-highlight`).
virtual_text = {
errors = { "italic" },
hints = { "italic" },
warnings = { "italic" },
information = { "italic" },
ok = { "italic" },
},
underlines = {
errors = { "underline" },
hints = { "underline" },
warnings = { "underline" },
information = { "underline" },
ok = { "underline" },
},
inlay_hints = {
background = true,
},
},
color_overrides = {},
custom_highlights = {},
auto_integrations = true,
integrations = {
cmp = true,
gitsigns = true,
nvimtree = true,
notify = false,
mini = {
enabled = true,
indentscope_color = "",
},
-- For more plugins integrations please scroll down (https://github.com/catppuccin/nvim#integrations)
},
})
-- setup must be called before loading
vim.cmd.colorscheme "catppuccin-nvim"
自定义
获取颜色
local latte = require("catppuccin.palettes").get_palette "latte"
local frappe = require("catppuccin.palettes").get_palette "frappe"
local macchiato = require("catppuccin.palettes").get_palette "macchiato"
local mocha = require("catppuccin.palettes").get_palette "mocha"
返回一个表格,其中键为颜色名称,值为十六进制代码。
覆盖颜色
可以使用 color_overrides 覆盖颜色,参见 https://github.com/catppuccin/nvim/discussions/323 以获取灵感:
require("catppuccin").setup {
color_overrides = {
all = {
text = "#ffffff",
},
latte = {
base = "#ff0000",
mantle = "#242424",
crust = "#474747",
},
frappe = {},
macchiato = {},
mocha = {},
}
}
覆盖高亮组
全局高亮组可以被覆盖,例如:
require("catppuccin").setup {
custom_highlights = function(colors)
return {
Comment = { fg = colors.flamingo },
TabLineSel = { bg = colors.pink },
CmpBorder = { fg = colors.surface2 },
Pmenu = { bg = colors.none },
}
end
}
每种风味(flavour)的高亮组也可以被覆盖,例如:
require("catppuccin").setup {
highlight_overrides = {
all = function(colors)
return {
NvimTreeNormal = { fg = colors.none },
CmpBorder = { fg = "#3e4145" },
}
end,
latte = function(latte)
return {
Normal = { fg = latte.base },
}
end,
frappe = function(frappe)
return {
["@comment"] = { fg = frappe.surface2, style = { "italic" } },
}
end,
macchiato = function(macchiato)
return {
LineNr = { fg = macchiato.overlay1 },
}
end,
mocha = function(mocha)
return {
Comment = { fg = mocha.flamingo },
}
end,
},
}
集成
Catppuccin 为 Neovim 生态系统中的其他插件提供主题支持,并通过 integrations 扩展 Neovim 功能。
要启用/禁用某个集成,只需将其设置为 true/false,例如:
require("catppuccin").setup({
integrations = {
cmp = true,
gitsigns = true,
nvimtree = true,
notify = false,
mini = {
enabled = true,
indentscope_color = "",
},
}
})
如果你使用 vim.pack、lazy.nvim 或
pckr.nvim 来管理你的插件,你可以
使用 auto_integrations 选项让 catppuccin 自动检测
已安装的插件并启用它们各自的集成(此选项
默认启用)。
require("catppuccin").setup({
auto_integrations = true,
})
以下是支持的插件及其对应的集成模块列表。
[!Important] 如果您想查看 Catppuccin 修改的完整高亮组列表,请参阅
lua/catppuccin/groups/integrations/目录。
| 插件 | 默认 |
| |
| |
| artio.nvim |
|
| |
Special使用此命令进行设置:
| |
| |
| |
| |
Special使用此命令进行设置:
| |
Special更新你的 bufferline 配置以使用 Catppuccin 组件:
配置项不言自明,详见
| |
| |
Special将
在嵌套表格中,你可以设置诊断的样式,包括
| |
| |
| |
| |
| |
Special更新你的 Feline 配置以使用 Catppuccin 组件:
请注意,调用 以下是默认值:
| |
| |
Special将 `notification.window.winblend` 设置为 `0`:
| |
| |
| |
| |
Special
| |
| |
| |
| |
| |
Special
| |
| |
Special
| |
| |
| |
Special用于自定义 Lsp Kind 图标和颜色
| |
Special要在
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
Special
| |
| |
Special
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
Special每种风味都有 2 个可用的预设( 以下是使用方法。
要使用其他风味,只需将 | |
| |
| |
| |
| |
| |
| |
Special
| |
Special使用此命令进行设置:
| |
| |
| |
| |
| |
| |
| |
| |
|
编译
Catppuccin 是一个高度可定制和可配置的颜色方案。然而, 这以增加复杂性和执行时间为代价。Catppuccin 可以预先 计算您配置的结果,并将结果存储在一个编译后的 Lua 文件中。我们使用这些预缓存的值来设置其高亮。
默认情况下,Catppuccin 会将编译结果写入系统的缓存 目录。如果您想更改缓存目录,请参阅下文:
require("catppuccin").setup({ -- Note: On windows we replace `/` with `\` by default
compile_path = vim.fn.stdpath "cache" .. "/catppuccin"
})
🙋 常见问题
为什么我的 Treesitter 高亮看起来不正确?
请禁用 additional_vim_regex_highlighting:
require("nvim-treesitter.configs").setup {
highlight = {
enable = true,
additional_vim_regex_highlighting = false
},
}
为什么我的颜色与预览不一致?
Catppuccin 要求您的终端支持 true color,即您的 终端能够显示完整的 1600 万种颜色范围。
- 支持:iterm2 (macOS), kitty, wezterm, alacritty, 查看完整列表...
- 不支持:Terminal.app (macOS), Terminus, Terminology, 查看完整列表...
如果您使用 tmux,请确保启用 true color 支持 和 斜体字体 支持。 这将避免在 #415 和 #428 中提出的问题。
💝 致谢
当前维护者
前维护者
版权所有 © 2021-至今 Catppuccin Org