Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to access the current palette of a colorscheme. #369

Open
WayneNoschang opened this issue Nov 24, 2024 · 0 comments
Open

How to access the current palette of a colorscheme. #369

WayneNoschang opened this issue Nov 24, 2024 · 0 comments

Comments

@WayneNoschang
Copy link

Some Neovim colorscheme plugins provide a way to require and use the currently used theme colors for use with other plugins. For example, a helper in onedarkpro.nvim theme.

Is there an API that I'm overlooking in the docs that allows me to do this?

The closest thing I can find is require("github-theme.palette") mentioned in the Color lib section of the READ.me. However, this will provide all palette styles or a specified one.

I want to be able to create a lualine theme by using the current theme's palette.

Below is an example using olimorris/onedarkpro.nvim to create a new lualine theme located in lua/lualine/theme/theme_name.lua.

-- https://github.com/nvim-lualine/lualine.nvim/wiki/Writing-a-theme
-- https://github.com/olimorris/onedarkpro.nvim/blob/main/lua/lualine/themes/onedark.lua

local colors = require("onedarkpro.helpers").get_colors()

local onedarkpro = {}

onedarkpro.normal = {
  a = { fg = colors.fg },
  b = { fg = colors.fg },
  c = { fg = colors.fg },
  x = { fg = colors.fg },
  y = { fg = colors.fg },
  z = { fg = colors.fg },
}

onedarkpro.insert = {
  a = { fg = colors.fg },
  b = { fg = colors.fg },
  c = { fg = colors.fg },
}

onedarkpro.command = {
  a = { fg = colors.fg },
  b = { fg = colors.fg },
  c = { fg = colors.fg },
}

return onedarkpro
@WayneNoschang WayneNoschang changed the title How to access current theme style colors. How to access the current palette of a colorscheme. Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant