@@ -22,14 +22,14 @@ Core Lua API··································
22
22
Language/Filetype detection·········································| comment.ft |
23
23
Utilities························································| comment.utils |
24
24
Operator-mode API···············································| comment.opfunc |
25
- Insert API·······················································| comment.extra |
25
+ Extra API· ·······················································| comment.extra |
26
26
27
27
================================================================================
28
28
Introduction *comment-nvim*
29
29
30
30
Comment.nvim is a smart and powerful comment plugin for neovim. It supports
31
31
dot-repeat, counts, line ('//') and block ('/* */') comments, and can be used
32
- with motion and text-objects. It has native integration with tressitter to
32
+ with motion and text-objects. It has native integration with | tressitter | to
33
33
support embedded filetypes like html, vue, markdown with codeblocks etc.
34
34
35
35
*comment.dotrepeat*
@@ -58,6 +58,10 @@ filetype also exists in the |comment.ft| then the commenting will be done using
58
58
the string in | comment.ft | instead of using 'commentstring' . To override this
59
59
behavior, you have to manually return the 'commentstring' from 'pre_hook'.
60
60
61
+ *comment.sourcecode*
62
+ Comment.nvim is FOSS provided under MIT license. All the source code is avaiable
63
+ at https://github.com/numToStr/Comment.nvim
64
+
61
65
================================================================================
62
66
Usage *comment.usage*
63
67
@@ -80,6 +84,10 @@ C.setup({config?}) *comment.usage.setup*
80
84
81
85
Usage: ~
82
86
>
87
+ -- Use default configuration
88
+ require('Comment').setup()
89
+
90
+ -- or with custom configuration
83
91
require('Comment').setup({
84
92
ignore = '^$',
85
93
toggler = {
@@ -97,25 +105,64 @@ C.setup({config?}) *comment.usage.setup*
97
105
================================================================================
98
106
Configuration *comment.config*
99
107
108
+ *comment.config.defaults*
109
+ Following is the default config for the | comment.usage.setup | . If you want to
110
+ override, just modify the option that you want, then it will be merged with the
111
+ default config.
112
+
113
+ >
114
+ {
115
+ padding = true,
116
+ sticky = true,
117
+ ignore = nil,
118
+ toggler = {
119
+ line = 'gcc',
120
+ block = 'gbc',
121
+ },
122
+ opleader = {
123
+ line = 'gc',
124
+ block = 'gb',
125
+ },
126
+ extra = {
127
+ above = 'gcO',
128
+ below = 'gco',
129
+ eol = 'gcA',
130
+ },
131
+ mappings = {
132
+ basic = true,
133
+ extra = true,
134
+ extended = false,
135
+ },
136
+ pre_hook = nil,
137
+ post_hook = nil,
138
+ }
139
+ <
140
+
100
141
CommentConfig *comment.config.CommentConfig*
101
142
Plugin's configuration
102
143
103
144
Fields: ~
104
- {padding} (boolean) Controls space between the comment
105
- and the line (default: 'true' )
106
- {sticky} (boolean) Whether cursor should stay at the
107
- same position. Only works with NORMAL
108
- mode mappings (default: 'true' )
109
- {ignore} (string|fun():string) Lua pattern used to ignore lines
110
- during (un)comment (default: 'nil' )
111
- {mappings} (Mappings|boolean)
145
+ {padding} (boolean|fun():boolean) Controls space between the comment
146
+ and the line (default: 'true' )
147
+ {sticky} (boolean) Whether cursor should stay at the
148
+ same position. Only works in NORMAL
149
+ mode mappings (default: 'true' )
150
+ {ignore} (string|fun():string) Lua pattern used to ignore lines
151
+ during (un)comment (default: 'nil' )
152
+ {mappings} (Mappings| false) Enables | comment.keybindings|
153
+ NOTE: If given 'false' , then the
154
+ plugin won't create any mappings
112
155
{toggler} (Toggler)
113
156
{opleader} (Opleader)
114
157
{extra} (ExtraMapping)
115
- {pre_hook} (fun(ctx):string) Function to call before (un)comment
116
- (default: 'nil' )
117
- {post_hook} (fun(ctx)) Function to call after (un)comment
118
- (default: 'nil' )
158
+ {pre_hook} (fun(ctx):string) Function to call before (un)comment.
159
+ It is called with a {ctx} argument
160
+ of type | comment.utils.CommentCtx |
161
+ (default: 'nil' )
162
+ {post_hook} (fun(ctx)) Function to call after (un)comment.
163
+ It is called with a {ctx} argument
164
+ of type | comment.utils.CommentCtx |
165
+ (default: 'nil' )
119
166
120
167
121
168
Mappings *comment.config.Mappings*
@@ -287,8 +334,6 @@ api.toggle *comment.api.toggle*
287
334
api.toggle.blockwise.current(motion?, config?)
288
335
api.toggle.blockwise.count(count, config?)
289
336
290
- -- NORMAL mode
291
-
292
337
-- Toggle current line (linewise) using C-/
293
338
vim.keymap.set('n', '<C-_>', api.toggle.linewise.current)
294
339
@@ -309,19 +354,17 @@ api.toggle *comment.api.toggle*
309
354
{ expr = true }
310
355
)
311
356
312
- -- VISUAL mode
313
-
314
357
local esc = vim.api.nvim_replace_termcodes(
315
358
'<ESC>', true, false, true
316
359
)
317
360
318
- -- Linewise toggle (linewise)
361
+ -- Toggle selection (linewise)
319
362
vim.keymap.set('x', '<leader>c', function()
320
363
vim.api.nvim_feedkeys(esc, 'nx', false)
321
364
api.toggle.linewise(vim.fn.visualmode())
322
365
end)
323
366
324
- -- Blockwise toggle (blockwise)
367
+ -- Toggle selection (blockwise)
325
368
vim.keymap.set('x', '<leader>b', function()
326
369
vim.api.nvim_feedkeys(esc, 'nx', false)
327
370
api.toggle.blockwise(vim.fn.visualmode())
@@ -674,7 +717,7 @@ U.get_count_lines({count}) *comment.utils.get_count_lines*
674
717
{count} (integer) Probably 'vim.v.count'
675
718
676
719
Returns: ~
677
- {string[]} of lines
720
+ {string[]} List of lines
678
721
{CommentRange}
679
722
680
723
@@ -685,7 +728,7 @@ U.get_lines({range}) *comment.utils.get_lines*
685
728
{range} (CommentRange)
686
729
687
730
Returns: ~
688
- {string[]} of lines
731
+ {string[]} List of lines
689
732
690
733
691
734
U.unwrap_cstr({cstr} ) *comment.utils.unwrap_cstr*
@@ -843,7 +886,7 @@ Op.blockwise({param}, {partial?}) *comment.opfunc.blockwise*
843
886
844
887
845
888
================================================================================
846
- Insert API *comment.extra*
889
+ Extra API *comment.extra*
847
890
848
891
Underlying functions that powers the | comment.api.insert | lua API.
849
892
0 commit comments