aboutsummaryrefslogtreecommitdiffhomepage
path: root/vim/mini.lua
diff options
context:
space:
mode:
Diffstat (limited to 'vim/mini.lua')
-rw-r--r--vim/mini.lua306
1 files changed, 276 insertions, 30 deletions
diff --git a/vim/mini.lua b/vim/mini.lua
index 1f4ee45..2646ca6 100644
--- a/vim/mini.lua
+++ b/vim/mini.lua
@@ -1,10 +1,15 @@
1-- vim: foldmethod=marker foldmarker={{{,}}} 1-- vim: sw=2 foldmethod=marker foldmarker={{{,}}}
2
3-- Ref: https://github.com/echasnovski/mini.nvim?tab=readme-ov-file
4-- TODO
5
6-- Install mini.nvim {{{
2 7
3-- Install mini.nvim -{{{
4-- Put this at the top of 'init.lua' 8-- Put this at the top of 'init.lua'
5local path_package = vim.fn.stdpath('data') .. '/site' 9local path_package = vim.fn.stdpath('data') .. '/site'
6vim.o.packpath=path_package 10vim.o.packpath = path_package
7local mini_path = path_package .. '/pack/deps/start/mini.nvim' 11local mini_path = path_package .. '/pack/deps/start/mini.nvim'
12
8if not vim.loop.fs_stat(mini_path) then 13if not vim.loop.fs_stat(mini_path) then
9 vim.cmd('echo "Installing `mini.nvim`" | redraw') 14 vim.cmd('echo "Installing `mini.nvim`" | redraw')
10 local clone_cmd = { 15 local clone_cmd = {
@@ -16,8 +21,27 @@ if not vim.loop.fs_stat(mini_path) then
16 vim.fn.system(clone_cmd) 21 vim.fn.system(clone_cmd)
17 vim.cmd('packadd mini.nvim | helptags ALL') 22 vim.cmd('packadd mini.nvim | helptags ALL')
18end 23end
24
25-- }}}
26-- mini.deps {{{
27require('mini.deps').setup({
28 path = { package = path_package }
29})
30add, now, later = MiniDeps.add, MiniDeps.now, MiniDeps.later
31-- }}}
32-- Disabled: mini.bufremote {{{
33add('echasnovski/mini.bufremove')
34vim.g.bufremove_disable = true
35--}}}
36-- Disabled: mini.animate --{{{
37add('echasnovski/mini.animate')
38vim.g.animate_disable = true
39-- }}}
40-- mini.basics {{{
41require('mini.basics').setup()
19-- }}} 42-- }}}
20require('mini.base16').setup({ --{{{ 43-- mini.base16 {{{
44require('mini.base16').setup({
21 palette = { 45 palette = {
22 -- Default Background 46 -- Default Background
23 base00 = "#2d2a2e", 47 base00 = "#2d2a2e",
@@ -54,10 +78,15 @@ require('mini.base16').setup({ --{{{
54 }, 78 },
55 use_cterm = true, 79 use_cterm = true,
56}) --}}} 80}) --}}}
57require('mini.misc').setup({ --{{{ 81-- mini.misc {{{
82require('mini.misc').setup({
58 make_global = { 'put', 'put_text', 'zoom'} 83 make_global = { 'put', 'put_text', 'zoom'}
59}) --}}} 84}) --}}}
60require('mini.statusline').setup({--{{{ 85-- mini.icons {{{
86require('mini.icons').setup({
87}) --}}}
88-- mini.statusline {{{
89require('mini.statusline').setup({
61 content = { 90 content = {
62 active = status_config 91 active = status_config
63 }, 92 },
@@ -84,27 +113,21 @@ function status_config()
84 local location = MiniStatusline.section_location({ trunc_width = 75 }) 113 local location = MiniStatusline.section_location({ trunc_width = 75 })
85 114
86 return MiniStatusline.combine_groups({ 115 return MiniStatusline.combine_groups({
87 { hl = mode_hl, strings = { mode } }, 116 { hl = mode_hl, strings = { mode } },
88 { hl = 'MiniStatuslineDevinfo', strings = { git, diagnostics['s'] } }, 117 { hl = 'MiniStatuslineDevinfo', strings = { git, diagnostics['s'] } },
89 { hl = 'MiniStatuslineError', strings = { diagnostics['e'] } }, 118 { hl = 'MiniStatuslineError', strings = { diagnostics['e'] } },
90 { hl = 'MiniStatuslineWarning', strings = { diagnostics['w'] } }, 119 { hl = 'MiniStatuslineWarning', strings = { diagnostics['w'] } },
91 { hl = 'MiniStatuslineInfo', strings = { diagnostics['i'] } }, 120 { hl = 'MiniStatuslineInfo', strings = { diagnostics['i'] } },
92 { hl = 'MiniStatuslineHint', strings = { diagnostics['h'] } }, 121 { hl = 'MiniStatuslineHint', strings = { diagnostics['h'] } },
93 '%<', -- Mark general truncate point 122 '%<', -- Mark general truncate point
94 { hl = 'MiniStatuslineFilename', strings = { filename } }, 123 { hl = 'MiniStatuslineFilename', strings = { filename } },
95 '%=', -- End left alignment 124 '%=', -- End left alignment
96 { hl = 'MiniStatuslineFileinfo', strings = { fileinfo } }, 125 { hl = 'MiniStatuslineFileinfo', strings = { fileinfo } },
97 { hl = mode_hl, strings = { location } }, 126 { hl = mode_hl, strings = { location } },
98 }) 127 })
99end 128end
100-- }}} 129-- }}}
101require('mini.animate').setup()--{{{ 130-- mini.clue {{{
102-- }}}
103require('mini.basics').setup()--{{{
104-- }}}
105-- require('mini.bufremove').setup() --{{{
106--}}}
107require('mini.clue') --{{{
108local miniclue = require('mini.clue') 131local miniclue = require('mini.clue')
109miniclue.setup({ 132miniclue.setup({
110 triggers = { 133 triggers = {
@@ -149,10 +172,12 @@ miniclue.setup({
149 miniclue.gen_clues.z(), 172 miniclue.gen_clues.z(),
150 }, 173 },
151})-- }}} 174})-- }}}
152require('mini.colors').setup()-- {{{ 175-- mini.colors {{{
176require('mini.colors').setup()
153-- }}} 177-- }}}
154require('mini.comment').setup({-- {{{ 178-- mini.comment {{{
155 -- Module mappings. Use `''` (empty string) to disable one. 179require('mini.comment').setup({
180 -- Module mappings. Use `''` (empty string) to disable one.
156 mappings = { 181 mappings = {
157 -- Toggle comment (like `gcip` - comment inner paragraph) for both 182 -- Toggle comment (like `gcip` - comment inner paragraph) for both
158 -- Normal and Visual modes 183 -- Normal and Visual modes
@@ -169,9 +194,230 @@ require('mini.comment').setup({-- {{{
169 textobject = 'gc', 194 textobject = 'gc',
170 }, 195 },
171})-- }}} 196})-- }}}
172require('mini.cursorword').setup()-- {{{ 197-- mini.cursorword {{{
198require('mini.cursorword').setup()
199-- }}}
200-- mini.diff {{{
201require('mini.diff').setup({
202 -- Options for how hunks are visualized
203 view = {
204 -- Visualization style. Possible values are 'sign' and 'number'.
205 -- Default: 'number' if line numbers are enabled, 'sign' otherwise.
206 style = 'sign',
207
208 -- Signs used for hunks with 'sign' view
209 signs = { add = '+', change = '▒', delete = '-' },
210
211 -- Priority of used visualization extmarks
212 priority = 199,
213 },
214})
215-- }}}
216-- mini.extra {{{
217require('mini.extra').setup()
218-- }}}
219-- mini.map {{{
220require('mini.map').setup()
221-- }}}
222-- mini.tabline {{{
223
224require('mini.tabline').setup()
225
226for i = 1, 9, 1 do
227 vim.keymap.set("n", string.format("<A-%s>", i), function()
228 vim.api.nvim_set_current_buf(vim.t.bufs[i])
229 end)
230end
231
173-- }}} 232-- }}}
174require('mini.cursorword').setup()-- {{{ 233-- mini.visits {{{
234require('mini.visits').setup()
175-- }}} 235-- }}}
176require('mini.diff').setup()-- {{{ 236-- mini.completion {{{
237require('mini.completion').setup()
177-- }}} 238-- }}}
239-- Telescope {{{
240add({
241 source = "nvim-telescope/telescope.nvim",
242 depends = {
243 'nvim-lua/plenary.nvim',
244 },
245 hooks = { post_checkout = function() end },
246})
247-- add({
248-- source = 'nvim-telescope/telescope-fzf-native.nvim',
249-- hooks = { post_checkout = function()
250-- vim.fn.system('make')
251-- end },
252-- })
253-- config {{{
254require('telescope').setup({
255 defaults = {-- {{{
256 mappings = {
257 i = {
258 -- ["<c-j>"] = "move_selection_next",
259 -- ["<c-k>"] = "move_selection_previous",
260 ["<C-o>"] = require("telescope.actions.layout").toggle_preview,
261 ["<C-u>"] = false,
262 ["<C-q>"] = function(p_bufnr)
263 require("telescope.actions").send_selected_to_qflist(p_bufnr)
264 vim.cmd.cfdo("edit")
265 end,
266 },
267 },
268 layout_config = {
269 horizontal = {
270 prompt_position = "bottom",
271 },
272 vertical = { height = 0.8 },
273 -- other layout configuration here
274 preview_cutoff = 0,
275 },
276 file_ignore_patterns = {
277 "node_modules"
278 },
279},-- }}}
280pickers = {-- {{{
281buffers = {
282 show_all_buffers = true,
283 sort_lastused = true,
284 theme = "dropdown",
285 previewer = false,
286 mappings = {
287 i = {
288 ["<c-d>"] = "delete_buffer",
289 },
290 n = {
291 ["<c-d>"] = "delete_buffer",
292 }
293 },
294},
295},-- }}}
296extensions = {
297 fzf = {
298 fuzzy = true, -- false will only do exact matching
299 override_generic_sorter = true, -- override the generic sorter
300 override_file_sorter = true, -- override the file sorter
301 case_mode = "smart_case", -- or "ignore_case" or "respect_case"
302 -- the default case_mode is "smart_case"
303 },
304 aerial = {
305 -- Display symbols as <root>.<parent>.<symbol>
306 show_nesting = {
307 ["_"] = false, -- This key will be the default
308 json = true, -- You can set the option for specific filetypes
309 yaml = true,
310 },
311 },
312},
313})
314-- }}}
315-- require("telescope").load_extension("fzf")
316-- require("telescope").load_extension("aerial")
317
318-- Keymaps {{{
319vim.keymap.set("n", "<leader>f", "<cmd>Telescope oldfiles<CR>", { desc = "telescope find oldfiles" })
320vim.keymap.set("n", "<leader>b", "<cmd>Telescope buffers<CR>", { desc = "telescope find buffers" })
321vim.keymap.set("n", "//", "<cmd>Telescope current_buffer_fuzzy_find<CR>", { desc = "telescope find in current buffer" })
322vim.keymap.set("n", "<leader>sf", "<cmd>Telescope find_files<cr>", { desc = "telescope find files" })
323vim.keymap.set(
324"n",
325"<leader>sF",
326"<cmd>Telescope find_files follow=true no_ignore=true hidden=true<CR>",
327{ desc = "telescope find all files" }
328)
329vim.keymap.set("n", "<leader>sg", "<cmd>Telescope live_grep<CR>", { desc = "telescope live grep" })
330vim.keymap.set("n", "<leader>gf", "<cmd>Telescope git_files<CR>", { desc = "telescope git files" })
331vim.keymap.set("n", "<leader>sH", "<cmd>Telescope help_tags<CR>", { desc = "telescope help page" })
332vim.keymap.set("n", "<leader>sm", "<cmd>Telescope marks<CR>", { desc = "telescope marks" })
333vim.keymap.set("n", "<leader>sj", "<cmd>Telescope jumplist<CR>", { desc = "telescope marks" })
334vim.keymap.set("n", "<leader>tt", "<cmd>Telescope<CR>", { desc = "telescope help page" })
335vim.keymap.set("n", "<leader>sk", "<cmd>Telescope keymaps<CR>", { desc = "telescope keymaps" })
336vim.keymap.set("n", "<leader>pt", "<cmd>Telescope terms<CR>", { desc = "telescope pick hidden term" })
337
338vim.keymap.set("n", "<leader>ss", function()
339 local current_filetype = vim.bo.filetype
340 local cwd = os.getenv("HOME") .. "/snippets"
341 require("telescope.builtin").find_files({
342 prompt_title = "Press <C-T> to edit a snippet",
343 default_text = current_filetype == "" and "" or current_filetype .. "_",
344 cwd = cwd,
345 attach_mappings = function(prompt_bufnr, map)
346 local get_prompt_or_entry = function()
347 local file_list = require("telescope.actions.state").get_selected_entry()
348 if file_list then
349 return file_list[1]
350 else
351 local current_picker = require("telescope.actions.state").get_current_picker(prompt_bufnr)
352 return current_picker:_get_prompt()
353 end
354 end
355
356 local edit_snippet = function()
357 local file = get_prompt_or_entry()
358 require("telescope.actions").close(prompt_bufnr)
359 local prefix_filetype = string.match(file, "([^_]+)")
360 vim.cmd(":vs")
361 vim.cmd(":e " .. cwd .. "/" .. file)
362 vim.bo.filetype = prefix_filetype
363 vim.bo.bufhidden = "wipe"
364 vim.cmd("set filetype?")
365 end
366
367 local insert_selected_snippet = function()
368 local file = get_prompt_or_entry()
369 local path = cwd .. "/" .. file
370 if vim.fn.filereadable(path) ~= 0 then
371 local snippet_content = vim.fn.readfile(path)
372 require("telescope.actions").close(prompt_bufnr)
373 vim.fn.setreg('"', snippet_content)
374 print("Snippet saved to register")
375 else
376 edit_snippet()
377 end
378 end
379
380 map("i", "<CR>", insert_selected_snippet)
381 map("i", "<C-T>", edit_snippet)
382 map("n", "<CR>", insert_selected_snippet)
383
384 return true
385 end,
386 })
387end, { desc = "[S]earch [S]nippets" })
388
389vim.keymap.set("n", "<leader>sd", function()
390 require("telescope.builtin").oldfiles({
391 prompt_title = "CD to",
392 attach_mappings = function(prompt_bufnr, map)
393 local cd_prompt = function()
394 local file = require("telescope.actions.state").get_selected_entry()[1]
395 local path = string.match(file, "(.*[/\\])")
396 require("telescope.actions").close(prompt_bufnr)
397 vim.api.nvim_feedkeys(":cd " .. path, "n", true)
398 end
399
400 map("i", "<CR>", cd_prompt)
401 map("n", "<CR>", cd_prompt)
402
403 return true
404 end,
405 })
406end, { desc = "Search Directory" })-- }}}
407
408-- }}}
409-- toggleterm {{{
410
411add({
412 source = "akinsho/toggleterm.nvim",
413 hooks = { post_checkout = function() end },
414})
415require("toggleterm").setup{
416 persist_size = false,
417 direction = 'float',
418}
419
420vim.keymap.set({ "n", "t" }, "<A-i>", function() vim.cmd("ToggleTerm direction=float") end, { desc = "terminal toggle floating term" })
421vim.keymap.set({ "n", "t" }, "<A-v>", function() vim.cmd("ToggleTerm direction=horizontal") end, { desc = "terminal toggle floating term" })
422
423--}}}