my dotfiles for arch
1return {
2 "echasnovski/mini.nvim",
3 version = false,
4 config = function()
5 require("mini.ai").setup({
6 -- Table with textobject id as fields, textobject specification as values.
7 -- Also use this to disable builtin textobjects. See |MiniAi.config|.
8 custom_textobjects = nil,
9
10 -- Module mappings. Use `''` (empty string) to disable one.
11 mappings = {
12 -- Main textobject prefixes
13 around = "a",
14 inside = "i",
15
16 -- Next/last variants
17 around_next = "an",
18 inside_next = "in",
19 around_last = "al",
20 inside_last = "il",
21
22 -- Move cursor to corresponding edge of `a` textobject
23 goto_left = "g[",
24 goto_right = "g]",
25 },
26
27 -- Number of lines within which textobject is searched
28 n_lines = 1000,
29
30 -- How to search for object (first inside current line, then inside
31 -- neighborhood). One of 'cover', 'cover_or_next', 'cover_or_prev',
32 -- 'cover_or_nearest', 'next', 'previous', 'nearest'.
33 search_method = "cover_or_next",
34
35 -- Whether to disable showing non-error feedback
36 -- This also affects (purely informational) helper messages shown after
37 -- idle time if user input is required.
38 silent = false,
39 })
40
41 require("mini.surround").setup(
42 -- No need to copy this inside `setup()`. Will be used automatically.
43 {
44 -- Add custom surroundings to be used on top of builtin ones. For more
45 -- information with examples, see `:h MiniSurround.config`.
46 custom_surroundings = nil,
47
48 -- Duration (in ms) of highlight when calling `MiniSurround.highlight()`
49 highlight_duration = 500,
50
51 -- Module mappings. Use `''` (empty string) to disable one.
52 mappings = {
53 add = "sa", -- Add surrounding in Normal and Visual modes
54 delete = "sd", -- Delete surrounding
55 find = "sf", -- Find surrounding (to the right)
56 find_left = "sF", -- Find surrounding (to the left)
57 highlight = "sh", -- Highlight surrounding
58 replace = "sr", -- Replace surrounding
59 update_n_lines = "sn", -- Update `n_lines`
60
61 suffix_last = "l", -- Suffix to search with "prev" method
62 suffix_next = "n", -- Suffix to search with "next" method
63 },
64
65 -- Number of lines within which surrounding is searched
66 n_lines = 1000,
67
68 -- Whether to respect selection type:
69 -- - Place surroundings on separate lines in linewise mode.
70 -- - Place surroundings on each line in blockwise mode.
71 respect_selection_type = false,
72
73 -- How to search for surrounding (first inside current line, then inside
74 -- neighborhood). One of 'cover', 'cover_or_next', 'cover_or_prev',
75 -- 'cover_or_nearest', 'next', 'prev', 'nearest'. For more details,
76 -- see `:h MiniSurround.config`.
77 search_method = "cover",
78
79 -- Whether to disable showing non-error feedback
80 -- This also affects (purely informational) helper messages shown after
81 -- idle time if user input is required.
82 silent = false,
83 }
84 )
85
86 -- Create a custom command to wrap double quotes with {[]} at cursor position
87 vim.api.nvim_create_user_command("WrapQuotesWithBrackets", function()
88 -- Get cursor position (1-indexed for line, 0-indexed for column)
89 local cursor = vim.api.nvim_win_get_cursor(0)
90 local line_num = cursor[1]
91 local col_num = cursor[2] + 1 -- Convert to 1-indexed for string operations
92
93 -- Get the current line
94 local line = vim.api.nvim_get_current_line()
95
96 -- Find all quote pairs in the line
97 local quote_start, quote_end = nil, nil
98 local pos = 1
99
100 while pos <= #line do
101 local start_pos = line:find('"', pos)
102 if not start_pos then
103 break
104 end
105
106 local end_pos = line:find('"', start_pos + 1)
107 if not end_pos then
108 break
109 end
110
111 -- Check if cursor is within or on this quote pair
112 if col_num >= start_pos and col_num <= end_pos then
113 quote_start = start_pos
114 quote_end = end_pos
115 break
116 end
117
118 pos = end_pos + 1
119 end
120
121 -- If we found quotes surrounding the cursor, wrap them
122 if quote_start and quote_end then
123 local before = line:sub(1, quote_start - 1)
124 local quoted_content = line:sub(quote_start, quote_end)
125 local after = line:sub(quote_end + 1)
126
127 local new_line = before .. "{[" .. quoted_content .. "]}" .. after
128
129 -- Replace the line
130 vim.api.nvim_set_current_line(new_line)
131
132 -- Adjust cursor position (move it after the inserted characters)
133 local new_col = col_num + 2 -- Account for the added '{[' characters
134 vim.api.nvim_win_set_cursor(0, { line_num, new_col - 1 }) -- Convert back to 0-indexed
135 else
136 print("No quotes found at cursor position")
137 end
138 end, {
139 desc = "Wrap double quotes at cursor with {[]}",
140 })
141
142 -- require("mini.pairs").setup({
143 -- -- In which modes mappings from this `config` should be created
144 -- modes = { insert = true, command = false, terminal = false },
145 --
146 -- -- Global mappings. Each right hand side should be a pair information, a
147 -- -- table with at least these fields (see more in |MiniPairs.map|):
148 -- -- - <action> - one of 'open', 'close', 'closeopen'.
149 -- -- - <pair> - two character string for pair to be used.
150 -- -- By default pair is not inserted after `\`, quotes are not recognized by
151 -- -- `<CR>`, `'` does not insert pair after a letter.
152 -- -- Only parts of tables can be tweaked (others will use these defaults).
153 -- mappings = {
154 -- ["("] = { action = "open", pair = "()", neigh_pattern = "[^\\]." },
155 -- ["["] = { action = "open", pair = "[]", neigh_pattern = "[^\\]." },
156 -- ["{"] = { action = "open", pair = "{}", neigh_pattern = "[^\\]." },
157 -- ["<"] = { action = "open", pair = "<>", neigh_pattern = "[^\\]." },
158 --
159 -- [")"] = { action = "close", pair = "()", neigh_pattern = "[^\\]." },
160 -- ["]"] = { action = "close", pair = "[]", neigh_pattern = "[^\\]." },
161 -- ["}"] = { action = "close", pair = "{}", neigh_pattern = "[^\\]." },
162 -- [">"] = { action = "close", pair = "<>", neigh_pattern = "[^\\]." },
163 --
164 -- ['"'] = { action = "closeopen", pair = '""', neigh_pattern = "[^\\].", register = { cr = false } },
165 -- ["'"] = { action = "closeopen", pair = "''", neigh_pattern = "[^%a\\].", register = { cr = false } },
166 -- ["`"] = { action = "closeopen", pair = "``", neigh_pattern = "[^\\].", register = { cr = false } },
167 -- },
168 -- })
169
170 require("mini.comment").setup({
171 -- Options which control module behavior
172 options = {
173 -- Function to compute custom 'commentstring' (optional)
174 custom_commentstring = nil,
175
176 -- Whether to ignore blank lines when commenting
177 ignore_blank_line = false,
178
179 -- Whether to recognize as comment only lines without indent
180 start_of_line = false,
181
182 -- Whether to force single space inner padding for comment parts
183 pad_comment_parts = true,
184 },
185
186 -- Module mappings. Use `''` (empty string) to disable one.
187 mappings = {
188 -- Toggle comment (like `gcip` - comment inner paragraph) for both
189 -- Normal and Visual modes
190 comment = "gc",
191
192 -- Toggle comment on current line
193 comment_line = "gcc",
194
195 -- Toggle comment on visual selection
196 comment_visual = "gc",
197
198 -- Define 'comment' textobject (like `dgc` - delete whole comment block)
199 -- Works also in Visual mode if mapping differs from `comment_visual`
200 textobject = "gc",
201 },
202
203 -- Hook functions to be executed at certain stage of commenting
204 hooks = {
205 -- Before successful commenting. Does nothing by default.
206 pre = function() end,
207 -- After successful commenting. Does nothing by default.
208 post = function() end,
209 },
210 })
211
212 local miniclue = require("mini.clue")
213 miniclue.setup({
214 triggers = {
215 -- Leader triggers
216 { mode = "n", keys = "<Leader>" },
217 { mode = "x", keys = "<Leader>" },
218
219 -- Built-in completion
220 { mode = "i", keys = "<C-x>" },
221
222 -- `g` key
223 { mode = "n", keys = "g" },
224 { mode = "x", keys = "g" },
225
226 -- Marks
227 { mode = "n", keys = "'" },
228 { mode = "n", keys = "`" },
229 { mode = "x", keys = "'" },
230 { mode = "x", keys = "`" },
231
232 -- Registers
233 { mode = "n", keys = '"' },
234 { mode = "x", keys = '"' },
235 { mode = "i", keys = "<C-r>" },
236 { mode = "c", keys = "<C-r>" },
237
238 -- Window commands
239 { mode = "n", keys = "<C-w>" },
240
241 -- `z` key
242 { mode = "n", keys = "z" },
243 { mode = "x", keys = "z" },
244 },
245
246 clues = {
247 -- Enhance this by adding descriptions for <Leader> mapping groups
248 miniclue.gen_clues.builtin_completion(),
249 miniclue.gen_clues.g(),
250 miniclue.gen_clues.marks(),
251 miniclue.gen_clues.registers(),
252 miniclue.gen_clues.windows(),
253 miniclue.gen_clues.z(),
254 },
255 })
256
257 -- local starter = require("mini.starter")
258 -- starter.setup({
259 -- evaluate_single = true,
260 -- header = "hi",
261 -- items = {
262 -- starter.sections.builtin_actions(),
263 -- starter.sections.telescope(),
264 -- starter.sections.sessions(5, true),
265 -- },
266 -- })
267
268 -- local sessions = require("mini.sessions")
269 -- sessions.setup({
270 -- autoread = true,
271 -- })
272
273 require("mini.move").setup({
274 -- Module mappings. Use `''` (empty string) to disable one.
275 mappings = {
276 -- Move visual selection in Visual mode. Defaults are Alt (Meta) + hjkl.
277 left = "<C-S-Left>",
278 right = "<C-S-Right>",
279 down = "<C-S-Down>",
280 up = "<C-S-Up>",
281
282 -- Move current line in Normal mode
283 line_left = "<C-S-Left>",
284 line_right = "<C-S-Right>",
285 line_down = "<C-S-Down>",
286 line_up = "<C-S-Up>",
287 },
288
289 -- Options which control moving behavior
290 options = {
291 -- Automatically reindent selection during linewise vertical move
292 reindent_linewise = true,
293 },
294 })
295
296 require("mini.icons").setup({
297 extension = {
298 ["spec.ts"] = { glyph = "", hl = "MiniIconsAzure" },
299 ["test.ts"] = { glyph = "", hl = "MiniIconsAzure" },
300 ["spec.svelte.ts"] = { glyph = "", hl = "MiniIconsAzure" },
301 ["test.svelte.ts"] = { glyph = "", hl = "MiniIconsAzure" },
302 ["svelte.ts"] = { glyph = "", hl = "MiniIconsAzure" },
303 },
304 })
305
306 require("mini.files").setup({
307 -- Customization of shown content
308 content = {
309 -- Predicate for which file system entries to show
310 filter = nil,
311 -- What prefix to show to the left of file system entry
312 prefix = nil,
313 -- In which order to show file system entries
314 sort = nil,
315 },
316 -- Module mappings created only inside explorer.
317 -- Use `''` (empty string) to not create one.
318 mappings = {
319 close = "q",
320 go_in = "<Right>",
321 go_in_plus = "L",
322 go_out = "<Left>",
323 go_out_plus = "H",
324 mark_goto = "'",
325 mark_set = "m",
326 reset = "<BS>",
327 reveal_cwd = "@",
328 show_help = "g?",
329 synchronize = "=",
330 trim_left = "<",
331 trim_right = ">",
332 },
333 -- General options
334 options = {
335 -- Whether to delete permanently or move into module-specific trash
336 permanent_delete = true,
337 -- Whether to use for editing directories
338 use_as_default_explorer = false,
339 },
340 -- Customization of explorer windows
341 windows = {
342 -- Maximum number of windows to show side by side
343 max_number = math.huge,
344 -- Whether to show preview of file/directory under cursor
345 preview = false,
346 -- Width of focused window
347 width_focus = 50,
348 -- Width of other windows
349 width_nofocus = 15,
350 },
351 })
352
353 vim.api.nvim_create_autocmd("User", {
354 pattern = "MiniFilesActionRename",
355 callback = function(event)
356 Snacks.rename.on_rename_file(event.data.from, event.data.to)
357 end,
358 })
359
360 -- local MiniPick = require("mini.pick")
361 -- MiniPick.setup({
362 -- -- Delays (in ms; should be at least 1)
363 -- delay = {
364 -- -- Delay between forcing asynchronous behavior
365 -- async = 10,
366 --
367 -- -- Delay between computation start and visual feedback about it
368 -- busy = 50,
369 -- },
370 --
371 -- -- Keys for performing actions. See `:h MiniPick-actions`.
372 -- mappings = {
373 -- caret_left = "<Left>",
374 -- caret_right = "<Right>",
375 --
376 -- choose = "<CR>",
377 -- choose_in_split = "<C-s>",
378 -- choose_in_tabpage = "<C-t>",
379 -- choose_in_vsplit = "<C-v>",
380 -- choose_marked = "<M-CR>",
381 --
382 -- delete_char = "<BS>",
383 -- delete_char_right = "<Del>",
384 -- delete_left = "<C-u>",
385 -- delete_word = "<C-w>",
386 --
387 -- mark = "<C-x>",
388 -- mark_all = "<C-a>",
389 --
390 -- move_down = "<C-n>",
391 -- move_start = "<C-g>",
392 -- move_up = "<C-p>",
393 --
394 -- paste = "<C-r>",
395 --
396 -- refine = "<C-Space>",
397 -- refine_marked = "<M-Space>",
398 --
399 -- scroll_down = "<C-f>",
400 -- scroll_left = "<C-h>",
401 -- scroll_right = "<C-l>",
402 -- scroll_up = "<C-b>",
403 --
404 -- stop = "<Esc>",
405 --
406 -- toggle_info = "<S-Tab>",
407 -- toggle_preview = "<Tab>",
408 -- },
409 --
410 -- -- General options
411 -- options = {
412 -- -- Whether to show content from bottom to top
413 -- content_from_bottom = false,
414 --
415 -- -- Whether to cache matches (more speed and memory on repeated prompts)
416 -- use_cache = false,
417 -- },
418 --
419 -- -- Source definition. See `:h MiniPick-source`.
420 -- source = {
421 -- items = nil,
422 -- name = nil,
423 -- cwd = nil,
424 --
425 -- match = nil,
426 -- show = nil,
427 -- preview = nil,
428 --
429 -- choose = nil,
430 -- choose_marked = nil,
431 -- },
432 --
433 -- -- Window related options
434 -- window = {
435 -- -- Float window config (table or callable returning it)
436 -- config = nil,
437 --
438 -- -- String to use as caret in prompt
439 -- prompt_caret = "▏",
440 --
441 -- -- String to use as prefix in prompt
442 -- prompt_prefix = "> ",
443 -- },
444 -- })
445 --
446 -- vim.keymap.set("n", "<leader>pf", function()
447 -- MiniPick.builtin.files({ tool = "git" })
448 -- end, { desc = "Find [F]iles" })
449 end,
450}