π± Info
A port of Material colorscheme for NeoVim written in Lua
Material.nvim is meant to be a fast and modern colorscheme written in Lua that supports a lot of the new features added to NeoVim like built-in LSP and TreeSitter
π Features
-
5 styles to choose from
-
Supported plugins:
-
Ability to change background on sidebar-like windows like Nvim-Tree, Packer, terminal etc.
-
Asynchronous highlight loading which makes the theme blazingly fast
-
Added functions for live theme switching without the need to restart NeoVim
-
Two Lualine themes
β‘οΈ Requirements
- Neovim >= 0.7.0
β Installation
Install via your favourite package manager:
" If you are using Vim-Plug
Plug 'marko-cerovac/material.nvim'
-- If you are using Packer
use 'marko-cerovac/material.nvim'
π¬ Usage
Enable the colorscheme:
"Vim-Script:
colorscheme material
--Lua:
vim.cmd 'colorscheme material'
For a comlete guide on usage and configuration of the theme, see :help material.nvim
.
βοΈ Configuration
- There are 5 different styles available:
- darker
- lighter
- oceanic
- palenight
- deep ocean
Set the desired style using:
"Vim-Script:
let g:material_style = "darker"
--Lua:
vim.g.material_style = "deep ocean"
The configuration of different options is done trough a setup function
lua << EOF
require('material').setup()
EOF
This is an example of the function with the default values
require('material').setup({
contrast = {
sidebars = false, -- Enable contrast for sidebar-like windows ( for example Nvim-Tree )
floating_windows = false, -- Enable contrast for floating windows
line_numbers = false, -- Enable contrast background for line numbers
sign_column = false, -- Enable contrast background for the sign column
cursor_line = false, -- Enable darker background for the cursor line
non_current_windows = false, -- Enable darker background for non-current windows
popup_menu = false, -- Enable lighter background for the popup menu
},
italics = {
comments = false, -- Enable italic comments
keywords = false, -- Enable italic keywords
functions = false, -- Enable italic functions
strings = false, -- Enable italic strings
variables = false -- Enable italic variables
},
contrast_filetypes = { -- Specify which filetypes get the contrasted (darker) background
"terminal", -- Darker terminal background
"packer", -- Darker packer background
"qf" -- Darker qf list background
},
high_visibility = {
lighter = false, -- Enable higher contrast text for lighter style
darker = false -- Enable higher contrast text for darker style
},
disable = {
colored_cursor = false, -- Disable the colored cursor
borders = false, -- Disable borders between verticaly split windows
background = false, -- Prevent the theme from setting the background (NeoVim then uses your teminal background)
term_colors = false, -- Prevent the theme from setting terminal colors
eob_lines = false -- Hide the end-of-buffer lines
},
lualine_style = "default", -- Lualine style ( can be 'stealth' or 'default' )
async_loading = true, -- Load parts of the theme asyncronously for faster startup (turned on by default)
custom_highlights = {}, -- Overwrite highlights with your own
plugins = { -- Here, you can disable(set to false) plugins that you don't use or don't want to apply the theme to
trouble = true,
nvim_cmp = true,
neogit = true,
gitsigns = true,
git_gutter = true,
telescope = true,
nvim_tree = true,
sidebar_nvim = true,
lsp_saga = true,
nvim_dap = true,
nvim_navic = true,
which_key = true,
sneak = true,
hop = true,
indent_blankline = true,
nvim_illuminate = true,
mini = true,
}
})
After passing the configuration to a setup function, make sure to enable the colorscheme:
colorscheme material
vim.cmd 'colorscheme material'
This is an example of overwriting the default highlights (most users will never need to do this)
require('material').setup{
custom_highlights = {
LineNr = { bg = '#FF0000' }
CursorLine = { fg = '#0000FF', underline = true },
-- This is a list of possible values
YourHighlightGroup = {
fg = "#SOME_COLOR", -- foreground color
bg = "#SOME_COLOR", -- background color
sp = "#SOME_COLOR", -- special color (for colored underlines, undercurls...)
bold = false, -- make group bold
italic = false, -- make group italic
underline = false, -- make group underlined
undercurl = false, -- make group undercurled
underdot = false, -- make group underdotted
underdash = false -- make group underdotted
striketrough = false, -- make group striked trough
reverse = false, -- reverse the fg and bg colors
link = "SomeOtherGroup" -- link to some other highlight group
}
}
}
To enable the lualine themes, first set the theme in your lualine settings to auto
or material
require('lualine').setup {
options = {
-- ... your lualine config
theme = 'auto'
or
theme = 'material'
-- ... your lualine config
}
}
Then, choose the style trough a variable called lualine_style
in the theme setup function
require('material').setup({
lualine_style = 'default' -- the default style
or
lualine_style = 'stealth' -- the stealth style
})
If the theme, doesn't look right, it's probably because material.nvim is being loaded before lualine, causing the other material theme that comes built-in to lualine to be used. To fix this, either load material.nvim after lualine (preferred way) or set the lualine theme to one of these two values in your lualine settings
require('lualine').setup {
options = {
-- ... your lualine config
theme = 'material-nvim' -- the default style
or
theme = 'material-stealth' -- the stealth style
-- ... your lualine config
}
}
β΅ Functions
- Toggle the style live without the need to exit NeoVim
Just call the function for style switching
"Vim-Script
:lua require('material.functions').toggle_style()
"This command toggles the style
The command can also be mapped to a key for fast style switching
"Vim-Script:
nnoremap <leader>mm :lua require('material.functions').toggle_style()<CR>
--Lua:
vim.api.nvim_set_keymap('n', '<leader>mm', [[<Cmd>lua require('material.functions').toggle_style()<CR>]], { noremap = true, silent = true })
- Toggle the end of buffer lines ( ~ )
Call the built in function for toggling buffer lines
"Vim-Script
:lua require('material.functions').toggle_eob()
"This command toggles the end of buffer lines
The command can also be mapped to a key to toggle the lines live
"Vim-Script:
nnoremap <leader>me :lua require('material.functions').toggle_eob()<CR>
--Lua:
vim.api.nvim_set_keymap('n', '<leader>me', [[<Cmd>lua require('material.functions').toggle_eob()<CR>]], { noremap = true, silent = true })
- Change the style to a desired one using the function change_style("desired style")
"Vim-Script:
:lua require('material.functions').change_style("palenight")
"This command changes the style to palenight
The command can also be mapped to a key for fast style switching
"Vim-Script:
nnoremap <leader>ml :lua require('material.functions').change_style('lighter')<CR>
nnoremap <leader>md :lua require('material.functions').change_style('darker')<CR>
--Lua:
vim.api.nvim_set_keymap('n', '<leader>ml', [[<Cmd>lua require('material.functions').change_style('lighter')<CR>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>md', [[<Cmd>lua require('material.functions').change_style('darker')<CR>]], { noremap = true, silent = true })