From 7c5176f172a7e723d435dab472ddba7b7d8d5de2 Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Sun, 21 Jul 2024 18:39:17 +0300 Subject: feat(neovim-utility): lazy loaded more plugins, moved motions to utility --- .config/nvim/lua/custom/plugins/utility.lua | 95 ++++++++++++++++++++++++++--- 1 file changed, 85 insertions(+), 10 deletions(-) (limited to '.config/nvim/lua') diff --git a/.config/nvim/lua/custom/plugins/utility.lua b/.config/nvim/lua/custom/plugins/utility.lua index 48c0baa..c6bb0a3 100644 --- a/.config/nvim/lua/custom/plugins/utility.lua +++ b/.config/nvim/lua/custom/plugins/utility.lua @@ -50,8 +50,8 @@ return { { 'nvim-pack/nvim-spectre', cmd = 'Spectre', config = true }, { 'echasnovski/mini.nvim', - lazy = true, version = false, + keys = {}, init = function() local function quit_buffer() if vim.bo.modified then @@ -65,26 +65,46 @@ return { { 'kylechui/nvim-surround', version = '*', - config = true, + lazy = false, + opts = { + keymaps = { + insert = false, + insert_line = false, + normal_line = false, + normal_cur_line = false, + visual_line = false, + normal = false, + normal_cur = false, + visual = false, + delete = false, + change = false, + -- normal = 'yS', + -- normal_cur = 'ySS', + -- visual = 'S', + -- delete = 'dS', + -- change = 'cW', + }, + }, keys = { { '(', '(nvim-surround-visual)(', mode = 'v' }, - { ')', '(nvim-surround-visual))', mode = 'v' }, { '{', '(nvim-surround-visual){', mode = 'v' }, - { '}', '(nvim-surround-visual)}', mode = 'v' }, { '[', '(nvim-surround-visual)[', mode = 'v' }, { '`', '(nvim-surround-visual)`', mode = 'v' }, - 'cs', - 'ds', - 'ys', + { '"', '(nvim-surround-visual)"', mode = 'v' }, + { "'", "(nvim-surround-visual)'", mode = 'v' }, + -- { 'yS', '(nvim-surround-normal)' }, + -- { 'ySS', '(nvim-surround-normal-cur)' }, + -- { 'S', '(nvim-surround-visual)', mode = 'v' }, + -- { 'cS', '{ nvim-surround-change }' }, + -- { 'dS', '(nvim-surround-delete)' }, }, }, { -- TODO: Make sure it uses a diff color -- the color rn is too similar to visual mode 'RRethy/vim-illuminate', - config = function() - vim.keymap.set('n', 'it', 'IlluminateToggle', { desc = '[I]lluminate [Tloggle]' }) - end, + event = 'BufEnter', + keys = { { 'it', 'IlluminateToggle', desc = '[I]lluminate [Tloggle]' } }, }, { 'lukas-reineke/indent-blankline.nvim', @@ -97,4 +117,59 @@ return { }, }, }, + { + 'christoomey/vim-tmux-navigator', + keys = { + { '', 'TmuxNavigateLeft' }, + { '', 'TmuxNavigateDown' }, + { '', 'TmuxNavigateUp' }, + { '', 'TmuxNavigateRight' }, + }, + }, + { + 'ggandor/leap.nvim', + dependencies = { 'tpope/vim-repeat' }, + keys = { + { 's', '(leap)', mode = { 'n', 'x', 'o' } }, + { 'S', '(leap-from-window)' }, + { + 'gs', + function() + require('leap.remote').action() + end, + }, + }, + config = function() + -- Define equivalence classes for brackets and quotes, in addition to + -- the default whitespace group. + require('leap').opts.equivalence_classes = { ' \t\r\n', '([{', ')]}', '\'"`' } + + -- Set background to gray in searchable area + vim.api.nvim_set_hl(0, 'LeapBackdrop', { fg = '#777777' }) + end, + }, + { + 'windwp/nvim-autopairs', + event = 'InsertEnter', + config = true, + }, + { + -- 'numToStr/Comment.nvim', + 'os-mey/Comment.nvim', + branch = 'fix-inline-visual-linewise-comment', + event = 'BufEnter', + config = function() + require('Comment').setup() + local api = require('Comment.api') + local esc = vim.api.nvim_replace_termcodes('', true, false, true) + local toggle_linewise_selection = function() + vim.api.nvim_feedkeys(esc, 'nx', false) + api.toggle.linewise(vim.fn.visualmode()) + end + + -- means Ctrl slash, `_` is a `/` + vim.keymap.set('n', '', api.toggle.linewise.current, { noremap = true, silent = true }) + vim.keymap.set('v', '', toggle_linewise_selection, { noremap = true, silent = true }) + end, + }, } -- cgit v1.3.1