Skip to content

Commit

Permalink
feat(integration): add reactive.nvim integration (#654)
Browse files Browse the repository at this point in the history
* feat(reactive): add preset builder

* feat(reactive): add presets for every catppuccin flavour

* docs(reactive): add reactive.nvim integration info

* docs(reactive): update integration setup
  • Loading branch information
rasulomaroff authored Jan 31, 2024
1 parent c2e6f8e commit 151e478
Show file tree
Hide file tree
Showing 10 changed files with 347 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,29 @@ rainbow_delimiters = true
</tr>
<!-- rainbow-delimiters.nvim -->

<!-- reactive.nvim -->
</tr>
<tr>
<td> <a href="https://github.com/rasulomaroff/reactive.nvim">reactive.nvim</a> </td>
<td>

<details> <summary>Special</summary>

There're 2 available presets (`cursor` and `cursorline`) for every flavour.

Here is how you can use them.

```lua
require('reactive').setup {
load = { 'catppuccin-mocha-cursor', 'catppuccin-mocha-cursorline' }
}
```

To use another flavour just replace `mocha` with the one you want to use.

</details>
<!-- reactive.nvim -->

<!-- symbols-outline.nvim -->
</tr>
<tr>
Expand Down
135 changes: 135 additions & 0 deletions lua/catppuccin/utils/reactive.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
local M = {}

function M.cursor(name, palette)
return {
name = name,
init = function() vim.opt.guicursor:append "a:ReactiveCursor" end,
modes = {
i = {
hl = {
ReactiveCursor = { bg = palette.teal },
},
},
no = {
operators = {
d = {
hl = {
ReactiveCursor = { bg = palette.red },
},
},
y = {
hl = {
ReactiveCursor = { bg = palette.peach },
},
},
c = {
hl = {
ReactiveCursor = { bg = palette.blue },
},
},
},
},
R = {
hl = {
ReactiveCursor = { bg = palette.sapphire },
},
},
-- visual
[{ "v", "V", "\x16" }] = {
hl = {
ReactiveCursor = { bg = palette.mauve },
},
},
-- select
[{ "s", "S", "\x13" }] = {
hl = {
ReactiveCursor = { bg = palette.pink },
},
},
},
}
end

function M.cursorline(name, palette)
local darken = require("catppuccin.utils.colors").darken

return {
name = name,
static = {
winhl = {
inactive = {
CursorLine = { bg = darken(palette.surface0, 0.75) },
CursorLineNr = { bg = darken(palette.surface0, 0.75) },
},
},
},
modes = {
-- insert mode
i = {
winhl = {
CursorLine = { bg = darken(palette.sky, 0.3) },
CursorLineNr = { bg = darken(palette.sky, 0.3) },
},
},
-- normal mode
n = {
winhl = {
CursorLine = { bg = palette.surface0 },
CursorLineNr = { bg = palette.surface0 },
},
},
-- operator-pending mode
no = {
operators = {
[{ "gu", "gU", "g~", "~" }] = {
winhl = {
CursorLine = { bg = palette.surface2 },
CursorLineNr = { bg = palette.surface2 },
},
},
-- delete operator
d = {
winhl = {
CursorLine = { bg = darken(palette.red, 0.4) },
CursorLineNr = { bg = darken(palette.red, 0.4) },
},
},
-- yank operator
y = {
winhl = {
CursorLine = { bg = darken(palette.peach, 0.3) },
CursorLineNr = { bg = darken(palette.peach, 0.3) },
},
},
-- change operator
c = {
winhl = {
CursorLine = { bg = darken(palette.blue, 0.4) },
CursorLineNr = { bg = darken(palette.blue, 0.4) },
},
},
},
},
R = {
winhl = {
CursorLine = { bg = darken(palette.sapphire, 0.4) },
CursorLineNr = { bg = darken(palette.sapphire, 0.4) },
},
},
-- visual mode
[{ "v", "V", "\x16" }] = {
winhl = {
Visual = { bg = darken(palette.mauve, 0.4) },
},
},
-- select mode
[{ "s", "S", "\x13" }] = {
winhl = {
Visual = { bg = darken(palette.pink, 0.4) },
},
},
},
}
end

return M
4 changes: 4 additions & 0 deletions lua/reactive/presets/catppuccin-frappe-cursor.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
local palette = require("catppuccin.palettes").get_palette "frappe"
local presets = require "catppuccin.utils.reactive"

return presets.cursor("catppuccin-frappe-cursor", palette)
78 changes: 78 additions & 0 deletions lua/reactive/presets/catppuccin-frappe-cursorline.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
local darken = require("catppuccin.utils.colors").darken
local palette = require("catppuccin.palettes").get_palette "frappe"

return {
name = "catppuccin-frappe-cursorline",
static = {
winhl = {
inactive = {
CursorLine = { bg = darken(palette.surface0, 0.85) },
CursorLineNr = { bg = darken(palette.surface0, 0.85) },
},
},
},
modes = {
i = {
winhl = {
CursorLine = { bg = darken(palette.sky, 0.4) },
CursorLineNr = { bg = darken(palette.sky, 0.4) },
},
},
n = {
winhl = {
CursorLine = { bg = palette.surface0 },
CursorLineNr = { bg = palette.surface0 },
},
},
no = {
operators = {
[{ "gu", "gU", "g~", "~" }] = {
winhl = {
CursorLine = { bg = palette.surface2 },
CursorLineNr = { bg = palette.surface2 },
},
},
-- delete operator
d = {
winhl = {
CursorLine = { bg = darken(palette.red, 0.4) },
CursorLineNr = { bg = darken(palette.red, 0.4) },
},
},
-- yank operator
y = {
winhl = {
CursorLine = { bg = darken(palette.peach, 0.4) },
CursorLineNr = { bg = darken(palette.peach, 0.4) },
},
},
-- change operator
c = {
winhl = {
CursorLine = { bg = darken(palette.blue, 0.5) },
CursorLineNr = { bg = darken(palette.blue, 0.5) },
},
},
},
},
-- replace mode
R = {
winhl = {
CursorLine = { bg = darken(palette.sapphire, 0.5) },
CursorLineNr = { bg = darken(palette.sapphire, 0.5) },
},
},
-- visual mode
[{ "v", "V", "\x16" }] = {
winhl = {
Visual = { bg = darken(palette.mauve, 0.4) },
},
},
-- select mode
[{ "s", "S", "\x13" }] = {
winhl = {
Visual = { bg = darken(palette.pink, 0.4) },
},
},
},
}
8 changes: 8 additions & 0 deletions lua/reactive/presets/catppuccin-latte-cursor.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
local palette = require("catppuccin.palettes").get_palette "latte"
local presets = require "catppuccin.utils.reactive"

local preset = presets.cursor("catppuccin-latte-cursor", palette)

preset.modes.R.hl.ReactiveCursor = { bg = palette.flamingo }

return preset
77 changes: 77 additions & 0 deletions lua/reactive/presets/catppuccin-latte-cursorline.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
local lighten = require("catppuccin.utils.colors").lighten
local palette = require("catppuccin.palettes").get_palette "latte"

return {
name = "catppuccin-latte-cursorline",
static = {
winhl = {
inactive = {
CursorLine = { bg = lighten(palette.surface0, 0.5) },
CursorLineNr = { bg = lighten(palette.surface0, 0.5) },
},
},
},
modes = {
i = {
winhl = {
CursorLine = { bg = lighten(palette.teal, 0.4) },
CursorLineNr = { bg = lighten(palette.teal, 0.4) },
},
},
n = {
winhl = {
CursorLine = { bg = palette.surface0 },
CursorLineNr = { bg = palette.surface0 },
},
},
no = {
operators = {
[{ "gu", "gU", "g~", "~" }] = {
winhl = {
CursorLine = { bg = palette.surface2 },
CursorLineNr = { bg = palette.surface2 },
},
},
-- delete operator
d = {
winhl = {
CursorLine = { bg = lighten(palette.red, 0.3) },
CursorLineNr = { bg = lighten(palette.red, 0.3) },
},
},
-- yank operator
y = {
winhl = {
CursorLine = { bg = lighten(palette.peach, 0.3) },
CursorLineNr = { bg = lighten(palette.peach, 0.3) },
},
},
-- change operator
c = {
winhl = {
CursorLine = { bg = lighten(palette.blue, 0.3) },
CursorLineNr = { bg = lighten(palette.blue, 0.3) },
},
},
},
},
-- visual
[{ "v", "V", "\x16" }] = {
winhl = {
Visual = { bg = lighten(palette.mauve, 0.3) },
},
},
-- select
[{ "s", "S", "\x13" }] = {
winhl = {
Visual = { bg = lighten(palette.pink, 0.3) },
},
},
R = {
winhl = {
CursorLine = { bg = lighten(palette.flamingo, 0.2) },
CursorLineNr = { bg = lighten(palette.flamingo, 0.2) },
},
},
},
}
4 changes: 4 additions & 0 deletions lua/reactive/presets/catppuccin-macchiato-cursor.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
local palette = require("catppuccin.palettes").get_palette "macchiato"
local presets = require "catppuccin.utils.reactive"

return presets.cursor("catppuccin-macchiato-cursor", palette)
10 changes: 10 additions & 0 deletions lua/reactive/presets/catppuccin-macchiato-cursorline.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
local palette = require("catppuccin.palettes").get_palette "macchiato"
local presets = require "catppuccin.utils.reactive"
local darken = require("catppuccin.utils.colors").darken

local preset = presets.cursorline("catppuccin-macchiato-cursorline", palette)

preset.static.winhl.inactive.CursorLine = { bg = darken(palette.surface0, 0.8) }
preset.static.winhl.inactive.CursorLineNr = { bg = darken(palette.surface0, 0.8) }

return preset
4 changes: 4 additions & 0 deletions lua/reactive/presets/catppuccin-mocha-cursor.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
local palette = require("catppuccin.palettes").get_palette "mocha"
local presets = require "catppuccin.utils.reactive"

return presets.cursor("catppuccin-mocha-cursor", palette)
4 changes: 4 additions & 0 deletions lua/reactive/presets/catppuccin-mocha-cursorline.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
local palette = require("catppuccin.palettes").get_palette "mocha"
local presets = require "catppuccin.utils.reactive"

return presets.cursorline("catppuccin-mocha-cursorline", palette)

0 comments on commit 151e478

Please sign in to comment.