summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/custom/plugins/motions.lua
blob: f36e735908304bc73d35fb237843ab14238da599 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
return {
    {
        'christoomey/vim-tmux-navigator',
        config = function()
            vim.keymap.set('n', 'C-h', ':TmuxNavigatorLeft<CR>')
            vim.keymap.set('n', 'C-j', ':TmuxNavigatorDown<CR>')
            vim.keymap.set('n', 'C-k', ':TmuxNavigatorUp<CR>')
            vim.keymap.set('n', 'C-l', ':TmuxNavigatorRight<CR>')
        end,
    },
    {
        'ggandor/leap.nvim',
        dependencies = { 'tpope/vim-repeat' },
        config = function()
            -- vim.keymap.set({ 'n', 'x', 'o' }, 's', '<Plug>(leap-forward)')
            -- vim.keymap.set({ 'n', 'x', 'o' }, 'S', '<Plug>(leap-backward)')
            -- vim.keymap.set({ 'n', 'x', 'o' }, 'gs', '<Plug>(leap-from-window)')

            vim.keymap.set('n', 's', '<Plug>(leap)')
            vim.keymap.set('n', 'S', '<Plug>(leap-from-window)')
            vim.keymap.set({ 'x', 'o' }, 's', '<Plug>(leap-forward)')
            vim.keymap.set({ 'x', 'o' }, 'S', '<Plug>(leap-backward)')

            -- 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',
        opts = {
            padding = true,
            ignore = nil,

            toggler = { line = 'gcc', block = 'gbc' },
            opleader = { line = 'gc', block = 'gb' },
            extra = { above = 'gcO', below = 'gco', eol = 'gcA' },

            mappings = {
                basic = true,  -- `gcc` `gbc` `gc[count]{motion}` `gb[count]{motion}`
                extra = false, -- `gco`, `gcO`, `gcA`
            },
        },
        config = function()
            local api = require('Comment.api')
            local esc = vim.api.nvim_replace_termcodes('<ESC>', true, false, true)
            local toggole_linewise_selection = function()
                vim.api.nvim_feedkeys(esc, 'nx', false)
                api.toggle.linewise(vim.fn.visualmode())
            end

            -- <C-_> means Ctrl slash, `_` is a `/`
            vim.keymap.set('n', '<C-_>', api.toggle.linewise.current, { noremap = true, silent = true })
            vim.keymap.set('v', '<C-_>', toggole_linewise_selection, { noremap = true, silent = true })
        end,
    },
    {
        'kylechui/nvim-surround',
        version = '*',
        event = 'VeryLazy',
        config = function()
            require('nvim-surround').setup({})
            vim.keymap.set('v', '(', '<Plug>(nvim-surround-visual)(')
            vim.keymap.set('v', ')', '<Plug>(nvim-surround-visual))')
            vim.keymap.set('v', '{', '<Plug>(nvim-surround-visual){')
            vim.keymap.set('v', '}', '<Plug>(nvim-surround-visual)}')
            -- I still want to be able to do < and > for indentation
            -- vim.keymap.set('v', '<', '<Plug>(nvim-surround-visual)<')
            -- vim.keymap.set('v', '>', '<Plug>(nvim-surround-visual)>')
            vim.keymap.set('v', '[', '<Plug>(nvim-surround-visual)[')
            vim.keymap.set('v', ']', '<Plug>(nvim-surround-visual)]')
            vim.keymap.set('v', "'", "<Plug>(nvim-surround-visual)'")
            vim.keymap.set('v', '"', '<Plug>(nvim-surround-visual)"')
            vim.keymap.set('v', '`', '<Plug>(nvim-surround-visual)`')
        end,
    },
}