marko-cerovac/material.nvim

github github
colorschemetreesitter-colorschemes
stars 900
issues 4
subscribers 5
forks 113
CREATED

2021-03-21

UPDATED

23 hours ago


material.nvim

Neovim Lua

The original Material theme now available for NeoVim


🔱 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

    • Oceanic 2022-04-18-01:21:38-screenshot

    • Deep ocean 2022-04-18-01:21:16-screenshot

    • Palenight 2022-04-18-01:21:33-screenshot

    • Lighter 2022-04-18-01:21:28-screenshot

    • Darker 2022-04-18-01:21:22-screenshot

  • Many 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

  • Ability to select styles using telescope.nvim

  • Added functions for live theme switching without the need to restart NeoVim

  • Two Lualine themes

    • Default: default-oceanic default-darker default-deep-ocean default-palenight default-lighter

    • Stealth stealth-oceanic stealth-darker stealth-deep-ocean stealth-palenight stealth-lighter

⚡️ Requirements

  • Neovim >= 0.7.0

⚓ Installation

Install via your favourite package manager:

-- If you are using Packer
use 'marko-cerovac/material.nvim'

🐬 Usage

Enable the colorscheme:

--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:

--Lua:
vim.g.material_style = "deep ocean"

The configuration of different options is done trough a setup function

This is an example of the function with the default values

require('material').setup({

    contrast = {
        terminal = false, -- Enable contrast for the built-in terminal
        sidebars = false, -- Enable contrast for sidebar-like windows ( for example Nvim-Tree )
        floating_windows = false, -- Enable contrast for floating windows
        cursor_line = false, -- Enable darker background for the cursor line
        lsp_virtual_text = false, -- Enable contrasted background for lsp virtual text
        non_current_windows = false, -- Enable contrasted background for non-current windows
        filetypes = {}, -- Specify which filetypes get the contrasted (darker) background
    },

    styles = { -- Give comments style such as bold, italic, underline etc.
        comments = { --[[ italic = true ]] },
        strings = { --[[ bold = true ]] },
        keywords = { --[[ underline = true ]] },
        functions = { --[[ bold = true, undercurl = true ]] },
        variables = {},
        operators = {},
        types = {},
    },

    plugins = { -- Uncomment the plugins that you use to highlight them
        -- Available plugins:
        -- "dap",
        -- "dashboard",
        -- "eyeliner",
        -- "fidget",
        -- "flash",
        -- "gitsigns",
        -- "harpoon",
        -- "hop",
        -- "illuminate",
        -- "indent-blankline",
        -- "lspsaga",
        -- "mini",
        -- "neogit",
        -- "neotest",
        -- "neo-tree",
        -- "neorg",
        -- "noice",
        -- "nvim-cmp",
        -- "nvim-navic",
        -- "nvim-tree",
        -- "nvim-web-devicons",
        -- "rainbow-delimiters",
        -- "sneak",
        -- "telescope",
        -- "trouble",
        -- "which-key",
        -- "nvim-notify",
    },

    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 terminal background)
        term_colors = false, -- Prevent the theme from setting terminal colors
        eob_lines = false -- Hide the end-of-buffer lines
    },

    high_visibility = {
        lighter = false, -- Enable higher contrast text for lighter style
        darker = false -- Enable higher contrast text for darker style
    },

    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_colors = nil, -- If you want to override the default colors, set this to a function

    custom_highlights = {}, -- Overwrite highlights with your own
})

After passing the configuration to a setup function, make sure to enable the colorscheme:

vim.cmd 'colorscheme material'

This is an example of overwriting the default highlights and colors (most users will never need to do this)

local material = require 'material'
local colors = require 'material.colors'

material.setup{
    custom_highlights = {
        LineNr = { bg = '#FF0000' },
        CursorLine = { fg = colors.editor.constrast , underline = true },

        -- Dynamically override highlight groups with functions to ensure colors are
        -- updated when changing styles at runtime
        TabLine = function(colors, _)
            return {
                fg = colors.main.gray,
                italic = true,
            }
        end,
        TabLineSel = function(_, highlights)
            return vim.tbl_extend(
                "force",
                highlights.main_highlights.editor()["TabLineSel"],
                { bold = true }
            )
        end,

        -- 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 underslashed
            striketrough = false, -- make group striked trough
            reverse = false, -- reverse the fg and bg colors
            link = "SomeOtherGroup" -- link to some other highlight group
        }
    },

    -- Custom colors must be a function that takes in the default colors table as
    -- a paramter, and then modifies them.
    -- To see the available colors, see lua/material/colors/init.lua
    custom_colors = function(colors)
        colors.editor.bg = "#SOME_COLOR"
        colors.main.purple = "#SOME_COLOR"
        colors.lsp.error = "#SOME_COLOR"
    end
}

To enable transparency, it is suggested you disable the theme background from the settings above. That way, your terminal's background will be used instead.

require('material').setup({
    -- ... other settings
    disable = {
        -- ... other settings
        background = true, 
    },
})

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

  • Use Telescope.nvim to switch styles

telescope_finder

:lua require("material.functions").find_style()
  • Cycle trough styles
:lua require('material.functions').toggle_style()
  • Toggle the end of buffer lines ( ~ )
:lua require('material.functions').toggle_eob()
  • Change the style to a desired one using the function change_style("desired style")
:lua require('material.functions').change_style("palenight")