🍨 Soothing pastel theme for NeoVim
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Go to file
Pocco81 ecfb68bdcd added @nullchilly as maintainer 2 years ago
.github/workflows ci(github): Add pull request check on dev branch 2 years ago
assets added demo png 3 years ago
autoload/lightline/colorscheme Fix lightline 3 years ago
colors refactor(colors): Remove vimscript 2 years ago
lua added @nullchilly as maintainer 2 years ago
.editorconfig dev: initial structure 3 years ago
.gitignore Initial commit 3 years ago
CONTRIBUTING.md license 3 years ago
LICENSE.md updated license 3 years ago
README.md added @nullchilly as maintainer 2 years ago
stylua.toml feat: added StyLua conf file 3 years ago

README.md

Logo
Catppuccin for NeoVim

About

This port of Catppuccin is special because it was the first one and the one that originated the project itself. Given this, it's important to acknowledge that it all didn't come to be what it is now out of nowhere. So, if you are interested in knowing more about the initial stages of the theme, you can find it under the old-catppuccino branch.

🎁 Features

Usage

You can use your favorite plugin manager for this. Here are some examples with the most popular ones:

Vim-plug

Plug 'catppuccin/nvim', {'as': 'catppuccin'}

Packer.nvim

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

Vundle

Plugin 'catppuccin/nvim', {'name': 'catppuccin'}

Setup

There are already some sane defaults that you may like, however you can change them to match your taste. These are the defaults:

dim_inactive = {
	enabled = false
	shade = "dark",
	percentage = 0.15,
},
transparent_background = false,
term_colors = false,
compile = {
	enabled = false,
	path = vim.fn.stdpath "cache" .. "/catppuccin",
	suffix = "_compiled"
},
styles = {
	comments = { "italic" },
	conditionals = { "italic" },
	loops = {},
	functions = {},
	keywords = {},
	strings = {},
	variables = {},
	numbers = {},
	booleans = {},
	properties = {},
	types = {},
	operators = {},
},
integrations = {
	treesitter = true,
	native_lsp = {
		enabled = true,
		virtual_text = {
			errors = { "italic" },
			hints = { "italic" },
			warnings = { "italic" },
			information = { "italic" },
		},
		underlines = {
			errors = { "underline" },
			hints = { "underline" },
			warnings = { "underline" },
			information = { "underline" },
		},
	},
	coc_nvim = false,
	lsp_trouble = false,
	cmp = true,
	lsp_saga = false,
	gitgutter = false,
	gitsigns = true,
	telescope = true,
	nvimtree = {
		enabled = true,
		show_root = true,
		transparent_panel = false,
	},
	neotree = {
		enabled = false,
		show_root = true,
		transparent_panel = false,
	},
	dap = {
		enabled = false,
		enable_ui = false,
	},
	which_key = false,
	indent_blankline = {
		enabled = true,
		colored_indent_levels = false,
	},
	dashboard = true,
	neogit = false,
	vim_sneak = false,
	fern = false,
	barbar = false,
	bufferline = true,
	markdown = true,
	lightspeed = false,
	ts_rainbow = false,
	hop = false,
	notify = true,
	telekasten = true,
	symbols_outline = true,
	mini = false,
}

The way you setup the settings on your configuration varies based on whether you are using vimL for this or Lua.

For init.lua

local catppuccin = require("catppuccin")

-- configure it
catppuccin.setup(<settings>)

For init.vim

lua << EOF
local catppuccin = require("catppuccin")

-- configure it
catppuccin.setup(<settings>)
EOF

After setting things up, you can load catppuccin like so:

" Vim Script
let g:catppuccin_flavour = "frappe" " latte, frappe, macchiato, mocha
colorscheme catppuccin
-- Lua
vim.g.catppuccin_flavour = "frappe" -- latte, frappe, macchiato, mocha
vim.cmd[[colorscheme catppuccin]]

Remember that if you want to switch your Catppuccin flavour "on the fly" you may use the :Catppuccin <flavour> command.

Note: the command has autocompletion enabled, so you can just press tab to cycle through the flavours

Configuration

Although settings already have self-explanatory names, here is where you can find info about each one of them and their classifications!

General

This settings are unrelated to any group and are independent.

  • transparent_background: (Boolean) if true, disables setting the background color.
  • term_colors: (Boolean) if true, sets terminal colors (e.g. g:terminal_color_0).

Dim inactive

This setting manages the ability to dim the inactive splits/windows/buffers displayed.

  • enabled: (Boolean) if true, dims the background color of inactive window or buffer or split.
  • shade: (string) sets the shade to apply to the inactive split or window or buffer.
  • percentage: (number 0 < x < 1) percentage of the shade to apply to the inactive window, split or buffer.

Styles

Handles the style of general hi groups (see :h highlight-args):

  • comments: (Table) changed the style of the comments.
  • functions: (Table) changed the style of the functions.
  • keywords: (Table) changed the style of the keywords.
  • strings: (Table) changed the style of the strings.
  • variables: (Table) changed the style of the variables.

Integrations

These integrations allow catppuccin to set the theme of various plugins/stuff. To enable an integration you just need to set it to true, however, there are some special integrations...

If you'd like to know which highlight groups are being affected by catppuccin, checkout this directory: lua/catppuccin/groups/integrations/.

Special Integrations
  • Feline.nvim: First make sure that the kyazdani42/nvim-web-devicons plugin is installed. Then update your Feline config to use the Catppuccin components:
require("feline").setup({
	components = require('catppuccin.groups.integrations.feline'),
})
  • Indent-blankline.nvim: setting enabled to true enables this integration. colored_indent_levels enables char highlights per indent level. Follow the instructions here to set the latter up.
  • Lightline: use this to set it up (Note: catppuccin is the only valid colorscheme name. It will pick the one set in your config):
let g:lightline = {'colorscheme': 'catppuccin'}
  • Lualine: use this to set it up (Note: catppuccin is the only valid theme name. It will pick the one set in your config):
require('lualine').setup {
	options = {
		theme = "catppuccin"
		-- ... the rest of your lualine config
	}
}
  • Native Nvim LSP: setting enabled to true enables this integration. In the inners tables you can set the style for the diagnostics, both virtual_text (what you see on the side) and underlines (what points directly at the thing (e.g. an error)).
  • NvimTree: setting enabled to true enables this integration:
integration = {
	nvimtree = {
		enabled = true,
		show_root = true, -- makes the root folder not transparent
		transparent_panel = false, -- make the panel transparent
	}
}
  • Neo-tree: setting enabled to true enables this integration:
integration = {
	neotree = {
		enabled = true,
		show_root = true, -- makes the root folder not transparent
		transparent_panel = false, -- make the panel transparent
	}
}
  • Nvim-dap: setting enabled to true:
dap = {
	enabled = true,
	enable_ui = true,
},
-- You need to override nvim-dap's default highlight groups, AFTER requiring nvim-dap
require("dap")

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 = ""})

Compile

Catppuccin is a highly customizable and configurable colorscheme. This does however come at the cost of complexity and execution time.

Catppuccin can pre compute the results of your configuration and store the results in a compiled lua file. We use these precached values to set it's highlights.

Enable

Setting enabled to true enables this feature:

compile = {
	enabled = true,
	path = vim.fn.stdpath "cache" .. "/catppuccin",
	suffix = "_compiled"
},

By default catppuccin writes the compiled results into the system's cache directory. Note: On windows we replace / with \ by default

Compile commands

:CatppuccinCompile " Create/update the compile file
:CatppuccinClean " Delete compiled file

Post-install/update hooks

Packer.nvim

-- It's recommended to add `:CatppuccinCompile` to post-install/update hooks
use {
	"catppuccin/nvim",
	as = "catppuccin",
	run = "CatppuccinCompile",
}

Vim-plug

Plug 'catppuccin/nvim', {'as': 'catppuccin', 'do': 'CatppuccinCompile'}

Auto compile

Packer.nvim

-- If you want catppuccin live reload after :PackerCompile
require("packer").init {
	auto_reload_compiled = true,
}
-- Create an autocmd User PackerCompileDone to update it every time packer is compiled
vim.api.nvim_create_autocmd("User", {
	pattern = "PackerCompileDone",
	callback = function()
		vim.cmd "CatppuccinCompile"
		vim.defer_fn(function()
			vim.cmd "colorscheme catppuccin"
		end, 50) -- Debounced for live reloading
	end,
})
-- PackerCompile on save assuming your plugin spefication file is in plugins.lua or catppuccin.lua
vim.api.nvim_create_autocmd("BufWritePost", {
	pattern = { "plugins.lua", "catppuccin.lua" },
	callback = function()
		vim.cmd "PackerCompile"
	end,
})

Vim-plug

" Auto compile on save if catppuccin config is written inside init.vim
autocmd BufWritePost init.vim :CatppuccinCompile

Acknowledge

nightfox.nvim#compile

Extra

Get catppuccin colors
require("catppuccin.palettes").get_palette()

Will returns a table where the key is the name of the color and the value is its hex value.

Overwriting highlight groups

Highlight groups can be overwritten in the setting like so:

custom_highlights = {
	<hi_group> = { <fields> }
}

Here is an example:

local colors = require("catppuccin.palettes").get_palette() -- fetch colors from palette
custom_highlights = {
	Comment = { fg = colors.flamingo }
	TSConstBuiltin = { fg = colors.peach, style = {} },
	TSConstant = { fg = colors.sky },
	TSComment = { fg = colors.surface2, style = { "italic" } }
}

Overwriting colors

Colors can be overwritten using color_overrides in the setting:

color_overrides = {
	frappe = {
		text = "#ffffff"
		base = "#ff0000",
		mantle = "#242424",
		crust = "#474747",
	}
},

Hooks

Use them to execute code at certain events. These are the ones available:

Autocmd Description
ColorSchemePre Before loading a colorscheme
ColorScheme After loading a colorscheme

They can be used like so:

vim.api.nvim_create_autocmd("ColorSchemePre", {
	pattern = "*",
	callback = function()
		print "I ran before loading Catppuccin!"
	end,
})

vim.api.nvim_create_autocmd("ColorScheme", {
	pattern = "*",
	callback = function()
		local colors = require("catppuccin.palettes").get_palette()
		-- do something with colors
	end,
})

FAQ

Transparent background tweak?

Add this to custom_highlights settings

local colors = require("catppuccin.palettes").get_palette()
colors.none = "NONE"
require("catppuccin").setup {
	custom_highlights = {
		Comment = { fg = colors.overlay1 },
		LineNr = { fg = colors.overlay1 },
		CursorLine = { bg = colors.none },
		CursorLineNr = { fg = colors.lavender },
		DiagnosticVirtualTextError = { bg = colors.none },
		DiagnosticVirtualTextWarn = { bg = colors.none },
		DiagnosticVirtualTextInfo = { bg = colors.none },
		DiagnosticVirtualTextHint = { bg = colors.none },
	}
}

Use catppuccin theme for :set background=light/dark?

The following autocmd will change the flavour to latte when you :set background=light and to mocha after :set background=dark

vim.api.nvim_create_autocmd("OptionSet", {
	pattern = "background",
	callback = function()
		vim.cmd("Catppuccin " .. (vim.v.option_new == "light" and "latte" or "mocha"))
	end,
})

For people who are hybrid between light and dark mode!

Catppuccin highlight function?

This is the old remap function under the hood:

require("catppuccin.lib.highlight").syntax({
	Normal = { style = { "italic", "bold" } }
})

Note: Unlike the :highlight command which can update a highlight group, this function completely replaces the definition. (:h nvim_set_hl)

However, if you wish to use the old highlight api (slower):

local function syntax(tbl)
	for group, color in pairs(tbl) do
		if color.style then
			color.style = table.concat(color.style, ",")
		end
		local style = color.style and "gui=" .. color.style or "gui=NONE"
		local fg = color.fg and "guifg=" .. color.fg or "guifg=NONE"
		local bg = color.bg and "guibg=" .. color.bg or "guibg=NONE"
		local sp = color.sp and "guisp=" .. color.sp or ""
		local blend = color.blend and "blend=" .. color.blend or ""
		local hl = "highlight " .. group .. " " .. style .. " " .. fg .. " " .. bg .. " " .. sp .. " " .. blend
		vim.cmd(hl)
		if color.link then
			vim.cmd("highlight! link " .. group .. " " .. color.link)
		end
	end
end

syntax {
	Normal = { style = { "italic", "bold" } },
}

Abnormal colors?

You need to enable truecolor

Related: :h termguicolors, catppuccin/nvim#182,

💝 Thanks to

 

Copyright © 2021-present Catppuccin Org