Skip to content

Commit 2ed2be7

Browse files
committed
refactor: rename themes options to highlights
1 parent 704c62f commit 2ed2be7

File tree

4 files changed

+42
-20
lines changed

4 files changed

+42
-20
lines changed

lua/one_monokai/config.lua

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,46 @@ local config = {}
33
---@class options
44
---@field transparent boolean #Whether to enable transparent background
55
---@field colors colors #Custom colors
6-
---@field themes fun(colors:colors):groups #Custom highlight groups
7-
---@field italics boolean #Whether to italicize some highlight groups
6+
---@field highlights? fun(colors:colors):groups #Custom highlight groups
7+
---@field italics boolean #Whether to apply italics to certain highlight groups
88
local defaults = {
99
transparent = false,
1010
colors = {},
11-
themes = function(_)
12-
return {}
13-
end,
11+
---@deprecated
12+
themes = nil,
13+
highlights = nil,
1414
italics = true,
1515
}
1616

17-
config.options = vim.deepcopy(defaults)
17+
---@type options
18+
local options = vim.deepcopy(defaults)
1819

1920
---Extend default with user's config
2021
---@param opts options
21-
function config:extend(opts)
22-
self.options = vim.tbl_deep_extend("force", self.options, opts or {})
22+
function config.extend(opts)
23+
if not opts or vim.tbl_isempty(opts) then
24+
return
25+
end
26+
27+
local logs = require "one_monokai.logs"
28+
29+
if opts.themes then
30+
logs.notify.warning(
31+
"config: %q option has been deprecated and will be removed soon. Please update your config to use %q instead.",
32+
"themes",
33+
"highlights"
34+
)
35+
36+
opts.highlights = opts.themes
37+
end
38+
39+
options = vim.tbl_deep_extend("force", options, opts)
2340
end
2441

25-
return setmetatable(config, {
26-
__index = function(_, key)
27-
return config.options[key]
42+
setmetatable(config, {
43+
__index = function(_, k)
44+
return options[k]
2845
end,
2946
})
47+
48+
return config
File renamed without changes.
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
local themes = {}
1+
local highlights = {}
22

33
---Set highlight groups
44
---@param groups groups
@@ -10,18 +10,21 @@ local function set_highlight(groups)
1010
local status_ok, err = pcall(set_hl, 0, name, attrs)
1111

1212
if not status_ok then
13-
logs.error.notify("themes(%s): %s", name, err)
13+
logs.notify.error("highlights(%s): %s", name, err)
1414
end
1515
end
1616
end
1717

18-
function themes.load()
18+
function highlights.load()
1919
local config = require "one_monokai.config"
2020
local colors = require "one_monokai.colors"
21-
local default = require "one_monokai.themes.groups"
21+
local default = require "one_monokai.highlights.groups"
2222

2323
set_highlight(default)
24-
set_highlight(config.themes(colors))
24+
25+
if config.highlights then
26+
set_highlight(config.highlights(colors))
27+
end
2528
end
2629

27-
return themes
30+
return highlights

lua/one_monokai/init.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ local M = {}
33
function M.setup(opts)
44
local set = vim.cmd
55
local config = require "one_monokai.config"
6-
local themes = require "one_monokai.themes"
6+
local highlights = require "one_monokai.highlights"
77

88
if vim.g.colors_name then
99
set.hi "clear"
@@ -17,8 +17,8 @@ function M.setup(opts)
1717
vim.o.termguicolors = true
1818
vim.g.colors_name = "one_monokai"
1919

20-
config:extend(opts)
21-
themes.load()
20+
config.extend(opts)
21+
highlights.load()
2222
end
2323

2424
return M

0 commit comments

Comments
 (0)