rebelot / kanagawa.nvim

NeoVim dark colorscheme inspired by the colors of the famous painting by Katsushika Hokusai.
MIT License
4.25k stars 180 forks source link

How to properly configure colour schemes... #192

Closed CryoViking closed 7 months ago

CryoViking commented 9 months ago

The documentation is not clear enough on how to configure the theme for neovim with reusing existing colours.

  {
    "rebelot/kanagawa.nvim",
    opts = {
      compile = false, -- enable compiling the colorscheme
      undercurl = true, -- enable undercurls
      commentStyle = { italic = true },
      functionStyle = {},
      keywordStyle = { italic = true },
      statementStyle = { bold = true },
      typeStyle = {},
      transparent = true, -- do not set background color
      dimInactive = false, -- dim inactive window `:h hl-NormalNC`
      terminalColors = true, -- define vim.g.terminal_color_{0,17}
      colors = { -- add/modify theme and palette colors
        palette = {
          matte_cyan = "#0eb8be",
        },
        theme = {
          wave = {
            syn = {
              constant = "matte_cyan", -- I'm aware this is wrong, but I can't figure out the way to reference
                                       -- my own defined colours in the palette
              special3 = "oniViolet", -- I want to use palette.oniViolet here,
            },
          },
          lotus = {},
          dragon = {},
          all = {
            ui = {
              bg_gutter = "none",
            },
          },
        },
      },
      overrides = function(colors) -- add/modify highlights
        local theme = colors.theme
        return {
          NormalFloat = { bg = "none" },
          FloatBorder = { bg = "none" },
          FloatTitle = { bg = "none" },

          -- Save an hlgroup with dark background and dimmed foreground
          -- so that you can use it where your still want darker windows.
          -- E.g.: autocmd TermOpen * setlocal winhighlight=Normal:NormalDark
          NormalDark = { fg = theme.ui.fg_dim, bg = theme.ui.bg_m3 },

          -- Popular plugins that open floats will link to NormalFloat by default;
          -- set their background accordingly if you wish to keep them dark and borderless
          LazyNormal = { bg = theme.ui.bg_m3, fg = theme.ui.fg_dim },
          MasonNormal = { bg = theme.ui.bg_m3, fg = theme.ui.fg_dim },

          TelescopeTitle = { fg = theme.ui.special, bold = true },
          TelescopePromptNormal = { bg = "none" },
          TelescopePromptBorder = { bg = "none", fg = theme.ui.bg_p1 },
          TelescopeResultsNormal = { bg = "none", fg = theme.ui.fg_dim },
          TelescopeResultsBorder = { bg = "none", fg = theme.ui.bg_m1 },
          TelescopePreviewNormal = { bg = "none" },
          TelescopePreviewBorder = { bg = "none", fg = theme.ui.bg_dim },
        }
      end,
      theme = "wave", -- Load "wave" theme when 'background' option is not set
      background = { -- map the value of 'background' option to a theme
        dark = "wave", -- try "dragon" !
        light = "lotus",
      },
    },
  },

I can't seem to pull oniViolet to override. My question becomes, do I need to do the override where I'm doing it, just in a different way, or do I need to do it in the overrides?

winter-again commented 7 months ago

I think the easiest way is to just specify the hex code for oniViolet from the README (#957fb8):

wave = {
    syn = {
        special3 = '#957fb8'
    }
}
rebelot commented 7 months ago

reference your color explicitly or assign it to a variable, palette colors can be accessed via

local palette = require'kanagawa.colors'.setup().palette
local matte_cyan =  "#0eb8be"
require'kanagawa'.setup{
   ...
}