-
Notifications
You must be signed in to change notification settings - Fork 3
/
init.lua
238 lines (229 loc) · 5.62 KB
/
init.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
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
local core_utils = require("core.utils")
local colors = require("core.colors")
local map = core_utils.map
return {
-- TUI
{
"rebelot/heirline.nvim",
event = "UIEnter",
config = function()
vim.o.signcolumn = "no"
vim.o.foldcolumn = "0"
vim.go.laststatus = 3
vim.go.showtabline = 0
require("heirline").setup {
statuscolumn = require("plugins.ui.statuscolumn"),
statusline = require("plugins.ui.statusline"),
}
local function new_tab()
local view = vim.fn.winsaveview()
vim.cmd.tabedit("%")
if view then
vim.fn.winrestview(view)
else
vim.notify("Failed to save view for new tab", vim.log.levels.WARN)
end
end
map {
["<C-t>"] = { new_tab, "Open current buffer in new tab" },
["<C-S-t>"] = { ":tabclose<CR>", "Close current tab" },
["<C-Tab>"] = { ":tabnext<CR>", "View next tab" },
["<C-S-Tab>"] = { ":tabprevious<CR>", "View previous tab" },
}
end,
},
require("plugins.ui.windowline"),
-- Colorful modes
{
"mvllow/modes.nvim",
event = "VeryLazy",
config = true,
},
-- CMD line replacement and other UI niceties
{
"folke/noice.nvim",
dependencies = {
"MunifTanjim/nui.nvim",
"rcarriga/nvim-notify",
},
enabled = true,
lazy = false,
init = function()
map {
["<leader><leader>"] = { ":noh<CR>", "Hide search highlights" },
["<leader>k"] = { ":Noice dismiss<CR>", "Dismiss notifications" },
}
end,
opts = {
presets = {
bottom_search = false,
command_palette = true,
long_message_to_split = true,
lsp_doc_border = true,
},
views = {
messages = { backend = "popup" },
},
popupmenu = { enabled = true, backend = "nui" },
routes = {
{
filter = { event = "msg_show", find = '"*"*lines --*%--' },
view = "notify",
opts = { skip = true },
},
},
messages = {
view = "mini",
view_error = "notify",
view_warn = "notify",
view_search = "virtualtext",
view_history = "messages",
},
},
},
-- Better select dialog
{
"stevearc/dressing.nvim",
event = "VeryLazy",
opts = {
input = { enabled = false },
select = { enabled = true },
},
},
-- Context-aware indentation lines
{
"lukas-reineke/indent-blankline.nvim",
event = "BufRead",
main = "ibl",
opts = {
indent = {
char = "▎",
tab_char = "▎",
},
scope = {
show_start = false,
show_end = false,
include = {
node_type = {
lua = { "table_constructor" },
nix = { "attrset_expression", "list_expression" },
},
},
},
},
},
-- Notification handler
{
"rcarriga/nvim-notify",
event = "UIEnter",
opts = {
top_down = true,
max_width = 100,
},
},
-- Keymaps cheat sheet and tooltips
{
"folke/which-key.nvim",
init = function()
vim.o.timeout = true
vim.o.timeoutlen = 150
end,
opts = {
window = {
border = "rounded",
position = "bottom",
margin = { 10, 10, 2, 10 },
},
},
},
{
"echasnovski/mini.hipatterns",
event = "VeryLazy",
config = function()
local hipatterns = require("mini.hipatterns")
local palette = colors.palette()
local palette_patterns = {}
local palette_highlights = {}
for name, color in pairs(palette) do
palette_patterns[name] = {
pattern = "%f[%w]palette[.]()" .. name .. "()%f[%W]",
group = "",
extmark_opts = {
virt_text_pos = "inline",
virt_text = { { " ", "HiPatternsPalette_" .. name } },
},
}
palette_highlights["HiPatternsPalette_" .. name] = { fg = color }
end
local function gen_palette_colors()
return {
pattern = function(bufnr)
if vim.api.nvim_buf_get_name(bufnr):match("theme.lua$") then
return "colors[.]%w*[(]palette[.].*, %d[.]%d+[)]"
end
return nil
end,
group = "",
extmark_opts = function(_, _, data)
local func, base_color, ratio =
data.full_match:match("colors[.](%w*)[(]palette[.](.*), (%d[.]%d+)[)]")
local group_name = "HiPatternsPalette_"
.. base_color
.. "_"
.. func
.. "_"
.. ratio:gsub("%.", "_")
base_color = palette[base_color]
if vim.fn.hlexists(group_name) == 0 then
require("catppuccin.lib.highlighter").syntax {
[group_name] = {
fg = colors[func](base_color, tonumber(ratio)),
},
}
end
return {
virt_text_pos = "inline",
virt_text = { { " ", group_name } },
}
end,
}
end
local function gen_group_colors()
return {
pattern = function(bufnr)
if vim.api.nvim_buf_get_name(bufnr):match("theme.lua$") then
return "()[^ ].*() = {.*palette.*}"
end
return nil
end,
group = function(_, _, data)
local group, body = data.full_match:match("([^{]*) = ({.*})$")
group = group:gsub('[]"[]+', "")
local group_name = "HiPatternsGroup_" .. group
local group_def = loadstring([[
local colors = require("core.colors")
local palette = colors.palette()
return ]] .. body)
-- The group name isn't fully descriptive of what's inside, so we need to redefine it each time
require("catppuccin.lib.highlighter").syntax {
[group_name] = group_def and group_def() or nil,
}
return group_name
end,
}
end
require("catppuccin.lib.highlighter").syntax(palette_highlights)
local highlighters = {
hex_color = hipatterns.gen_highlighter.hex_color {
style = "inline",
inline_text = " ",
},
palette_colors = gen_palette_colors(),
group_colors = gen_group_colors(),
}
hipatterns.setup {
highlighters = vim.tbl_extend("force", highlighters, palette_patterns),
}
end,
},
}