Custom Colorscheme
Using a Custom Colorscheme
There are only 2 simple steps to change colorscheme of your editor:
- Add a plugin
- Specify colorscheme
Step 1 - Adding a plugin
You can either add a colorscheme plugin directly to your plugins
as described in the Custom Plugins Page, for example if you wanted to add Catppuccin you would add the following to your plugins
:
{
"catppuccin/nvim",
name = "catppuccin",
opts = {
-- configuration options...
},
}
Or you can install it using AstroCommunity. Navigate to the folder listing the available community colorscheme plugins and pick a colorscheme that you would like to install. Then make sure you have add the AstroCommunity repository to your plugins
and then insert the necessary import
statement as described in the AstroCommunity documentation. For example to add Catppuccin, you would add the following to your plugins
:
"AstroNvim/astrocommunity",
{ import = "astrocommunity.colorscheme.catppuccin" }
Step 2 - Specifying colorscheme
Open your user/init.lua
(usually it’s ~/.config/nvim/lua/user/init.lua
), find the line where colorsheme
property is being set:
colorscheme = "astrodark"
Then change it to the name of the theme you’ve installed in the step 1:
colorscheme = "catppuccin"
Using a Custom Colorscheme Configured with Global Variables
Some colorscheme plugins are configured through global variables rather than Lua functions like setup()
so they require a slightly different setup to get them working correctly. For example if we want to use Sonokai:
return {
colorscheme = "sonokai",
plugins = {
{
"sainnhe/sonokai",
init = function() -- init function runs before the plugin is loaded
vim.g.sonokai_style = "shusia"
end,
},
},
}