Home

Awesome

🫖 Monokai NighTasty

<!-- panvimdoc-ignore-start -->

Pull Requests GitHub last commit GitHub issues

<!-- panvimdoc-ignore-end -->

🐧 Description

A dark/light theme for Neovim based on the Monokai color palette. This theme is born from a mix between the code of the great tokyonight.nvim and the palette of the flavorful vim-monokai-tasty.

<!-- panvimdoc-ignore-start -->

Monokai-NighTasty

<!-- panvimdoc-ignore-end -->

🌆 Features

<details> <summary>🚀 Supported plugins</summary> <!-- plugins:start -->
PluginHighlights Module
aerial.nvimaerial
aleale
alpha-nvimalpha
barbar.nvimbarbar
bufferline.nvimbufferline
dashboard-nvimdashboard
flash.nvimflash
gitsigns.nvimgitsigns
headlines.nvimheadlines
indent-blankline.nvimindent-blankline
justinmk/dirvish.vimdirvish
lazy.nvimlazy
leap.nvimleap
lspsaga.nvimlspsaga
mini.hipatternsmini_hipatterns
mini.indentscopemini_indentscope
neo-tree.nvimneo-tree
noice.nvimnoice
nvim-cmpcmp
nvim-dap-uidapui
nvim-navicnavic
nvim-notifynotify
nvim-tree.luanvim-tree
nvim-treesitter-contexttreesitter-context
rainbow-delimiters.nvimrainbow
render-markdown.nvimrender-markdown
telescope.nvimtelescope
todo-comments.nvimtodo-comments
trouble.nvimtrouble
undotreeundotree
vim-gitguttergitgutter
vim-sneaksneak
which-key.nvimwhich-key
yanky.nvimyanky
<!-- plugins:end --> </details> <!-- panvimdoc-ignore-start -->

📷 Screenshots

<details> <summary> Click to expand </summary>

🌙 Dark Theme

Dark Theme

☀️ Light Theme

Light Theme

💨 Dark Theme with transparent background:

Transparent Dark Theme

📽 Settings in action

https://github.com/polirritmico/monokai-nightasty.nvim/assets/24460484/51fb86fe-8ff8-4f90-b7fe-fbe69184a637

</details> <!-- panvimdoc-ignore-end -->

📋 Requirements

📦 Installation

Install with your package manager.

-- Lazy
{
  "polirritmico/monokai-nightasty.nvim",
  lazy = false,
  priority = 1000,
}

🛠️ Usage/Configuration

Basic usage

vim.opt.background = "dark" -- default to dark or light style

local opts = {...} -- options should be setted through a setup call:
require("monokai-nightasty").setup(opts) -- ...and then load the theme:
require("monokai-nightasty").load()

-- As an alternative, pass the options directly into load and it will run setup
-- the first time it is executed:
require("monokai-nightasty").load(opts)
:set background=dark
:colorscheme monokai-nightasty
<!-- prettier-ignore-start -->

[!TIP] 📌 TLDR: Check the Configuration examples.

<!-- prettier-ignore-end -->

💡 Toggle function

The plugin provides a toggle function to change the dark/light styles:

require("monokai-nightasty").toggle()
:MonokaiToggleLight

⚙️ Configuration details

⚠️ Set the configuration BEFORE loading the theme

Spec:

<!-- panvimdoc-ignore-start --> <details> <summary> Click to see the configuration spec </summary> <!-- panvimdoc-ignore-end --> <!-- config-spec:start -->
---@class monokai.Config
---@field dark_style_background string default, dark, transparent, #color
---@field light_style_background string default, dark, transparent, #color
---@field on_colors fun(colors: ColorScheme)
---@field on_highlights fun(highlights: monokai.Highlights, colors: ColorScheme)
---@field hl_styles table Styles to be applied to selected syntax groups
---@field color_headers boolean Enable header colors for each header level (h1, h2, etc.)
---@field dim_inactive boolean dims inactive windows
---@field lualine_bold boolean Lualine headers will be bold or regular
---@field lualine_style string Possible values: "dark", "light" or "default" (default follows dark/light style)
---@field markdown_header_marks boolean Add headers marks highlights (the `#` character) to Treesitter highlight query
---@field terminal_colors boolean|table|fun(colors: ColorScheme):table
---@field auto_enable_plugins boolean Automatically enable supported plugins through lazy.nvim
---@field plugins table<string, boolean> List of manually enabled/disabled plugins.
---@field cache boolean Enables/Disable the cache
<!-- config-spec:end --> </details>

Full defaults:

Monokai Nightasty comes with these defaults:

<!-- defaults:start -->
M.defaults = {
  dark_style_background = "default", -- default, dark, transparent, #color
  light_style_background = "default", -- default, dark, transparent, #color
  hl_styles = {
    -- Style to be applied to selected syntax groups: (See `:help nvim_set_hl` for supported keys)
    comments = { italic = true },
    keywords = { italic = false },
    functions = {},
    variables = {},
    -- Background styles for sidebars (panels) and floating windows:
    floats = "default", -- default, dark, transparent
    sidebars = "default", -- default, dark, transparent
  },

  color_headers = false, -- Enable header colors for each header level (h1, h2, etc.)
  dim_inactive = false, -- dims inactive windows
  lualine_bold = true, -- Lualine headers will be bold or regular
  lualine_style = "default", -- "dark", "light" or "default" (default follows dark/light style)
  markdown_header_marks = false, -- Add headers marks highlights (the `#` character) to Treesitter highlight query

  -- Set the colors for terminal-mode (`:h terminal-config`). `false` to disable it.
  -- Pass a table with `terminal_color_x` values: `{ terminal_color_8 = "#e6e6e6" }`.
  -- Also accepts a function:
  -- ```lua
  -- function(colors) return { fg = colors.fg_dark, terminal_color_4 = "#ff00ff" } end
  -- ```
  -- > Use the `fg` key to apply colors to the normal text.
  terminal_colors = true,

  --- You can override specific color groups to use other groups or a hex color
  --- function will be called with the Monokai ColorScheme table.
  ---@param colors ColorScheme
  on_colors = function(colors) end,

  --- You can override specific highlights to use other groups or a hex color
  --- function will be called with the Monokai Highlights and ColorScheme table.
  ---@param highlights monokai.Highlights
  ---@param colors ColorScheme
  on_highlights = function(highlights, colors) end,

  -- When `true` the theme will be cached for better performance.
  cache = true,

  --- Automatically enable highlights for supported plugins in the lazy.nvim config.
  auto_enable_plugins = true,

  --- List of manually enabled/disabled plugins.
  --- Check the supported plugins here:
  ---   https://github.com/polirritmico/monokai-nightasty.nvim/tree/main/lua/monokai-nightasty/highlights
  ---@type table<string, boolean>
  plugins = {
    -- Use the ["<repository name>"]. For example:
    -- ["telescope.nvim"] = true,

    -- `all`: enable or disable all plugins. By default if lazy.nvim is not loaded enable all the plugins
    all = package.loaded.lazy == nil,
  },
}
<!-- defaults:end -->

📐 Configuration examples

Base configuration with a bit of customization:

<!-- panvimdoc-ignore-start --> <details> <summary> Click to see the example </summary> <!-- panvimdoc-ignore-end -->
{
  "polirritmico/monokai-nightasty.nvim",
  lazy = false,
  priority = 1000,
  keys = {
    { "<leader>tt", "<Cmd>MonokaiToggleLight<CR>", desc = "Monokai-Nightasty: Toggle dark/light theme." },
  },
  ---@type monokai.UserConfig
  opts = {
    dark_style_background = "default",
    light_style_background = "default",
    markdown_header_marks = true,
    -- hl_styles = { comments = { italic = false } },
    terminal_colors = function(colors) return { fg = colors.fg_dark } end,
  },
  config = function(_, opts)
    vim.opt.cursorline = true -- Highlight line at the cursor position
    vim.o.background = "dark" -- Default to dark theme

    require("monokai-nightasty").load(opts)
  end,
}
</details>

Full configuration:

<!-- panvimdoc-ignore-start --> <details> <summary> Click to see the example </summary> <!-- panvimdoc-ignore-end -->
return {
  "polirritmico/monokai-nightasty.nvim",
  lazy = false,
  priority = 1000,
  keys = {
    { "<leader>tt", "<Cmd>MonokaiToggleLight<CR>", desc = "Monokai-Nightasty: Toggle dark/light theme." },
  },
  ---@type monokai.UserConfig
  opts = {
    dark_style_background = "transparent", -- default, dark, transparent, #color
    light_style_background = "default", -- default, dark, transparent, #color
    color_headers = true, -- Enable header colors for each header level (h1, h2, etc.)
    lualine_bold = true, -- Lualine a and z sections font width
    lualine_style = "default", -- "dark", "light" or "default" (Follows dark/light style)
    markdown_header_marks = true, -- Add headers marks highlights (the `#` character) to Treesitter highlight query
    -- Style to be applied to different syntax groups. See `:help nvim_set_hl`
    hl_styles = {
      keywords = { italic = true },
      comments = { italic = true },
    },

    -- This also could be a table like this: `terminal_colors = { Normal = { fg = "#e6e6e6" } }`
    terminal_colors = function(colors)
      return { fg = colors.fg_dark }
    end,

    --- You can override specific color/highlights. Theme color values
    --- in `extras/palettes`. Also could be any hex RGB color you like.
    on_colors = function(colors)
      -- Custom color only for light theme
      local current_is_light = vim.o.background == "light"
      colors.comment = current_is_light and "#2d7e79" or colors.grey

      -- Custom color only for dark theme
      colors.border = not current_is_light and colors.magenta or colors.border

      -- Custom lualine normal color
      colors.lualine.normal_bg = current_is_light and "#7ebd00" or colors.green
    end,

    on_highlights = function(highlights, colors)
      -- You could add styles like bold, underline, italic
      highlights.TelescopeSelection = { bold = true }
      highlights.TelescopeBorder = { fg = colors.grey }
      highlights["@lsp.type.property.lua"] = { fg = colors.fg }
    end,
  },
  config = function(_, opts)
    -- Highlight line at the cursor position
    vim.opt.cursorline = true

    -- Default to dark theme
    vim.o.background = "dark"  -- dark | light

    -- Open new Nvim instances with the light theme when the sun hits the screen
    local date_output = vim.api.nvim_exec2("!date +'\\%H\\%M'", { output = true })
    local system_time = tonumber(string.match(date_output["output"], "%d%d%d%d"))
    if system_time >= 1345 and system_time < 1630 then
      vim.o.background = "light"
    end

    require("monokai-nightasty").load(opts)
  end,
}
</details>

🍚 Customization: Change a color/style:

There are two main options: change the color definition or the specific highlight.

Change a color definition:

Simple use the on_colors option:

opts = {
  on_colors = function(colors)
    colors.charcoal_medium = "#455455"
  end
}

This would be applied before the highlights generation.

Change a specific highlight:

Simple use the on_highlights option:

opts = {
  on_highlights(hl, c)
    hl["Folded"] = { fg = c.orange, bg = c.bg_float, italic = false },
    hl["LineNr"] = { fg = c.grey },
  end,
}

To get the highlight name, move the cursor over it and run :Inspect.

Independent light/dark theme customization:

<!-- panvimdoc-ignore-start --> <details> <summary> Set colors for each theme using boolean logic: </summary> <!-- panvimdoc-ignore-end -->
{
  on_colors = function(colors)
    local is_light = vim.o.background == "light"
    colors.comment = is_light and "#2d7e79" or colors.grey
    colors.border = not is_light and colors.magenta or colors.border

    if is_light then
      colors.orange = "#f59263",
    end
  end,

  on_highlights = function(highlights, colors)
    local is_light = vim.o.background == "light"

    highlights["@variable.member.lua"] = {
      fg = is_light and colors.magenta or colors.grey,
      underline = is_light,
    },
  end,
}
</details>

🔍 Colors and Highlights

How the plugin setup the highlights and colors under the hood:

  1. colors are loaded from the base palette based on the current vim.o.background value ("dark"/"light").

  2. Then, colors is extended and adjusted following the configuration settings.

  3. After that, opts.on_colors(colors) is called, overriding any matching color.

  4. The highlight groups are set using the generated colors.

  5. opts.on_highlights(highlights, colors) can be used to override highlight groups.

If opts.cache is true and the current configuration has no changes, jump straight to step 5 to apply the on_highlights function.

To get the name of a highlight group or to find the used color, here are some alternatives:

  1. Use :Inspect to get info of the highlight group at the current position.
  2. Check the generated palettes in the extras.
  3. For plugins specifics check each module in the highlights directory.

🧩 Extras

Currently this extra files are generated:

<!-- extras:start --> <!-- extras:end -->

The Monokai Nightasty Palette is a file with the used colors and highlights.

To use the generated config files with the corresponding external tool, check the extras folder, copy, link or reference the file in each setting. Refer to the respective program documentation.

Markdown files

Nvim Tressiter no longer provide highlight captures for the headers # marks. This plugin will provide them for as long as they work, or until nvim-treesitter provides any way to highlight them.

To enable this feature, set the markdown_header_marks option to true (defaults to false).

<!-- panvimdoc-ignore-start -->
DisabledEnabled
Disabled TS custom queryEnabled TS custom query
<!-- panvimdoc-ignore-end -->

Tmux

<!-- panvimdoc-ignore-start --> <details> <summary> Config details </summary> <!-- panvimdoc-ignore-end -->

Just source the theme file:

source-file 'path/to/monokai-nightasty_dark.tmux'

Fix undercurls in Tmux

If the undercurls or colors are not being properly displayed within Tmux, add the following to your config file:

# Undercurl
set -as terminal-features ",xterm-256color:RGB" # or: set -g default-terminal "${TERM}"
set -as terminal-overrides ',*:Smulx=\E[4::%p1%dm'  # undercurl support
set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m'  # underscore colours - needs tmux-3.0
</details>

🔌 Using with other plugins

You could import the color palette to use with other plugins:

local opts = require("monokai-nightasty.config").extend()
local colors = require("monokai-nightasty.colors").setup(opts)

some_plugin_config.title = colors.blue
example_plugin_config = {
  foo = colors.bg_dark,
  bar = colors.green,
  buz = opts.transparent and colors.none or colors.bg
}

Some color utility functions are available for use:

local opts = require("monokai-nightasty.config").extend()
local colors = require("monokai-nightasty.colors").setup(opts)
local utils = require("monokai-nightasty.utils")

some_plugin_config.example = utils.lighten(colors.bg, 0.5)
some_plugin_config.another = utils.darken(colors.bg, 0.3)

🎨 Color Palettes

🌃 Dark Style

<!-- panvimdoc-ignore-start -->
Color nameHex codeRender
Yellow#ffff87#ffff87
Purple#af87ff#af87ff
Green#a4e400#a4e400
Blue#62d8f1#62d8f1
Magenta#fc1a70#fc1a70
Orange#ff9700#ff9700
<!-- panvimdoc-ignore-end --> <!-- panvimdoc-include-comment | Color name | Hex code | |------------|-----------| | Yellow | `#ffff87` | | Purple | `#af87ff` | | Green | `#a4e400` | | Blue | `#62d8f1` | | Magenta | `#fc1a70` | | Orange | `#ff9700` | -->

🏙️ Light Style

<!-- panvimdoc-ignore-start -->
Color nameHex codeRender
Yellow#ff8f00#ff8f00
Purple#6054d0#6054d0
Green#4fb000#4fb000
Blue#00b3e3#00b3e3
Magenta#ff004b#ff004b
Orange#ff4d00#ff4d00
<!-- panvimdoc-ignore-end --> <!-- panvimdoc-include-comment | Color name | Hex code | |------------|-----------| | Yellow | `#ff8f00` | | Purple | `#6054d0` | | Green | `#4fb000` | | Blue | `#00b3e3` | | Magenta | `#ff004b` | | Orange | `#ff4d00` | -->

🌱 Contributions

This plugin is made mainly for my personal use, but suggestions, issues, or pull requests are very welcome.

Enjoy