Skip to content

Commit ef7bdab

Browse files
committed
Add Comment.nvim integration to the README
The new multiline comment configuration can be used.
1 parent dd79058 commit ef7bdab

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,35 @@ require("nvim_comment").setup({
264264
})
265265
```
266266

267+
#### [`Comment.nvim`](https://github.com/numToStr/Comment.nvim)
268+
269+
First, disable the `CursorHold` autocommand of this plugin:
270+
271+
```lua
272+
require'nvim-treesitter.configs'.setup {
273+
context_commentstring = {
274+
enable = true,
275+
enable_autocmd = false,
276+
}
277+
}
278+
```
279+
280+
Then, configure `Comment.nvim` to trigger the `commentstring` updating logic
281+
with its `pre_hook` configuration:
282+
283+
```lua
284+
require('Comment').setup {
285+
pre_hook = function(ctx)
286+
local U = require 'Comment.utils'
287+
local type = ctx.ctype == U.ctype.line and '__default' or '__multiline'
288+
return require('ts_context_commentstring.internal').calculate_commentstring {
289+
key = type,
290+
}
291+
end,
292+
}
293+
```
294+
295+
267296
## More demos
268297

269298
**React:**

0 commit comments

Comments
 (0)