-
Notifications
You must be signed in to change notification settings - Fork 37
/
config.lua
166 lines (150 loc) · 4.94 KB
/
config.lua
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
local util = require("onedarkpro.utils")
local M = { theme = "onedark", is_setup = false }
local defaults = {
caching = true, -- Enable caching
cache_path = vim.fn.expand(vim.fn.stdpath("cache") .. "/onedarkpro"), -- The path to the cache directory
cache_suffix = "_compiled",
debug = false,
colors = {}, -- Add/override colors
highlights = {}, -- Add/override highlights
styles = {
tags = "NONE", -- Style that is applied to tags
types = "NONE", -- Style that is applied to types
methods = "NONE", -- Style that is applied to methods
numbers = "NONE", -- Style that is applied to numbers
strings = "NONE", -- Style that is applied to strings
comments = "NONE", -- Style that is applied to comments
keywords = "NONE", -- Style that is applied to keywords
constants = "NONE", -- Style that is applied to constants
functions = "NONE", -- Style that is applied to functions
operators = "NONE", -- Style that is applied to operators
variables = "NONE", -- Style that is applied to variables
parameters = "NONE", -- Style that is applied to parameters
conditionals = "NONE", -- Style that is applied to conditionals
virtual_text = "NONE", -- Style that is applied to virtual text
},
filetypes = { -- Enable/disable specific plugins
c = true,
comment = true,
go = true,
html = true,
java = true,
javascript = true,
json = true,
lua = true,
markdown = true,
php = true,
python = true,
ruby = true,
rust = true,
scss = true,
toml = true,
typescript = true,
typescriptreact = true,
vue = true,
xml = true,
yaml = true,
},
plugins = { -- Enable/disable specific plugins
aerial = true,
barbar = true,
codecompanion = true,
copilot = true,
dashboard = true,
diffview = true,
flash_nvim = true,
gitsigns = true,
hop = true,
indentline = true,
leap = true,
lsp_saga = true,
lsp_semantic_tokens = true,
marks = true,
mason = true,
mini_indentscope = true,
neotest = true,
neo_tree = true,
nvim_cmp = true,
nvim_bqf = true,
nvim_dap = true,
nvim_dap_ui = true,
nvim_hlslens = true,
nvim_lsp = true,
nvim_navic = true,
nvim_notify = true,
nvim_tree = true,
nvim_ts_rainbow = true,
nvim_ts_rainbow2 = true,
op_nvim = true,
packer = true,
persisted = true,
polygot = true,
rainbow_delimiters = true,
startify = true,
telescope = true,
toggleterm = true,
treesitter = true,
trouble = true,
vim_ultest = true,
which_key = true,
vim_dadbod_ui = true,
},
options = {
cursorline = false, -- Use cursorline highlighting?
transparency = false, -- Use a transparent background?
terminal_colors = true, -- Use the theme's colors for Neovim's :terminal?
lualine_transparency = false, -- Center bar transparency?
highlight_inactive_windows = false, -- When the window is out of focus, change the normal background?
},
}
M.config = vim.deepcopy(defaults)
---Determine the filetypes or plugins that should be loaded
---@param files table
---@param override table
---@return table
local function load_files(files, override)
for f, _ in pairs(files) do
if override["all"] == false then files[f] = false end
if override[f] then files[f] = override[f] end
end
return files
end
---Set the theme to use
---@param theme string
---@return nil
function M.set_theme(theme)
M.theme = theme
end
---Reset the config to the default values
---@return nil
function M.reset()
M.config = util.deep_copy(defaults)
end
---Setup the configuration for the theme
---@param opts? table
---@return nil
function M.setup(opts)
opts = opts or {}
M.config = util.deep_extend(M.config, opts)
if M.config.options.cursorline then vim.wo.cursorline = true end
if opts and opts.filetypes then M.config.filetypes = load_files(M.config.filetypes, opts.filetypes) end
if opts and opts.plugins then M.config.plugins = load_files(M.config.plugins, opts.plugins) end
M.is_setup = true
end
---Get information relating to where the cache is stored
---@param opts? table
---@return string,string
function M.get_cached_info(opts)
opts = opts or {}
local theme = opts.theme or M.theme
local cache_path = opts.cache_path or M.config.cache_path
local theme_path = util.join_paths(cache_path, theme .. M.config.cache_suffix)
return cache_path, theme_path
end
---Create a hash from the config
---@return string|number
function M.hash()
local hash = require("onedarkpro.lib.hash")(M.config)
return hash and hash or 0
end
return M