5 build = "make install_jsregexp", -- optional
7 { "honza/vim-snippets", },
10 local snippets = vim.fn.stdpath("config").."/snippets"
11 require("luasnip.loaders.from_snipmate").load({ paths = { snippets }})
12 require("luasnip.loaders.from_lua").load({ paths = { snippets }})
19 delete_check_events = "TextChanged",
20 store_selection_keys = "<Tab>",
24 { "echasnovski/mini.pairs",
27 modes = { insert = true, command = true, terminal = false },
28 -- skip autopair when next character is one of these
29 skip_next = [=[[%w%%%'%[%"%.%`%$]]=],
30 -- skip autopair when the cursor is inside these treesitter nodes
31 skip_ts = { "string" },
32 -- skip autopair when next character is closing pair
33 -- and there are more closing pairs than opening pairs
34 skip_unbalanced = true,
35 -- better deal with markdown code blocks
38 config = function(_, opts)
42 return not vim.g.minipairs_disable
45 vim.g.minipairs_disable = not state
49 local pairs = require("mini.pairs")
51 local open = pairs.open
52 --- Custom open command with extensions from LazyVim
53 ---@diagnostic disable-next-line: duplicate-set-field
54 pairs.open = function(pair, neigh_pattern)
55 if vim.fn.getcmdline() ~= "" then
56 return open(pair, neigh_pattern)
58 local o, c = pair:sub(1, 1), pair:sub(2, 2)
59 local line = vim.api.nvim_get_current_line()
60 local cursor = vim.api.nvim_win_get_cursor(0)
61 local next = line:sub(cursor[2] + 1, cursor[2] + 1)
62 local before = line:sub(1, cursor[2])
63 -- don't add fourth ` in markdown ```
64 if opts.markdown and o == "`" and vim.bo.filetype == "markdown" and before:match("^%s*``") then
65 return "`\n```" .. vim.api.nvim_replace_termcodes("<up>", true, true, true)
67 if opts.skip_next and next ~= "" and next:match(opts.skip_next) then
70 if opts.skip_ts and #opts.skip_ts > 0 then
71 local ok, captures = pcall(vim.treesitter.get_captures_at_pos, 0, cursor[1] - 1, math.max(cursor[2] - 1, 0))
72 for _, capture in ipairs(ok and captures or {}) do
73 if vim.tbl_contains(opts.skip_ts, capture.capture) then
78 if opts.skip_unbalanced and next == c and c ~= o then
79 local _, count_open = line:gsub(vim.pesc(pair:sub(1, 1)), "")
80 local _, count_close = line:gsub(vim.pesc(pair:sub(2, 2)), "")
81 if count_close > count_open then
85 return open(pair, neigh_pattern)
90 { "echasnovski/mini.surround",
92 -- HACK: use function to disable merging with LazyVim's keys definition
94 { "ys", desc = "Add surrounding", "n" },
95 { "S", desc = "Add surrounding", "x" },
96 { "ds", desc = "Delete surrounding" },
97 { "cs", desc = "Change surrounding" },
98 { "yss", "ys_", remap = true },
103 -- TODO: this is tpope/surround like, but should consider using vim-sandwich mappings
104 -- see: :h MiniSurround-vim-surround-config
114 config = function(_, opts)
115 require("mini.surround").setup(opts)
117 vim.keymap.del("x", "ys", { silent = true })
118 vim.keymap.set("x", "S", [[:<C-u>lua MiniSurround.add('visual')<CR>]], { silent = true })
122 { "echasnovski/mini.ai",
123 -- TODO: port vim text objects over
126 local ai = require("mini.ai")
129 custom_textobjects = {
130 o = ai.gen_spec.treesitter({ -- code block
131 a = { "@block.outer", "@conditional.outer", "@loop.outer" },
132 i = { "@block.inner", "@conditional.inner", "@loop.inner" },
134 f = ai.gen_spec.treesitter({ a = "@function.outer", i = "@function.inner" }), -- function
135 c = ai.gen_spec.treesitter({ a = "@class.outer", i = "@class.inner" }), -- class
136 t = { "<([%p%w]-)%f[^<%w][^<>]->.-</%1>", "^<.->().*()</[^/]->$" }, -- tags
137 d = { "%f[%d]%d+" }, -- digits
138 e = { -- Word with case
139 { "%u[%l%d]+%f[^%l%d]", "%f[%S][%l%d]+%f[^%l%d]", "%f[%P][%l%d]+%f[^%l%d]", "^[%l%d]+%f[^%l%d]" },
142 u = ai.gen_spec.function_call(), -- u for "Usage"
143 U = ai.gen_spec.function_call({ name_pattern = "[%w_]" }), -- without dot in function name
148 { "numToStr/Comment.nvim",
150 { "JoosepAlviste/nvim-ts-context-commentstring", -- nested language commenting (f.ex markdown code blocks)
151 opts = { enable_autocmd = false, },
154 opts = function(_, opts)
155 local tscci = require('ts_context_commentstring.integrations.comment_nvim')
156 vim.tbl_deep_extend('force', opts, {
165 pre_hook = tscci.create_pre_hook()
170 { "danymat/neogen", -- Generate annotations like doxygen
173 { "<leader>cn", function() require("neogen").generate() end, desc = "Generate Annotations (Neogen)", },
176 snippet_engine = "luasnip",
179 { "folke/lazydev.nvim",
184 { path = "${3rd}/luv/library", words = { "vim%.uv" } },
185 { path = "snacks.nvim", words = { "Snacks" } },
186 { path = "lazy.nvim", words = { "LazySpec" } },
190 { "gbprod/yanky.nvim", enabled = false, -- better yank/paste
192 -- I'm not entirely convinced, it doesn't provide functionality like vim-peekaboo,
193 -- maybe it can supplement it though?
194 -- Also, see issues on OSC52: https://github.com/gbprod/yanky.nvim/issues/213
196 desc = "Better Yank/Paste",
199 highlight = { timer = 150 },
204 function() vim.cmd([[YankyRingHistory]]) end,
206 desc = "Open Yank History",
209 { "y", "<Plug>(YankyYank)", mode = { "n", "x" }, desc = "Yank Text" },
210 { "p", "<Plug>(YankyPutAfter)", mode = { "n", "x" }, desc = "Put Text After Cursor" },
211 { "P", "<Plug>(YankyPutBefore)", mode = { "n", "x" }, desc = "Put Text Before Cursor" },
212 { "gp", "<Plug>(YankyGPutAfter)", mode = { "n", "x" }, desc = "Put Text After Selection" },
213 { "gP", "<Plug>(YankyGPutBefore)", mode = { "n", "x" }, desc = "Put Text Before Selection" },
214 { "[y", "<Plug>(YankyCycleForward)", desc = "Cycle Forward Through Yank History" },
215 { "]y", "<Plug>(YankyCycleBackward)", desc = "Cycle Backward Through Yank History" },
216 { "]p", "<Plug>(YankyPutIndentAfterLinewise)", desc = "Put Indented After Cursor (Linewise)" },
217 { "[p", "<Plug>(YankyPutIndentBeforeLinewise)", desc = "Put Indented Before Cursor (Linewise)" },
218 { "]P", "<Plug>(YankyPutIndentAfterLinewise)", desc = "Put Indented After Cursor (Linewise)" },
219 { "[P", "<Plug>(YankyPutIndentBeforeLinewise)", desc = "Put Indented Before Cursor (Linewise)" },
220 { ">p", "<Plug>(YankyPutIndentAfterShiftRight)", desc = "Put and Indent Right" },
221 { "<p", "<Plug>(YankyPutIndentAfterShiftLeft)", desc = "Put and Indent Left" },
222 { ">P", "<Plug>(YankyPutIndentBeforeShiftRight)", desc = "Put Before and Indent Right" },
223 { "<P", "<Plug>(YankyPutIndentBeforeShiftLeft)", desc = "Put Before and Indent Left" },
224 { "=p", "<Plug>(YankyPutAfterFilter)", desc = "Put After Applying a Filter" },
225 { "=P", "<Plug>(YankyPutBeforeFilter)", desc = "Put Before Applying a Filter" },
229 { "andrewferrier/debugprint.nvim",
230 dependencies = { "nvim-treesitter" },
231 -- TODO: setup debugprint (or maybe not)