ITADN
catppuccin/nvim · 文件 下载 ZIP
文件最后提交记录最后更新时间
README.md
以下内容由 AI 翻译,如有问题请点此提交 issue 反馈

Logo
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" } }

lazy.nvim

{ "catppuccin/nvim", name = "catppuccin", priority = 1000 }

packer.nvim

use { "catppuccin/nvim", as = "catppuccin" }

rocks.nvim

:Rocks install catppuccin.nvim

Vim 支持

对 Vim 的支持通过 vim 分支提供。

vim-plug

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.packlazy.nvimpckr.nvim 来管理你的插件,你可以 使用 auto_integrations 选项让 catppuccin 自动检测 已安装的插件并启用它们各自的集成(此选项 默认启用)。

require("catppuccin").setup({
    auto_integrations = true,
})

以下是支持的插件及其对应的集成模块列表。

[!Important] 如果您想查看 Catppuccin 修改的完整高亮组列表,请参阅 lua/catppuccin/groups/integrations/ 目录。

插件 默认

aerial.nvim

aerial = false

alpha-nvim

alpha = true
artio.nvim
artio = true

barbar.nvim

barbar = false

barbecue.nvim

barbecue = {
    dim_dirname = true, -- directory name is dimmed by default
    bold_basename = true,
    dim_context = false,
    alt_background = false,
},
Special

使用此命令进行设置:

require("barbecue").setup {
  theme = "catppuccin-nvim", -- catppuccin-latte, catppuccin-frappe, catppuccin-macchiato, catppuccin-mocha
}

beacon.nvim

beacon = false

blink.cmp

blink_cmp = {
    style = 'bordered',
}

blink.indent

blink_indent = true

blink.pairs

blink_pairs = true
Special

使用此命令进行设置:

require("blink.pairs").setup {
    highlights = {
        groups = {
            "BlinkPairsRed",
            "BlinkPairsYellow",
            "BlinkPairsBlue",
            "BlinkPairsOrange",
            "BlinkPairsGreen",
            "BlinkPairsPurple",
            "BlinkPairsCyan",
        },
    },
}

bufferline.nvim

Special

更新你的 bufferline 配置以使用 Catppuccin 组件:

[!NOTE] bufferline 需要在设置好 Catppuccin 之后加载,否则高亮会不正确

use "akinsho/bufferline.nvim" {
  after = "catppuccin",
  config = function()
    require("bufferline").setup {
      highlights = require("catppuccin.special.bufferline").get_theme()
    }
  end
}

配置项不言自明,详见 :h bufferline-highlights 中的详细说明:

local mocha = require("catppuccin.palettes").get_palette "mocha"
bufferline.setup {
    highlights = require("catppuccin.special.bufferline").get_theme {
        styles = { "italic", "bold" },
        custom = {
            all = {
                fill = { bg = "#000000" },
            },
            mocha = {
                background = { fg = mocha.text },
            },
            latte = {
                background = { fg = "#000000" },
            },
        },
    },
}

buffon.nvim

buffon = false

coc.nvim

coc_nvim = false
Special

enabled 设置为 true 可启用此集成。

coc_nvim = true,

[!Note] coc.nvim 默认链接到原生 lsp 高亮组,因此 lsp_styles 选项也会应用于 coc

在嵌套表格中,你可以设置诊断的样式,包括 virtual_text(你在侧边看到的内容)和 underlines(直接指向该对象的内容(例如错误))。

lsp_styles = {
    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,
    },
},

colorful-winsep.nvim

colorful_winsep = {
    enabled = false,
    color = "red",
}

dashboard-nvim

dashboard = true

diffview.nvim

diffview = false

dropbar.nvim

dropbar = {
    enabled = false,
    color_mode = false, -- enable color for kind's texts, not just kind's icons
},

feline.nvim

Special

更新你的 Feline 配置以使用 Catppuccin 组件:

local ctp_feline = require('catppuccin.special.feline')

ctp_feline.setup()

require("feline").setup({
    components = ctp_feline.get_statusline(),
})

请注意,调用 setup() 是可选的。您可以传入一个 lua 表,以按 vim 模式更改 assets、settings 和 colors。

以下是默认值:

local clrs = require("catppuccin.palettes").get_palette()
local ctp_feline = require('catppuccin.special.feline')
local U = require "catppuccin.utils.colors"

ctp_feline.setup({
    assets = {
        left_separator = "",
        right_separator = "",
        mode_icon = "",
        dir = "󰉖",
        file = "󰈙",
        lsp = {
            server = "󰅡",
            error = "",
            warning = "",
            info = "",
            hint = "",
        },
        git = {
            branch = "",
            added = "",
            changed = "",
            removed = "",
        },
    },
    sett = {
        text = U.vary_color({ latte = latte.base }, clrs.surface0),
        bkg = U.vary_color({ latte = latte.crust }, clrs.surface0),
        diffs = clrs.mauve,
        extras = clrs.overlay1,
        curr_file = clrs.maroon,
        curr_dir = clrs.flamingo,
        show_modified = false, -- show if the file has been modified
        show_lazy_updates = false -- show the count of updatable plugins from lazy.nvim
                                  -- need to set checker.enabled = true in lazy.nvim first
                                  -- the icon is set in ui.icons.plugin in lazy.nvim
    },
    mode_colors = {
        ["n"] = { "NORMAL", clrs.lavender },
        ["no"] = { "N-PENDING", clrs.lavender },
        ["i"] = { "INSERT", clrs.green },
        ["ic"] = { "INSERT", clrs.green },
        ["t"] = { "TERMINAL", clrs.green },
        ["v"] = { "VISUAL", clrs.flamingo },
        ["V"] = { "V-LINE", clrs.flamingo },
        [""] = { "V-BLOCK", clrs.flamingo },
        ["R"] = { "REPLACE", clrs.maroon },
        ["Rv"] = { "V-REPLACE", clrs.maroon },
        ["s"] = { "SELECT", clrs.maroon },
        ["S"] = { "S-LINE", clrs.maroon },
        [""] = { "S-BLOCK", clrs.maroon },
        ["c"] = { "COMMAND", clrs.peach },
        ["cv"] = { "COMMAND", clrs.peach },
        ["ce"] = { "COMMAND", clrs.peach },
        ["r"] = { "PROMPT", clrs.teal },
        ["rm"] = { "MORE", clrs.teal },
        ["r?"] = { "CONFIRM", clrs.mauve },
        ["!"] = { "SHELL", clrs.green },
    },
    view = {
        lsp = {
            progress = true, -- if true the status bar will display an lsp progress indicator
            name = false, -- if true the status bar will display the lsp servers name, otherwise it will display the text "Lsp"
            exclude_lsp_names = {}, -- lsp server names that should not be displayed when name is set to true
            separator = "|", -- the separator used when there are multiple lsp servers
        },
    }
})

[!Warning] 目前 feline 并不官方支持自定义主题。为了让 :colorscheme catppuccin-<flavour> 正常工作,你可以添加此 autocmd 作为变通方案:

vim.api.nvim_create_autocmd("ColorScheme", {
    pattern = "*",
    callback = function()
        package.loaded["feline"] = nil
        package.loaded["catppuccin.special.feline"] = nil
        require("feline").setup {
            components = require("catppuccin.special.feline").get_statusline(),
        }
    end,
})

fern.vim

fern = false

fidget.nvim

fidget = false
Special 将 `notification.window.winblend` 设置为 `0`:
require("fidget").setup {
    notification = {
        window = {
            winblend = 0,
        },
    }
    -- ... the rest of your fidget config
}

flash.nvim

flash = true

fzf-lua

fzf = true

gitgraph.nvim

gitgraph = false

gitsigns.nvim

gitsigns = true
Special
gitsigns = {
  enabled = true,
  -- align with the transparent_background option by default
  transparent = false,
}

grug-far.nvim

grug_far = false

harpoon

harpoon = false

headlines.nvim

headlines = false

hop.nvim

hop = false

indent-blankline.nvim

indent_blankline = {
    enabled = true,
    scope_color = "", -- catppuccin color (eg. `lavender`) Default: text
    colored_indent_levels = false,
},
Special

colored_indent_levels 按缩进级别启用字符高亮。按照此处的说明进行设置。

leap.nvim

leap = false

lightline.vim

Special
let g:lightline = {'colorscheme': 'catppuccin'}

lightspeed.nvim

lightspeed = false

lir.nvim

lir = {
    enabled = false,
    git_status = false
}

lspsaga.nvim

lsp_saga = false
Special

用于自定义 Lsp Kind 图标和颜色

require("lspsaga").setup {
    ui = {
        kind = require("catppuccin.groups.integrations.lsp_saga").custom_kind(),
    },
}

lualine.nvim

-- transparent_bg = opts.transparent_background and "NONE" or C.mantle
lualine = {
    normal = {
        a = { bg = C.blue, fg = C.mantle, gui = "bold" },
        b = { bg = C.surface0, fg = C.blue },
        c = { bg = transparent_bg, fg = C.text },
    },

    insert = {
        a = { bg = C.green, fg = C.base, gui = "bold" },
        b = { bg = C.surface0, fg = C.green },
    },

    terminal = {
        a = { bg = C.green, fg = C.base, gui = "bold" },
        b = { bg = C.surface0, fg = C.green },
    },

    command = {
        a = { bg = C.peach, fg = C.base, gui = "bold" },
        b = { bg = C.surface0, fg = C.peach },
    },
    visual = {
        a = { bg = C.mauve, fg = C.base, gui = "bold" },
        b = { bg = C.surface0, fg = C.mauve },
    },
    replace = {
        a = { bg = C.red, fg = C.base, gui = "bold" },
        b = { bg = C.surface0, fg = C.red },
    },
    inactive = {
        a = { bg = transparent_bg, fg = C.blue },
        b = { bg = transparent_bg, fg = C.surface1, gui = "bold" },
        c = { bg = transparent_bg, fg = C.overlay0 },
    },
},
Special

要在 integrations.lualine 规范中实现颜色覆盖:

-- In your catppuccin config (integrations):
lualine = {
    -- lualine color overrides in the following hierarchy: Catppuccin Flavor -> Mode -> Lualine Section
    -- The Catppuccin flavor entry can be any Catpuccin flavor or "all" to apply to all flavors
    -- The flavor entry can be either a table or a function which consumes the current Catppuccin palette, just like custom_highlights and color_overrides
    all = function(colors)
        ---@type CtpIntegrationLualineOverride
        return {
            -- Specifying a normal-mode status line override for section a's background and b's foreground to use lavender like the main Catppuccin theme
            normal = {
                a = { bg = colors.lavender, gui = "italic" },
                b = { fg = colors.lavender },
            }
        }
    end,
    -- A macchiato-specific override, which takes priority over 'all'. Also using the direct table syntax instead of function in case you do not rely on dynamic palette colors
    macchiato = {
        normal = {
            a = { bg = "#abcdef" },
        }
    },
},
--  And in your lualine config:
require('lualine').setup {
    options = {
        -- lualine will integrate with catppuccin by name or automatically via `vim.g.colors_name` by setting this to "auto"
        theme = "catppuccin-nvim"
        -- ... the rest of your lualine config
    }
}

markview.nvim

markview = false

mason.nvim

mason = false

mini.nvim

mini = {
    enabled = true,
    indentscope_color = "", -- catppuccin color (eg. `lavender`) Default: text
},

neo-tree.nvim

neotree = true

neogit

neogit = true

neotest

neotest = false

noice.nvim

noice = false

notifier.nvim

notifier = false

nvim-cmp

cmp = true

copilot.vim

copilot_vim = false,

nvim-dap

dap = true
Special
local sign = vim.fn.sign_define

sign("DapBreakpoint", { text = "●", texthl = "DapBreakpoint", linehl = "", numhl = ""})
sign("DapBreakpointCondition", { text = "●", texthl = "DapBreakpointCondition", linehl = "", numhl = ""})
sign("DapLogPoint", { text = "◆", texthl = "DapLogPoint", linehl = "", numhl = ""})

nvim-dap-ui

dap_ui = true

navic

navic = {
    enabled = false,
    custom_bg = "NONE", -- "lualine" will set background to mantle
},
Special
-- You NEED to enable highlight in nvim-navic setting or it won't work
require("nvim-navic").setup {
    highlight = true
}

nvim-notify

notify = false

nvim-surround

nvim_surround = false

nvim-tree.lua

nvimtree = true

nvim-treesitter-context

treesitter_context = true

nvim-ts-rainbow2

ts_rainbow2 = false

nvim-ts-rainbow

ts_rainbow = false

nvim-ufo

ufo = true

nvim-window-picker

window_picker = false

octo.nvim

octo = false

overseer.nvim

overseer = false

pounce.nvim

pounce = false

rainbow-delimiters.nvim

rainbow_delimiters = true

reactive.nvim

Special

每种风味都有 2 个可用的预设(cursorcursorline)。

以下是使用方法。

require('reactive').setup {
  load = { 'catppuccin-mocha-cursor', 'catppuccin-mocha-cursorline' }
}

要使用其他风味,只需将 mocha 替换为您想要使用的即可。

render-markdown.nvim

render_markdown = true

snacks.nvim

snacks = {
    enabled = false,
    indent_scope_color = "", -- catppuccin color (eg. `lavender`) Default: overlay2
}

symbols-outline.nvim

[!NOTE] 此插件已被作者归档,建议改用 outline.nvim

symbols_outline = false

telekasten.nvim

telekasten = false

telescope.nvim

telescope = {
    enabled = true,
}

trouble.nvim

lsp_trouble = false

vim-airline

Special
let g:airline_theme = 'catppuccin'

vim-clap

Special

使用此命令进行设置:

let g:clap_theme = 'catppuccin'

vim-dadbod-ui

dadbod_ui = false

vim-gitgutter

gitgutter = false

vim-illuminate

illuminate = {
    enabled = true,
    lsp = false
}

vim-sandwich

sandwich = false

vim-signify

signify = false

vim-sneak

vim_sneak = false

vimwiki

vimwiki = false

which-key.nvim

which_key = false

编译

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 万种颜色范围。

如果您使用 tmux,请确保启用 true color 支持斜体字体 支持。 这将避免在 #415#428 中提出的问题。

💝 致谢

当前维护者

前维护者

 

版权所有 © 2021-至今 Catppuccin Org