Skip to content

Commit

Permalink
Feat: Add after_palette to override extended palette values (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
5-pebbles authored Jun 3, 2024
1 parent c2c0eaf commit 96d0989
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@ Nordic will use the default values, unless `setup` is called. Below is the defau

```lua
require('nordic').setup({
-- This callback can be used to override the colors used in the palette.
-- This callback can be used to override the colors used in the base palette.
on_palette = function(palette) end,
-- This callback can be used to override the colors used in the extended palette.
after_palette = function(palette) end,
-- This callback can be used to override highlights before they are applied.
on_highlight = function(highlights, palette) end,
-- Enable bold keywords.
Expand Down Expand Up @@ -156,6 +158,23 @@ require('nordic').setup({
</details>


<details>
<summary><b><code>after_palette</code></b></summary>
&nbsp;

An example of setting the visual selection color (for more values see [this file](https://github.com/AlexvZyl/nordic.nvim/blob/main/lua/nordic/colors/init.lua)):
```lua
require('nordic').setup({
after_palette = function(palette)
local U = require("nordic.utils")
palette.bg_visual = U.blend(palette.orange.base, palette.bg, 0.15)
end,
})
```

</details>


<details>
<summary><b><code>on_highlight</code></b></summary>
&nbsp;
Expand Down
3 changes: 3 additions & 0 deletions lua/nordic/colors/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ function C.build_palette()

-- Misc
C.comment = C.gray4

-- Modify the palette after generating colors.
options.after_palette(C)
end

-- Build the first palette.
Expand Down
4 changes: 3 additions & 1 deletion lua/nordic/config.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
local M = {}

local defaults = {
-- This callback can be used to override the colors used in the palette.
-- This callback can be used to override the colors used in the base palette.
on_palette = function(palette) end,
-- This callback can be used to override the colors used in the extended palette.
after_palette = function(palette) end,
-- This callback can be used to override highlights before they are applied.
on_highlight = function(highlights, palette) end,
-- Enable bold keywords.
Expand Down
6 changes: 6 additions & 0 deletions lua/nordic/tests/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ config.on_palette = function(palette)
palette.black0 = '#000000'
end

config.after_palette = function(palette)
local U = require("nordic.utils")
palette.bg_visual = U.blend(palette.orange.base, palette.bg, 0.15)
end


config.on_highlight = function(highlights, palette)
highlights.TelescopePromptTitle = {
fg = palette.red.bright,
Expand Down

0 comments on commit 96d0989

Please sign in to comment.