-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path.lazy.lua
141 lines (130 loc) · 4.22 KB
/
.lazy.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
local M = {
autocmds = true,
module = "monokai-nightasty",
module_escaped = "monokai%-nightasty",
colorscheme = "monokai-nightasty",
---@type monokai.UserConfig
opts = {
style = vim.o.background,
auto_enable_plugins = false,
plugins = { all = true },
cache = false,
color_headers = true,
-- dark_style_background = "transparent",
-- hl_styles = {},
},
globals = { vim = vim },
cache = {}, ---@type table<string, boolean>
}
function M.set_autocmds()
local function reset()
require("monokai-nightasty.utils").cache.clear()
local opts = require("monokai-nightasty.config").extend()
local colors = require("monokai-nightasty.colors").setup(opts)
M.globals.colors = colors
M.globals.c = colors
end
local function reload()
for k in pairs(package.loaded) do
if k:find("^" .. M.module_escaped) then
package.loaded[k] = nil
end
end
M.cache = {}
require(M.module).setup(M.opts) -- Setup
reset()
local colorscheme = vim.g.colors_name or M.colorscheme
colorscheme = colorscheme:find(M.colorscheme) and colorscheme or M.colorscheme
vim.cmd.colorscheme(colorscheme)
if package.loaded["MiniHipatterns"] then
local mini_hipatterns = require("mini.hipatterns")
for _, buf in ipairs(require("mini.hipatterns").get_enabled_buffers()) do
mini_hipatterns.update(buf)
end
end
end
M.reload = vim.schedule_wrap(reload)
local augroup = vim.api.nvim_create_augroup("monokai_dev", { clear = true })
vim.api.nvim_create_autocmd("User", {
pattern = "VeryLazy",
group = augroup,
callback = M.reload,
})
vim.api.nvim_create_autocmd("BufWritePost", {
group = augroup,
pattern = "*" .. M.module .. "/**.lua",
callback = M.reload,
})
end
---@param name string
---@param buf number
function M.hl_group(name, buf)
return vim.api.nvim_buf_get_name(buf):find("kinds") and "LspKind" .. name or name
end
if M.autocmds then
M.set_autocmds()
end
return {
{
"echasnovski/mini.hipatterns",
opts = function(_, opts)
local hi = require("mini.hipatterns")
opts.highlighters = opts.highlighters or {}
opts.highlighters = vim.tbl_extend("keep", opts.highlighters or {}, {
hex_color = hi.gen_highlighter.hex_color({ priority = 2000 }),
hl_group = {
pattern = function(buf)
return vim.api.nvim_buf_get_name(buf):find("lua/" .. M.module_escaped)
and '^%s*%[?"?()[%w%.@]+()"?%]?%s*='
end,
group = function(buf, match)
local group = M.hl_group(match, buf)
if group then
if M.cache[group] == nil then
M.cache[group] = false
local hl =
vim.api.nvim_get_hl(0, { name = group, link = false, create = false })
if not vim.tbl_isempty(hl) then
hl.fg = hl.fg
or vim.api.nvim_get_hl(0, { name = "Normal", link = false }).fg
M.cache[group] = true
-- stylua: ignore
vim.api.nvim_set_hl(0, group .. "Dev", hl --[[@as vim.api.keyset.highlight]])
end
end
return M.cache[group] and group .. "Dev" or nil
end
end,
extmark_opts = { priority = 2000 },
},
hl_color = {
pattern = {
"%f[%w]()c%.[%w_%.]+()%f[%W]",
"%f[%w]()colors%.[%w_%.]+()%f[%W]",
"%f[%w]()vim%.g%.terminal_color_%d+()%f[%W]",
},
group = function(_, match)
local parts = vim.split(match, ".", { plain = true })
local color = vim.tbl_get(M.globals, unpack(parts))
return type(color) == "string"
and require("mini.hipatterns").compute_hex_color_group(color, "fg")
end,
extmark_opts = function(_, _, data)
return {
virt_text = { { "⬤ ", data.hl_group } },
virt_text_pos = "inline",
priority = 2000,
}
end,
},
})
end,
},
{
"nvim-telescope/telescope.nvim",
keys = {
{ "<leader>fc", "<Cmd>Telescope highlights<CR>" },
{ "<leader><leader>", "<Cmd>Inspect<CR>" },
},
},
}