Skip to content

Commit

Permalink
Expand on_highlights example in README
Browse files Browse the repository at this point in the history
The examples that were in there previously didn't contain very
constructive information. This should clarify what one is changing and
what else one needs to do to achieve the same.
  • Loading branch information
neanias committed Dec 21, 2023
1 parent 2bceb39 commit a1d1e27
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,22 +173,40 @@ the undercurl:

```lua
require("everforest").setup({
on_highlights = function (hl, palette)
on_highlights = function(hl, palette)
hl.DiagnosticError = { fg = palette.none, bg = palette.none, sp = palette.red }
hl.DiagnosticWarn = { fg = palette.none, bg = palette.none, sp = palette.yellow }
hl.DiagnosticInfo = { fg = palette.none, bg = palette.none, sp = palette.blue }
hl.DiagnosticHint = { fg = palette.none, bg = palette.none, sp = palette.green }
end
end,
})
```

If you want to tweak or amend an existing highlight group you **need to add the
colours that aren't changing as well as your new styles**. This is because the
highlights defined in the `on_highlights` method will _override_ the default
highlights.

Here's an example of adding a **bold** styling to the `Boolean` highlight group:

```lua
require("everforest").setup({
on_highlights = function(hl, palette)
-- The default highlights for Boolean is fg purple, bg none. If we want to
-- just add a bold to the existing, we need to have the existing *and* the
-- bold style.
hl.Boolean = { fg = palette.purple, bg = palette.none, bold = true }
end,
})
```

To clear any highlight groups, simply set them to `{}`:

```lua
require("everforest").setup({
on_highlights = function (hl, palette)
on_highlights = function(hl, palette)
hl.TSDanger = {}
end
end,
})
```

Expand Down

0 comments on commit a1d1e27

Please sign in to comment.