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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
local K = vim.keymap.set
local call = require('Comment.api').call
---@mod comment.keybindings Keybindings
---@brief [[
---Comment.nvim provides default keybindings for (un)comment your code. These
---keybinds are enabled upon calling |commen.usage.setup| and can be configured
---or disabled, if desired.
---
---Basic: ~
---
--- *gc*
--- *gb*
--- *gc[count]{motion}*
--- *gb[count]{motion}*
---
--- Toggle comment on a region using linewise/blockwise comment. In 'NORMAL'
--- mode, it uses 'Operator-Pending' mode to listen for an operator/motion.
--- In 'VISUAL' mode it simply comment the selected region.
---
--- *gcc*
--- *gbc*
--- *[count]gcc*
--- *[count]gbc*
---
--- Toggle comment on the current line using linewise/blockwise comment. If
--- prefixed with a 'v:count' then it will comment over the number of lines
--- corresponding to the {count}. These are only available in 'NORMAL' mode.
---
---
---Extra: ~
---
--- *gco* - Inserts comment below and enters INSERT mode
--- *gcO* - Inserts comment above and enters INSERT mode
--- *gcA* - Inserts comment at the end of line and enters INSERT mode
---@brief ]]
---@mod comment.plugmap Plug Mappings
---@brief [[
---Comment.nvim provides <Plug> mappings for most commonly used actions. These
---are enabled by default and can be used to make custom keybindings. All plug
---mappings have support for dot-repeat except VISUAL mode keybindings. To create
---custom comment function, check out 'comment.api' section.
---
--- *<Plug>(comment_toggle_linewise)*
--- *<Plug>(comment_toggle_blockwise)*
---
--- Toggle comment on a region with linewise/blockwise comment in NORMAL mode.
--- using |Operator-Pending| mode (or |g@|) to get the region to comment.
--- These powers the |gc| and |gb| keybindings.
---
--- *<Plug>(comment_toggle_linewise_current)*
--- *<Plug>(comment_toggle_blockwise_current)*
---
--- Toggle comment on the current line with linewise/blockwise comment in
--- NORMAL mode. These powers the |gcc| and 'gbc' keybindings.
---
--- *<Plug>(comment_toggle_linewise_count)*
--- *<Plug>(comment_toggle_blockwise_count)*
---
--- Toggle comment on a region using 'v:count' with linewise/blockwise comment
--- in NORMAL mode. These powers the |[count]gcc| and |[count]gbc| keybindings.
---
--- *<Plug>(comment_toggle_linewise_visual)*
--- *<Plug>(comment_toggle_blockwise_visual)*
---
--- Toggle comment on the selected region with linewise/blockwise comment in
--- NORMAL mode. These powers the |{visual}gc| and |{visual}gb| keybindings.
---
---Usage: ~
--->lua
--- -- Toggle current line or with count
--- vim.keymap.set('n', 'gcc', function()
--- return vim.v.count == 0
--- and '<Plug>(comment_toggle_linewise_current)'
--- or '<Plug>(comment_toggle_linewise_count)'
--- end, { expr = true })
---
--- -- Toggle in Op-pending mode
--- vim.keymap.set('n', 'gc', '<Plug>(comment_toggle_linewise)')
---
--- -- Toggle in VISUAL mode
--- vim.keymap.set('x', 'gc', '<Plug>(comment_toggle_linewise_visual)')
---<
---@brief ]]
---@export plugs
-- Operator-Pending mappings
K(
'n',
'<Plug>(comment_toggle_linewise)',
call('toggle.linewise', 'g@'),
{ expr = true, desc = 'Comment toggle linewise' }
)
K(
'n',
'<Plug>(comment_toggle_blockwise)',
call('toggle.blockwise', 'g@'),
{ expr = true, desc = 'Comment toggle blockwise' }
)
-- Toggle mappings
K(
'n',
'<Plug>(comment_toggle_linewise_current)',
call('toggle.linewise.current', 'g@$'),
{ expr = true, desc = 'Comment toggle current line' }
)
K(
'n',
'<Plug>(comment_toggle_blockwise_current)',
call('toggle.blockwise.current', 'g@$'),
{ expr = true, desc = 'Comment toggle current block' }
)
-- Count mappings
K(
'n',
'<Plug>(comment_toggle_linewise_count)',
call('toggle.linewise.count_repeat', 'g@$'),
{ expr = true, desc = 'Comment toggle linewise with count' }
)
K(
'n',
'<Plug>(comment_toggle_blockwise_count)',
call('toggle.blockwise.count_repeat', 'g@$'),
{ expr = true, desc = 'Comment toggle blockwise with count' }
)
-- Visual-Mode mappings
K(
'x',
'<Plug>(comment_toggle_linewise_visual)',
'<ESC><CMD>lua require("Comment.api").locked("toggle.linewise")(vim.fn.visualmode())<CR>',
{ desc = 'Comment toggle linewise (visual)' }
)
K(
'x',
'<Plug>(comment_toggle_blockwise_visual)',
'<ESC><CMD>lua require("Comment.api").locked("toggle.blockwise")(vim.fn.visualmode())<CR>',
{ desc = 'Comment toggle blockwise (visual)' }
)
|