local MiniAi = require('mini.ai') local MiniAlign = require('mini.align') local MiniComment = require('mini.comment') local MiniOperators = require('mini.operators') local MiniPairs = require('mini.pairs') local MiniSurround = require('mini.surround') -- comment actions MiniComment.setup() -- keymap: overrides default vim gc / gcc -- surround actions MiniSurround.setup({ custom_surroundings = { -- js template string ['$'] = { output = { left = '`${', right = '}`', }, }, }, }) -- keymap: -- sa (surround add) -- sr (surround replace) -- sd (surround delete) local spec_treesitter = require('mini.ai').gen_spec.treesitter MiniAi.setup({ -- only consider the current location search_method = 'cover', custom_textobjects = { ['.'] = spec_treesitter({ a = '@call.outer', i = '@call.inner', }), [','] = spec_treesitter({ a = '@parameter.outer', i = '@parameter.inner', }), }, }); -- align actions MiniAlign.setup() -- keymap: ga / gA -- Treesitter-aware split/join require('treesj').setup({ use_default_keymaps = false, }) vim.keymap.set('n', 's', 'TSJSplit') vim.keymap.set('n', 'j', 'TSJJoin') -- autopair brackets MiniPairs.setup({ mappings = { -- default config includes (, [ and { -- autopair <> if preceded by a character, otherwise it might be a regular -- comparison operation ['<'] = { action = 'open', pair = '<>', neigh_pattern = '%w.' }, ['>'] = { action = 'close', pair = '<>' }, }, }) -- extra operators MiniOperators.setup({ -- disable evaluate mapping evaluate = { prefix = '' }, -- custom mapping defined later replace = { prefix = '' }, -- other mappings -- gm - multiply -- gs - sort -- gx - exchange }) MiniOperators.make_mappings('replace', { textobject = 'cp', line = 'cpp', -- overrides default p mapping selection = 'p', }) local function toggle_end_char(char) local cursor = vim.api.nvim_win_get_cursor(0) local row = cursor[1] - 1 local end_char = vim.api.nvim_buf_get_text(0, row, -2, row, -1, {})[1] if end_char == char then vim.api.nvim_buf_set_text(0, row, -2, row, -1, {}) else vim.api.nvim_buf_set_text(0, row, -1, row, -1, { char }) end end -- add ,/; to end of line vim.keymap.set('i', '', function() toggle_end_char(',') end) vim.keymap.set('i', '', function() toggle_end_char(';') end)