-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy path20_mini.lua
288 lines (242 loc) · 9.69 KB
/
20_mini.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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
local add, now, later = MiniDeps.add, MiniDeps.now, MiniDeps.later
-- Make 'mini.nvim' part of the 'mini-deps-snap'
-- Use 'HEAD' because I personally update it and don't want to follow `main`
add({ name = 'mini.nvim', checkout = 'HEAD' })
-- Step one ===================================================================
now(function() vim.cmd('colorscheme miniwinter') end)
now(function()
require('mini.basics').setup({
-- Manage options manually in a spirit of transparency
options = { basic = false },
mappings = { windows = true, move_with_alt = true },
autocommands = { relnum_in_visual_mode = true },
})
end)
now(function()
local not_lua_diagnosing = function(notif) return not vim.startswith(notif.msg, 'lua_ls: Diagnosing') end
local filterout_lua_diagnosing = function(notif_arr)
return MiniNotify.default_sort(vim.tbl_filter(not_lua_diagnosing, notif_arr))
end
require('mini.notify').setup({
content = { sort = filterout_lua_diagnosing },
window = { config = { border = 'double' } },
})
vim.notify = MiniNotify.make_notify()
end)
now(function() require('mini.sessions').setup() end)
now(function() require('mini.starter').setup() end)
now(function() require('mini.statusline').setup() end)
now(function() require('mini.tabline').setup() end)
now(function()
require('mini.icons').setup({
use_file_extension = function(ext, _)
local suf3, suf4 = ext:sub(-3), ext:sub(-4)
return suf3 ~= 'scm' and suf3 ~= 'txt' and suf3 ~= 'yml' and suf4 ~= 'json' and suf4 ~= 'yaml'
end,
})
MiniIcons.mock_nvim_web_devicons()
later(MiniIcons.tweak_lsp_kind)
end)
-- Step two ===================================================================
later(function() require('mini.extra').setup() end)
later(function()
local ai = require('mini.ai')
ai.setup({
custom_textobjects = {
B = MiniExtra.gen_ai_spec.buffer(),
F = ai.gen_spec.treesitter({ a = '@function.outer', i = '@function.inner' }),
},
})
end)
later(function() require('mini.align').setup() end)
later(function() require('mini.animate').setup({ scroll = { enable = false } }) end)
later(function() require('mini.bracketed').setup() end)
later(function() require('mini.bufremove').setup() end)
later(function()
local miniclue = require('mini.clue')
--stylua: ignore
miniclue.setup({
clues = {
Config.leader_group_clues,
miniclue.gen_clues.builtin_completion(),
miniclue.gen_clues.g(),
miniclue.gen_clues.marks(),
miniclue.gen_clues.registers(),
miniclue.gen_clues.windows({ submode_resize = true }),
miniclue.gen_clues.z(),
},
triggers = {
{ mode = 'n', keys = '<Leader>' }, -- Leader triggers
{ mode = 'x', keys = '<Leader>' },
{ mode = 'n', keys = [[\]] }, -- mini.basics
{ mode = 'n', keys = '[' }, -- mini.bracketed
{ mode = 'n', keys = ']' },
{ mode = 'x', keys = '[' },
{ mode = 'x', keys = ']' },
{ mode = 'i', keys = '<C-x>' }, -- Built-in completion
{ mode = 'n', keys = 'g' }, -- `g` key
{ mode = 'x', keys = 'g' },
{ mode = 'n', keys = "'" }, -- Marks
{ mode = 'n', keys = '`' },
{ mode = 'x', keys = "'" },
{ mode = 'x', keys = '`' },
{ mode = 'n', keys = '"' }, -- Registers
{ mode = 'x', keys = '"' },
{ mode = 'i', keys = '<C-r>' },
{ mode = 'c', keys = '<C-r>' },
{ mode = 'n', keys = '<C-w>' }, -- Window commands
{ mode = 'n', keys = 'z' }, -- `z` key
{ mode = 'x', keys = 'z' },
},
window = { config = { border = 'double' } },
})
end)
-- Don't really need it on daily basis
-- later(function() require('mini.colors').setup() end)
later(function() require('mini.comment').setup() end)
later(function()
require('mini.completion').setup({
lsp_completion = {
source_func = 'omnifunc',
auto_setup = false,
process_items = function(items, base)
-- Don't show 'Text' and 'Snippet' suggestions
items = vim.tbl_filter(function(x) return x.kind ~= 1 and x.kind ~= 15 end, items)
return MiniCompletion.default_process_items(items, base)
end,
},
window = {
info = { border = 'double' },
signature = { border = 'double' },
},
})
if vim.fn.has('nvim-0.11') == 1 then
vim.opt.completeopt:append('fuzzy') -- Use fuzzy matching for built-in completion
end
end)
later(function() require('mini.cursorword').setup() end)
later(function()
require('mini.diff').setup()
local rhs = function() return MiniDiff.operator('yank') .. 'gh' end
vim.keymap.set('n', 'ghy', rhs, { expr = true, remap = true, desc = "Copy hunk's reference lines" })
end)
later(function() require('mini.doc').setup() end)
later(function()
require('mini.files').setup({ windows = { preview = true } })
local minifiles_augroup = vim.api.nvim_create_augroup('ec-mini-files', {})
vim.api.nvim_create_autocmd('User', {
group = minifiles_augroup,
pattern = 'MiniFilesWindowOpen',
callback = function(args) vim.api.nvim_win_set_config(args.data.win_id, { border = 'double' }) end,
})
vim.api.nvim_create_autocmd('User', {
group = minifiles_augroup,
pattern = 'MiniFilesExplorerOpen',
callback = function()
MiniFiles.set_bookmark('c', vim.fn.stdpath('config'), { desc = 'Config' })
MiniFiles.set_bookmark('m', vim.fn.stdpath('data') .. '/site/pack/deps/start/mini.nvim', { desc = 'mini.nvim' })
MiniFiles.set_bookmark('p', vim.fn.stdpath('data') .. '/site/pack/deps/opt', { desc = 'Plugins' })
MiniFiles.set_bookmark('w', vim.fn.getcwd, { desc = 'Working directory' })
end,
})
end)
later(function() require('mini.git').setup() end)
later(function()
local hipatterns = require('mini.hipatterns')
local hi_words = MiniExtra.gen_highlighter.words
hipatterns.setup({
highlighters = {
fixme = hi_words({ 'FIXME', 'Fixme', 'fixme' }, 'MiniHipatternsFixme'),
hack = hi_words({ 'HACK', 'Hack', 'hack' }, 'MiniHipatternsHack'),
todo = hi_words({ 'TODO', 'Todo', 'todo' }, 'MiniHipatternsTodo'),
note = hi_words({ 'NOTE', 'Note', 'note' }, 'MiniHipatternsNote'),
hex_color = hipatterns.gen_highlighter.hex_color(),
},
})
end)
later(function() require('mini.indentscope').setup() end)
later(function() require('mini.jump').setup() end)
later(function()
local jump2d = require('mini.jump2d')
jump2d.setup({
spotter = jump2d.gen_pattern_spotter('[^%s%p]+'),
view = { dim = true, n_steps_ahead = 2 },
})
end)
later(function()
local map = require('mini.map')
local gen_integr = map.gen_integration
map.setup({
symbols = { encode = map.gen_encode_symbols.dot('4x2') },
integrations = { gen_integr.builtin_search(), gen_integr.diff(), gen_integr.diagnostic() },
})
vim.keymap.set('n', [[\h]], ':let v:hlsearch = 1 - v:hlsearch<CR>', { desc = 'Toggle hlsearch' })
for _, key in ipairs({ 'n', 'N', '*' }) do
vim.keymap.set('n', key, key .. 'zv<Cmd>lua MiniMap.refresh({}, { lines = false, scrollbar = false })<CR>')
end
end)
later(function()
require('mini.misc').setup({ make_global = { 'put', 'put_text', 'stat_summary', 'bench_time' } })
MiniMisc.setup_auto_root()
MiniMisc.setup_termbg_sync()
end)
later(function() require('mini.move').setup({ options = { reindent_linewise = false } }) end)
later(function()
local remap = function(mode, lhs_from, lhs_to)
local keymap = vim.fn.maparg(lhs_from, mode, false, true)
local rhs = keymap.callback or keymap.rhs
if rhs == nil then error('Could not remap from ' .. lhs_from .. ' to ' .. lhs_to) end
vim.keymap.set(mode, lhs_to, rhs, { desc = keymap.desc })
end
remap('n', 'gx', '<Leader>ox')
remap('x', 'gx', '<Leader>ox')
require('mini.operators').setup()
end)
later(function()
require('mini.pairs').setup({ modes = { insert = true, command = true, terminal = true } })
vim.keymap.set('i', '<CR>', 'v:lua.Config.cr_action()', { expr = true })
end)
later(function()
require('mini.pick').setup({ window = { config = { border = 'double' } } })
vim.ui.select = MiniPick.ui_select
vim.keymap.set('n', ',', [[<Cmd>Pick buf_lines scope='current' preserve_order=true<CR>]], { nowait = true })
MiniPick.registry.projects = function()
local cwd = vim.fn.expand('~/repos')
local choose = function(item)
vim.schedule(function() MiniPick.builtin.files(nil, { source = { cwd = item.path } }) end)
end
return MiniPick.builtin.files({ cwd = cwd }, { source = { choose = choose } })
end
end)
later(function()
local snippets, config_path = require('mini.snippets'), vim.fn.stdpath('config')
local lang_patterns = { tex = { 'latex.json' }, plaintex = { 'latex.json' } }
local load_if_minitest_buf = function(context)
local buf_name = vim.api.nvim_buf_get_name(context.buf_id)
local is_test_buf = vim.fn.fnamemodify(buf_name, ':t'):find('^test_.+%.lua$') ~= nil
if not is_test_buf then return {} end
return MiniSnippets.read_file(config_path .. '/snippets/mini-test.json')
end
snippets.setup({
snippets = {
snippets.gen_loader.from_file(config_path .. '/snippets/global.json'),
snippets.gen_loader.from_lang({ lang_patterns = lang_patterns }),
load_if_minitest_buf,
},
})
end)
later(function() require('mini.splitjoin').setup() end)
later(function()
require('mini.surround').setup({ search_method = 'cover_or_next' })
-- Disable `s` shortcut (use `cl` instead) for safer usage of 'mini.surround'
vim.keymap.set({ 'n', 'x' }, 's', '<Nop>')
end)
later(function()
local test = require('mini.test')
local reporter = test.gen_reporter.buffer({ window = { border = 'double' } })
test.setup({
execute = { reporter = reporter },
})
end)
later(function() require('mini.trailspace').setup() end)
later(function() require('mini.visits').setup() end)