1
1
local collect = require (' github-theme.lib.collect' )
2
2
local util = require (' github-theme.util' )
3
-
4
3
local M = { theme = ' github_dark' , has_options = false }
5
4
5
+ -- TODO: improve type of `specs` and `palettes`
6
+ --- @class (exact ) GhTheme.Config
7
+ --- @field options ? GhTheme.Config.Options
8
+ --- @field palettes ? table
9
+ --- @field specs ? table
10
+ --- @field groups ? table<GhTheme.Theme | " all" , table<string , GhTheme.HighlightGroup>>
11
+
12
+ --- @class (exact ) GhTheme.Config.Module
13
+ --- @field enable ? boolean whether to set plugin-specific highlights for this module /plugin
14
+
15
+ --- @class (exact ) GhTheme.Config.Module.Coc : GhTheme.Config.Module
16
+ --- @field background ? boolean whether to set background color of virtual text
17
+
18
+ --- @class (exact ) GhTheme.Config.Module.Diagnostic : GhTheme.Config.Module
19
+ --- @field background ? boolean whether to set background color of virtual text
20
+
21
+ --- @class (exact ) GhTheme.Config.Module.NativeLSP : GhTheme.Config.Module
22
+ --- @field background ? boolean whether to set background color of virtual text
23
+
24
+ --- Config for external modules/plugins.
25
+ --- @class (exact ) GhTheme.Config.Options.Modules
26
+ --- @field cmp ? boolean | GhTheme.Config.Module
27
+ --- @field coc ? boolean | GhTheme.Config.Module.Coc
28
+ --- @field coc_explorer ? boolean | GhTheme.Config.Module
29
+ --- @field dapui ? boolean | GhTheme.Config.Module
30
+ --- @field diffchar ? boolean | GhTheme.Config.Module
31
+ --- @field dashboard ? boolean | GhTheme.Config.Module
32
+ --- @field diagnostic ? boolean | GhTheme.Config.Module.Diagnostic
33
+ --- @field fidget ? boolean | GhTheme.Config.Module
34
+ --- @field fzf ? boolean | GhTheme.Config.Module
35
+ --- @field gitgutter ? boolean | GhTheme.Config.Module
36
+ --- @field gitsigns ? boolean | GhTheme.Config.Module
37
+ --- @field indent_blankline ? boolean | GhTheme.Config.Module
38
+ --- @field lsp_semantic_tokens ? boolean | GhTheme.Config.Module
39
+ --- @field lsp_trouble ? boolean | GhTheme.Config.Module
40
+ --- @field mini ? boolean | GhTheme.Config.Module
41
+ --- @field native_lsp ? boolean | GhTheme.Config.Module.NativeLSP
42
+ --- @field neogit ? boolean | GhTheme.Config.Module
43
+ --- @field neotree ? boolean | GhTheme.Config.Module
44
+ --- @field notify ? boolean | GhTheme.Config.Module
45
+ --- @field nvimtree ? boolean | GhTheme.Config.Module
46
+ --- @field telescope ? boolean | GhTheme.Config.Module
47
+ --- @field treesitter ? boolean | GhTheme.Config.Module
48
+ --- @field treesitter_context ? boolean | GhTheme.Config.Module
49
+ --- @field whichkey ? boolean | GhTheme.Config.Module
50
+
51
+ --- @class GhTheme.Config.Options
6
52
local defaults = {
7
53
compile_file_suffix = ' _compiled' ,
8
54
compile_path = util .join_paths (util .cache_home , ' github-theme' ),
@@ -13,15 +59,34 @@ local defaults = {
13
59
dim_inactive = false ,
14
60
module_default = true ,
15
61
styles = {
62
+ --- @type GhTheme.HighlightGroup.Style
16
63
comments = ' NONE' ,
64
+
65
+ --- @type GhTheme.HighlightGroup.Style
17
66
functions = ' NONE' ,
67
+
68
+ --- @type GhTheme.HighlightGroup.Style
18
69
keywords = ' NONE' ,
70
+
71
+ --- @type GhTheme.HighlightGroup.Style
19
72
variables = ' NONE' ,
73
+
74
+ --- @type GhTheme.HighlightGroup.Style
20
75
conditionals = ' NONE' ,
76
+
77
+ --- @type GhTheme.HighlightGroup.Style
21
78
constants = ' NONE' ,
79
+
80
+ --- @type GhTheme.HighlightGroup.Style
22
81
numbers = ' NONE' ,
82
+
83
+ --- @type GhTheme.HighlightGroup.Style
23
84
operators = ' NONE' ,
85
+
86
+ --- @type GhTheme.HighlightGroup.Style
24
87
strings = ' NONE' ,
88
+
89
+ --- @type GhTheme.HighlightGroup.Style
25
90
types = ' NONE' ,
26
91
},
27
92
inverse = {
@@ -33,9 +98,12 @@ local defaults = {
33
98
floats = true ,
34
99
sidebars = {
35
100
enable = true ,
101
+ --- List of (filetype or `'terminal'`) whose bg will be darkened.
36
102
list = {},
37
103
},
38
104
},
105
+
106
+ --- @type GhTheme.Config.Options.Modules
39
107
modules = {
40
108
coc = {
41
109
background = true ,
@@ -55,6 +123,12 @@ local defaults = {
55
123
},
56
124
}
57
125
126
+ -- The following is done to disallow the addition of any more fields.
127
+
128
+ --- @type GhTheme.Config.Options
129
+ --- @diagnostic disable-next-line : redefined-local
130
+ local defaults = defaults
131
+
58
132
M .options = collect .deep_copy (defaults )
59
133
60
134
M .module_names = {
@@ -84,10 +158,12 @@ M.module_names = {
84
158
' whichkey' ,
85
159
}
86
160
161
+ --- @param name GhTheme.Theme
87
162
function M .set_theme (name )
88
163
M .theme = name
89
164
end
90
165
166
+ --- @param opts GhTheme.Config.Options
91
167
function M .set_options (opts )
92
168
opts = opts or {}
93
169
M .options = collect .deep_extend (M .options , opts )
107
183
108
184
function M .hash ()
109
185
local hash = require (' github-theme.lib.hash' )(M .options )
110
- return hash and hash or 0
186
+ return hash or 0
111
187
end
112
188
113
189
return M
0 commit comments