-
-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathconfig.lua
More file actions
221 lines (200 loc) · 7.26 KB
/
config.lua
File metadata and controls
221 lines (200 loc) · 7.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
local collect = require('github-theme.lib.collect')
local util = require('github-theme.util')
local M = { theme = 'github_dark', has_options = false }
---@alias GhTheme.Config.Options.Filetype string A neovim `filetype`.
-- TODO: improve type of `specs` and `palettes`
---@class (exact) GhTheme.Config
---@field options? GhTheme.Config.Options
---@field palettes? table<GhTheme.Theme|"all", table>|false
---@field specs? table<GhTheme.Theme|"all", table>|false
---@field groups? table<GhTheme.Theme|"all", table<string, GhTheme.HighlightGroup|false>>|false
---@class (exact) GhTheme.Config.Module
---@field enable? boolean whether to set plugin-specific highlights for this module/plugin
---@class (exact) GhTheme.Config.Options
---@field compile_file_suffix? string
---@field compile_path? string
---@field hide_end_of_buffer? boolean
---@field hide_nc_statusline? boolean
---@field transparent? boolean
---@field terminal_colors? boolean
---@field dim_inactive? boolean
---@field module_default? boolean
---@field styles? GhTheme.Config.Options.Styles
---@field inverse? GhTheme.Config.Options.Inverse
---@field darken? GhTheme.Config.Options.Darken
---@field modules? GhTheme.Config.Options.Modules
local defaults = {
compile_file_suffix = '_compiled',
compile_path = util.join_paths(util.cache_home, 'github-theme'),
hide_end_of_buffer = true,
hide_nc_statusline = true,
transparent = false,
terminal_colors = true,
dim_inactive = false,
module_default = true,
---A table of syntax items/groups and their corresponding styles.
---@class (exact) GhTheme.Config.Options.Styles
---@field comments? GhTheme.HighlightGroup.Style
---@field functions? GhTheme.HighlightGroup.Style
---@field keywords? GhTheme.HighlightGroup.Style
---@field variables? GhTheme.HighlightGroup.Style
---@field conditionals? GhTheme.HighlightGroup.Style
---@field constants? GhTheme.HighlightGroup.Style
---@field numbers? GhTheme.HighlightGroup.Style
---@field operators? GhTheme.HighlightGroup.Style
---@field strings? GhTheme.HighlightGroup.Style
---@field types? GhTheme.HighlightGroup.Style
styles = {
comments = 'NONE',
functions = 'NONE',
keywords = 'NONE',
variables = 'NONE',
conditionals = 'NONE',
constants = 'NONE',
numbers = 'NONE',
operators = 'NONE',
strings = 'NONE',
types = 'NONE',
},
---The `inverse` table contains a list of highlight types. If a highlight type is
---enabled, the `fg` and `bg` colors will be inversed/reversed (swapped).
---
---For example, if `search` is enabled, then the foreground and background colors of
---highlighted search terms will be swapped.
---@class (exact) GhTheme.Config.Options.Inverse
---@field match_paren? boolean invert highlight of matching parenthesis (`:help matchparen`)
---@field visual? boolean invert highlight of visual mode selection
---@field search? boolean invert highlight of current search term
inverse = {
match_paren = false,
visual = false,
search = false,
},
---@class (exact) GhTheme.Config.Options.Darken
---@field floats? boolean whether to darken the `bg` of floating windows (default `true`)
---@field sidebars? GhTheme.Config.Options.Darken.Sidebars
darken = {
floats = true,
---@class (exact) GhTheme.Config.Options.Darken.Sidebars
---@field enable? boolean whether to darken the `bg` of sidebars (i.e. sidebar windows) (default `true`)
---@field list? (GhTheme.Config.Options.Filetype|"terminal")[] list of sidebars whose `bg` will be darkened
sidebars = {
enable = true,
list = {},
},
},
---Config for external modules/plugins.
---@class (exact) GhTheme.Config.Options.Modules
---@field cmp? boolean|GhTheme.Config.Module
---@field coc? boolean|GhTheme.Config.Module.Coc
---@field coc_explorer? boolean|GhTheme.Config.Module
---@field dapui? boolean|GhTheme.Config.Module
---@field diffchar? boolean|GhTheme.Config.Module
---@field dashboard? boolean|GhTheme.Config.Module
---@field diagnostic? boolean|GhTheme.Config.Module.Diagnostic
---@field fidget? boolean|GhTheme.Config.Module
---@field fzf? boolean|GhTheme.Config.Module
---@field gitgutter? boolean|GhTheme.Config.Module
---@field gitsigns? boolean|GhTheme.Config.Module
---@field indent_blankline? boolean|GhTheme.Config.Module
---@field lsp_semantic_tokens? boolean|GhTheme.Config.Module
---@field lsp_trouble? boolean|GhTheme.Config.Module
---@field mini? boolean|GhTheme.Config.Module
---@field native_lsp? boolean|GhTheme.Config.Module.NativeLSP
---@field neogit? boolean|GhTheme.Config.Module
---@field neotree? boolean|GhTheme.Config.Module
---@field notify? boolean|GhTheme.Config.Module
---@field snacks? boolean|GhTheme.Config.Module
---@field nvimtree? boolean|GhTheme.Config.Module
---@field telescope? boolean|GhTheme.Config.Module
---@field treesitter? boolean|GhTheme.Config.Module
---@field treesitter_context? boolean|GhTheme.Config.Module
---@field whichkey? boolean|GhTheme.Config.Module
modules = {
---@class (exact) GhTheme.Config.Module.Coc: GhTheme.Config.Module
---@field enable? boolean
---@field background? boolean whether to set background color of virtual text
coc = {
background = true,
},
---@class (exact) GhTheme.Config.Module.Diagnostic: GhTheme.Config.Module
---@field enable? boolean
---@field background? boolean whether to set background color of virtual text
diagnostic = {
-- This is linked to so much that is needs to be enabled. This is here primarily for
-- the extra options that can be added with modules.
enable = true,
background = false,
},
---@class (exact) GhTheme.Config.Module.NativeLSP: GhTheme.Config.Module
---@field enable? boolean
---@field background? boolean whether to set background color of virtual text
native_lsp = {
enable = util.is_nvim,
background = true,
},
treesitter = util.is_nvim,
lsp_semantic_tokens = util.is_nvim,
snacks = {
enable = true,
},
},
}
M.module_names = {
'cmp',
'coc',
'coc_explorer',
'dapui',
'dashboard',
'diagnostic',
'diffchar',
'fidget',
'fzf',
'gitgutter',
'gitsigns',
'indent_blankline',
'lsp_semantic_tokens',
'lsp_trouble',
'mini',
'native_lsp',
'neogit',
'neotree',
'notify',
'nvimtree',
'snacks',
'telescope',
'treesitter',
'treesitter_context',
'whichkey',
}
---@param name GhTheme.Theme
function M.set_theme(name)
M.theme = name
end
---@param opts GhTheme.Config.Options
function M.set_options(opts)
opts = opts or {}
---@type GhTheme.Config.Options
M.options = collect.deep_extend(M.options, opts)
M.has_options = true
end
function M.reset()
---@type GhTheme.Config.Options
M.options = collect.deep_copy(defaults)
return M
end
---@param opts? { output_path?: string, file_suffix?: string, theme?: string }
---@return string
---@return string
function M.get_compiled_info(opts)
opts = opts or {}
local output_path = opts.output_path or M.options.compile_path
local file_suffix = opts.file_suffix or M.options.compile_file_suffix
---@cast output_path -?
---@cast file_suffix -?
return output_path, util.join_paths(output_path, (opts.theme or M.theme) .. file_suffix)
end
function M.hash()
return require('github-theme.lib.hash')(M.options) or 0
end
return M.reset()