Skip to content

Commit 9d9f7ac

Browse files
committed
feat: add global option bones_no_cache to disable cache
1 parent 3927fd7 commit 9d9f7ac

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

doc/zenbones.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,19 @@ the flavor name e.g. `g:rosebones_italic_comments`.
8585
| lighten_cursor_line | dark | `4` | Percentage to lighten \|hl-CursorLine\| relative to Normal bg. |
8686
| colorize_diagnostic_underline_text | both | `false` | Colorize the fg of `DiagnosticUnderline*`. |
8787
| transparent_background | both | `false` | Make background transparent. |
88-
| no_cache | both | `false` | Disable caching for the current colorscheme. |
8988

9089
#### g:bones_compat
9190

9291
Set to `1` to enable compatibility mode for all colorschemes. Enabled in Vim. To
9392
enable/disable compatibility mode for a specific theme, set the variable
9493
`g:{theme}_compat` to `0` or `1`, e.g. `let g:zenbones_compat = 1`.
9594

95+
#### g:bones_no_cache
96+
97+
Set to `true` to disable caching for all colorschemes. Only valid for Neovim.
98+
To enable/disable caching for a specific theme, set the variable
99+
`g:{theme}_no_cache` to `true`, e.g. `vim.g.zenbones_no_cache = true`.
100+
96101
### lightline
97102

98103
```vim

lua/zenbones/specs/init.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ function M.get_global_config(prefix, base_bg)
1717
end
1818

1919
local common = concat_config(prefix, {
20-
"no_cache",
2120
"solid_vert_split",
2221
"solid_float_border",
2322
"solid_line_nr",

lua/zenbones/util.lua

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,28 @@ M.version = "4.12.0" -- x-release-please-version
77
function M.apply_colorscheme()
88
local colors_name = vim.g.colors_name
99
-- TODO don't call get_global_config twice
10-
local opts = require("zenbones.specs").get_global_config(colors_name, vim.o.background)
11-
if opts.no_cache then
10+
if M.is_cache_disabled(colors_name) then
1211
M.apply_colorscheme_without_cache(colors_name)
1312
else
14-
M.apply_colorscheme_with_cache(colors_name, opts)
13+
M.apply_colorscheme_with_cache(colors_name)
1514
end
1615
end
1716

17+
function M.is_cache_disabled(colors_name)
18+
return vim.g.bones_no_cache or vim.g[colors_name .. "_no_cache"]
19+
end
20+
1821
function M.apply_colorscheme_without_cache(colors_name)
1922
package.loaded[colors_name] = nil
2023
require "lush"(require(colors_name), { force_clean = false })
2124
local p = require(colors_name .. ".palette")[vim.o.background]
2225
require("zenbones.term").apply_colors(p)
2326
end
2427

25-
function M.apply_colorscheme_with_cache(global_colors_name, opts)
28+
function M.apply_colorscheme_with_cache(global_colors_name)
2629
-- For randombones, we should cache individual colorscheme with their real name
2730
-- but use options from prefix "randombones"
31+
local opts = require("zenbones.specs").get_global_config(global_colors_name, vim.o.background)
2832
local colors_name = vim.g.randombones_colors_name or global_colors_name
2933
local inputs = {
3034
version = M.version,

0 commit comments

Comments
 (0)