You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -224,14 +203,6 @@ These mappings are disabled by default. (config: `mappings.extended`)
224
203
`gbac` - Toggle comment around a class (w/ LSP/treesitter support)
225
204
```
226
205
227
-
<aid="api"></a>
228
-
229
-
### ⚙️ API
230
-
231
-
-[Plug Mappings](./doc/plugs.md) - Excellent for creating custom keybindings
232
-
233
-
-[Lua API](./doc/API.md) - Details the Lua API. Great for making custom comment function.
234
-
235
206
<aid="treesitter"></a>
236
207
237
208
### 🌳 Treesitter
@@ -254,12 +225,10 @@ There are two hook methods i.e `pre_hook` and `post_hook` which are called befor
254
225
255
226
<aid="pre-hook"></a>
256
227
257
-
-`pre_hook` - This method is called with a `ctx` (Read `comment.utils.CommentCtx`) argument before comment/uncomment is started. It can be used to return a custom `commentstring`which will be used for comment/uncomment the lines. You can use something like [nvim-ts-context-commentstring](https://github.com/JoosepAlviste/nvim-ts-context-commentstring) to compute the commentstring using treesitter.
228
+
-`pre_hook` - Called with a `ctx`argument (Read `:h comment.utils.CommentCtx`) before (un)comment. Can optionally return a `commentstring`to be used for (un)commenting. You can use [nvim-ts-context-commentstring](https://github.com/JoosepAlviste/nvim-ts-context-commentstring) to easily comment `tsx/jsx` files.
258
229
259
230
```lua
260
-
-- NOTE: The example below is a proper integration and it is RECOMMENDED.
261
231
{
262
-
---@paramctxCommentCtx
263
232
pre_hook=function(ctx)
264
233
-- Only calculate commentstring for tsx filetypes
265
234
ifvim.bo.filetype=='typescriptreact' then
@@ -285,13 +254,14 @@ There are two hook methods i.e `pre_hook` and `post_hook` which are called befor
-`post_hook` - This method is called after commenting is done. It receives the same `ctx` (Read `comment.utils.CommentCtx`) argument as [`pre_hook`](#pre_hook).
261
+
-`post_hook` - This method is called after (un)commenting. It receives the same `ctx` (Read `:h comment.utils.CommentCtx`) argument as [`pre_hook`](#pre_hook).
Most languages/filetypes have native support for comments via `commentstring` but there might be a filetype that is not supported. There are two ways to enable commenting for unsupported filetypes:
349
319
350
-
1. You can set `commentstring` for that particular filetype like the following
320
+
1. You can set `commentstring` for that particular filetype like the following. Read `:h commentstring` for more info.
351
321
352
322
```lua
353
323
vim.bo.commentstring='//%s'
@@ -356,8 +326,6 @@ vim.bo.commentstring = '//%s'
356
326
vim.api.nvim_command('set commentstring=//%s')
357
327
```
358
328
359
-
> Read `:h commentstring` for more help
360
-
361
329
<aid="ft-lua"></a>
362
330
363
331
2. You can also use this plugin interface to store both line and block commentstring for the filetype. You can treat this as a more powerful version of the `commentstring`. Read `:h comment.ft` for more info.
@@ -367,16 +335,14 @@ local ft = require('Comment.ft')
0 commit comments