Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
Merge pull request #91 from yioneko/custom
Browse files Browse the repository at this point in the history
feat: allow customizing highlight group
  • Loading branch information
ful1e5 authored Dec 22, 2021
2 parents e9fb6d2 + e7300ac commit b7201d3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ require('lualine').setup {
| keyword_style | `italic` | Highlight style for keywords (check `:help highlight-args` for options) |
| lualine_bold | `false` | When `true`, section headers in the lualine theme will be bold |
| msg_area_style | `NONE` | Highlight style for messages and cmdline (check `:help highlight-args` for options) |
| overrides | `function` | Override specific highlight groups. The function accpet colors as argument. |
| sidebars | `{}` | Set a darker background on sidebar-like windows. For example: `{"qf", "vista_kind", "terminal", "packer"}` |
| transparent | `false` | Enable this to disable setting the background color |
| transparent_sidebar | `false` | Sidebar like windows like `NvimTree` get a transparent background |
Expand Down Expand Up @@ -148,7 +149,16 @@ require("onedark").setup({
sidebars = {"qf", "vista_kind", "terminal", "packer"},

-- Change the "hint" color to the "orange" color, and make the "error" color bright red
colors = {hint = "orange", error = "#ff0000"}
colors = {hint = "orange", error = "#ff0000"},
-- Overwrite the highlight groups
overrides = function(c)
return {
htmlTag = {fg = c.red, bg = "#282c34", sp = c.hint, style = "underline"},
DiagnosticHint = {link = "LspDiagnosticsDefaultHint"},
-- this will remove the highlight groups
TSField = {},
}
end
})
```

Expand Down
1 change: 1 addition & 0 deletions lua/onedark/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ local config = {
keyword_style = opt("keyword_style", "italic"),
lualine_bold = opt("lualine_bold", false),
msg_area_style = opt("msg_area_style", "NONE"),
overrides = opt("overrides", function() return {} end),
sidebars = opt("sidebars", {}),
transform_colors = false,
transparent = opt("transparent", false),
Expand Down
13 changes: 13 additions & 0 deletions lua/onedark/theme.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ local config_module = require("onedark.config")

local M = {}

local function apply_overrides(group, overrides)
for k, v in pairs(overrides) do
if group[k] ~= nil and type(v) == "table" then
group[k] = v
end
end
end

---@param config onedark.Config
---@return onedark.Theme
function M.setup(config)
Expand Down Expand Up @@ -588,6 +596,11 @@ function M.setup(config)

theme.defer = {}

local overrides = config.overrides(c)
apply_overrides(theme.base, overrides)
apply_overrides(theme.plugins, overrides)
apply_overrides(theme.defer, overrides)

if config.hide_inactive_statusline then

-- StatusLine
Expand Down
4 changes: 4 additions & 0 deletions lua/onedark/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ end

-- local ns = vim.api.nvim_create_namespace("onedark")
function util.highlight(group, color)
if not (color.fg or color.bg or color.sp or color.style or color.link) then
return
end

if color.fg then util.colorsUsed[color.fg] = true end
if color.bg then util.colorsUsed[color.bg] = true end
if color.sp then util.colorsUsed[color.sp] = true end
Expand Down

0 comments on commit b7201d3

Please sign in to comment.