Skip to content

Commit 40b1732

Browse files
authored
breaking: colorbuddy 2.0 (tjdevries#38)
Update to better version :) Sorry if this broke anything for you, just use tag 1.0.0 :)
1 parent cdb5b06 commit 40b1732

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1313
-2099
lines changed

BREAKING.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Breaking Changes
2+
3+
### v2
4+
5+
These are the following breaking changes moving from previous version
6+
into the new v2 branch. If I have to make bad breaking changes again in
7+
the future, then we'll move to `v3` i guess
8+
9+
- now requires latest neovim 0.8 (as of august 17)
10+
- now uses "@<group>" names primarily
11+
12+
- Color.new
13+
- Now only accepts string `#RRGGBB` OR `ColorbuddyHSL` OR `ColorbuddyRGB`
14+
- Old usages of `Color.new("name", "#ffffff")` will still work (which was as many as I could find)
15+
- Color:new_child
16+
- If you were using this (not thinking anyone actually was though, it wasn't really required)
17+
then you need to now pass modifiers as a table.
18+
19+

README.md

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
# colorbuddy.nvim
22

3+
NOTE: now requires neovim 0.9 or nightly
4+
35
A colorscheme helper for Neovim.
46

57
Written in Lua! Quick & Easy Color Schemes :smile:
68

79
Sincerely, your color buddy.
810

11+
12+
# Basic Usage
13+
14+
```lua
15+
vim.cmd.colorscheme("colorbuddy")
16+
-- or
17+
vim.cmd.colorscheme("gruvbuddy")
18+
```
19+
920
## Example
1021

1122
Your color buddy for making cool neovim color schemes. Write your colorscheme in lua!
@@ -15,7 +26,19 @@ You can see one example for gruvbox-esque styles [here](https://github.com/tjdev
1526
Example:
1627

1728
```lua
18-
local Color, colors, Group, groups, styles = require('colorbuddy').setup()
29+
-- file: colors/my-colorscheme-name.lua
30+
31+
local colorbuddy = require('colorbuddy')
32+
33+
-- Set up your custom colorscheme if you want
34+
colorbuddy.colorscheme("my-colorscheme-name")
35+
36+
-- And then modify as you like
37+
local Color = colorbuddy.Color
38+
local colors = colorbuddy.colors
39+
local Group = colorbuddy.Group
40+
local groups = colorbuddy.groups
41+
local styles = colorbuddy.styles
1942

2043
-- Use Color.new(<name>, <#rrggbb>) to create new colors
2144
-- They can be accessed through colors.<name>
@@ -30,15 +53,6 @@ Group.new('luaFunctionCall' , groups.Function , groups.Function , groups.Fu
3053

3154
-- Define highlights in relative terms of other colors
3255
Group.new('Error' , colors.red:light() , nil , s.bold)
33-
```
34-
35-
36-
### Advanced Examples
37-
38-
```lua
39-
-- Optionally, you can just use the globals created when calling `setup()`
40-
-- No need to declare new locals
41-
require('colorbuddy').setup()
4256

4357
-- If you want multiple styles, just add them!
4458
Group.new('italicBoldFunction', colors.green, groups.Function, styles.bold + styles.italic)

colors/colorbuddy.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require("colorbuddy").colorscheme("colorbuddy")

colors/gruvbuddy.lua

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
require("colorbuddy").colorscheme("gruvbuddy")
2+
3+
local colorbuddy = require("colorbuddy")
4+
local Color = colorbuddy.Color
5+
local Group = colorbuddy.Group
6+
local c = colorbuddy.colors
7+
local g = colorbuddy.groups
8+
local s = colorbuddy.styles
9+
10+
Color.new("white", "#f2e5bc")
11+
Color.new("red", "#cc6666")
12+
Color.new("pink", "#fef601")
13+
Color.new("green", "#99cc99")
14+
Color.new("yellow", "#f8fe7a")
15+
Color.new("blue", "#81a2be")
16+
Color.new("aqua", "#8ec07c")
17+
Color.new("cyan", "#8abeb7")
18+
Color.new("purple", "#8e6fbd")
19+
Color.new("violet", "#b294bb")
20+
Color.new("orange", "#de935f")
21+
Color.new("brown", "#a3685a")
22+
23+
Color.new("seagreen", "#698b69")
24+
Color.new("turquoise", "#698b69")
25+
26+
local background_string = "#111111"
27+
Color.new("background", background_string)
28+
Color.new("gray0", background_string)
29+
30+
Group.new("Normal", c.superwhite, c.gray0)
31+
32+
Group.new("@constant", c.orange, nil, s.none)
33+
Group.new("@function", c.yellow, nil, s.none)
34+
Group.new("@function.bracket", g.Normal, g.Normal)
35+
Group.new("@keyword", c.violet, nil, s.none)
36+
Group.new("@keyword.faded", g.nontext.fg:light(), nil, s.none)
37+
Group.new("@property", c.blue)
38+
Group.new("@variable", c.superwhite, nil)
39+
Group.new("@variable.builtin", c.purple:light():light(), g.Normal)
40+
41+
-- I've always liked lua function calls to be blue. I don't know why.
42+
Group.new("@function.call.lua", c.blue:dark(), nil, nil)

example/colorscheme.lua

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
1+
if true then
2+
return
3+
end
14

2-
local Color = require('colorbuddy.init').Color
3-
local colors = require('colorbuddy.init').colors
5+
local Color = require("colorbuddy.init").Color
6+
local colors = require("colorbuddy.init").colors
47

5-
local Group = require('colorbuddy.init').Group
6-
local groups = require('colorbuddy.init').groups
8+
local Group = require("colorbuddy.init").Group
9+
local groups = require("colorbuddy.init").groups
710

8-
local styles = require('colorbuddy.init').styles
11+
local styles = require("colorbuddy.init").styles
912

10-
Color.new('red', '#cc6666')
11-
Color.new('green', '#99cc99')
12-
Color.new('yellow', '#f0c674')
13-
Color.new('background', '#1d1f21')
13+
Color.new("red", "#cc6666")
14+
Color.new("green", "#99cc99")
15+
Color.new("yellow", "#f0c674")
16+
Color.new("background", "#1d1f21")
1417

15-
Group.new('Function', colors.yellow, colors.background, styles.bold)
16-
Group.new('mFunction', groups.Function, groups.Function, groups.Function)
18+
Group.new("Function", colors.yellow, colors.background, styles.bold)
19+
Group.new("mFunction", groups.Function, groups.Function, groups.Function)
1720

1821
-- If you want multiple styles, just add them!
19-
Group.new('italicBoldFunction', groups.Function, colors.background, styles.bold + styles.italic)
22+
Group.new("italicBoldFunction", groups.Function, colors.background, styles.bold + styles.italic)
2023

2124
-- If you want the same style as a different group, but without a style
2225
-- just subtract it!
23-
Group.new('boldFunction', colors.yellow, colors.yellow, groups.italicBoldFunction - styles.italic)
26+
Group.new("boldFunction", colors.yellow, colors.yellow, groups.italicBoldFunction - styles.italic)

lua/colorbuddy/actions.lua

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
1-
local _c = require("colorbuddy.color")
2-
local Color = require("colorbuddy.color").Color
31
local colors = require("colorbuddy.color").colors
42

5-
local log = require("colorbuddy.log")
6-
73
local actions = {}
84

9-
actions.lighter = function()
5+
local global_apply = function(modifier)
106
local updated = {}
117

128
for _, c in pairs(colors) do
139
if not updated[c] then
14-
updated = Color.modifier_apply(c, "light")
10+
-- Get to the root of all the nodes
11+
local val = c
12+
while val.parent do
13+
val = val.parent
14+
end
15+
16+
if not updated[val] then
17+
vim.tbl_extend("force", updated, val:modifier_apply({ modifier }, updated))
18+
end
19+
20+
assert(updated[c], "must have encountered color at some point")
1521
end
1622
end
1723
end
1824

19-
actions.darker = function()
20-
local updated = {}
25+
actions.lighter = function()
26+
global_apply("light")
27+
end
2128

22-
for _, c in pairs(colors) do
23-
if not updated[c] then
24-
updated = Color.modifier_apply(c, "dark")
25-
end
26-
end
29+
actions.darker = function()
30+
global_apply("dark")
2731
end
2832

29-
return {
30-
actions = actions,
31-
}
33+
return actions

0 commit comments

Comments
 (0)