Skip to content

joe23rep/colorscheme

Repository files navigation

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

Installation

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

Packer.nvim

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

Vim-plug

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

Usage

For lua

vim.g.catppuccin_flavour = "macchiato" -- latte, frappe, macchiato, mocha

require("catppuccin").setup()

vim.cmd [[colorscheme catppuccin]]

For vimscript

let g:catppuccin_flavour = "macchiato" " latte, frappe, macchiato, mocha

lua << EOF
require("catppuccin").setup()
EOF

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

You may pass a lua table to the setup() function in order to edit any of Catppuccin's settings:

require("catppuccin").setup({
	dim_inactive = {
		enabled = false,
		shade = "dark",
		percentage = 0.15,
	},
	transparent_background = false,
	term_colors = false,
	compile = {
		enabled = false,
		path = vim.fn.stdpath "cache" .. "/catppuccin",
	},
	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,
		leap = false,
		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,
		aerial = false,
		vimwiki = true,
		beacon = true,
		navic = false,
		overseer = false,
	},
	color_overrides = {},
	highlight_overrides = {},
})

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:
local ctp_feline = require('catppuccin.groups.integrations.feline')

ctp_feline.setup()

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

Notice that calling setup() is optional. You may pass a lua table in order to change assets, settings and the colors per vim mode.

Here are the defaults

local clrs = require("catppuccin.palettes").get_palette()
assets = {
	left_separator = "",
	right_separator = "",
	bar = "",
	mode_icon = ""
},
sett = {
	text = ucolors.vary_color({ latte = latte.base }, clrs.surface0),
	bkg = ucolors.vary_color({ latte = latte.crust }, clrs.surface0),
	diffs = clrs.mauve,
	extras = clrs.overlay1,
	curr_file = clrs.maroon,
	curr_dir = clrs.flamingo,
	show_modified = true -- show if the file has been modified
},
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 },
}

  • 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'}
  • vim-clap: use this to set it up:
let g:clap_theme = '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:
integration = {
	dap = {
		enabled = true,
		enable_ui = true, -- enable nvim-dap-ui
	}
}
-- 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 = ""})
  • Nvim-navic: setting enabled to true:
integration = {
	navic = true
}
-- You NEED to enable highlight in nvim-navic setting or it won't work
require("nvim-navic").setup {
	highlight = true
}

Customize highlights

Get catppuccin colors

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"

vim.g.catppuccin_flavour = "macchiato" -- Has to be set in order for empty argument to work
local colors = require("catppuccin.palettes").get_palette() -- g:catppuccin_flavour's palette

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

Overwriting highlight groups

Global highlight groups can be overwritten in the setting like so:

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

Here is an example:

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

Per flavour highlight groups can be overwritten in the setting like so:

highlight_overrides = {
	all = { -- Will be replaced with custom_highlights if it exists
		<hi_group> = { <fields> }
	}, -- Same for each flavour
	latte = {},
	frappe = {},
	macchiato = {},
	mocha = {},
}

Here is an example:

local ucolors = require "catppuccin.utils.colors"
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"

vim.g.catppuccin_flavour = "macchiato"
local colors = require("catppuccin.palettes").get_palette() -- return vim.g.catppuccin_flavour palette

require("catppuccin").setup {
	highlight_overrides = {
		all = {
			CmpBorder = { fg = "#3e4145" },
		},
		latte = {
			Normal = { fg = ucolors.darken(latte.base, 0.7, latte.mantle) },
		},
		frappe = {
			TSConstBuiltin = { fg = frappe.peach, style = {} },
			TSConstant = { fg = frappe.sky },
			TSComment = { fg = frappe.surface2, style = { "italic" } },
		},
		macchiato = {
			LineNr = { fg = macchiato.overlay1 }
		},
		mocha = {
			Comment = { fg = mocha.flamingo },
		},
	},
}

Aditionally, if you want to load other custom highlights later, you may use this function:

require("catppuccin.lib.highlighter").syntax()

For example:

local colors = require("catppuccin.palettes").get_palette() -- fetch colors from palette
require("catppuccin.lib.highlighter").syntax({
	Comment = { fg = colors.surface0 }
})

Note: custom highlights loaded using the require("catppuccin.lib.highlighter").syntax() function won't be pre-compiled. See compile.

Overwriting colors

Colors can be overwritten using color_overrides in the setting, like so:

require("catppuccin").setup {
	color_overrides = {
		all = {
			text = "#ffffff",
		},
		latte = {
			base = "#ff0000",
			mantle = "#242424",
			crust = "#474747",
		},
		frappe = {},
		macchiato = {},
		mocha = {},
	}
}

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

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
:CatppuccinStatus " Compile status

NOTE: You have to reload setup function in order for compile to register new config. Please refer to auto compile

Catppuccin also provides these functions to work with the catppuccin compiler.

local catppuccin = require('catppuccin')

-- Create/update the compile files
catppuccin.compile()

-- Delete compiled files
catppuccin.clean()

-- Show compile status
catppuccin.status()

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

-- It's recommended to add `:CatppuccinCompile` to post-update hooks
Plug 'catppuccin/nvim', {'as': 'catppuccin', 'do': 'CatppuccinCompile'}

Auto compile

Packer.nvim

-- If you want catppuccin setup function to actually reload without restarting nvim
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, 0) -- Defered for live reloading
	end
})
-- PackerCompile on save if your config file is in plugins.lua or catppuccin.lua
-- DO NOT put the autocmd inside the plugin specification file or you will get 2 ^ x files open after x saves
vim.api.nvim_create_autocmd("BufWritePost", {
	pattern = { "plugins.lua", "catppuccin.lua" },
	callback = function()
		vim.cmd "PackerCompile"
	end
})

Vim-plug

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

Acknowledge

nightfox.nvim#compile

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 },
	}
}

Usage with :set background

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!

Old catppuccin remap function

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

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

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published