@@ -57,13 +57,8 @@ plugin. `vim-commentary` provides the mappings for commenting which use the
5757` commentstring ` setting so that ` vim-commentary ` can do its thing even in more
5858complex filetypes.
5959
60- There is an additional integration with ` vim-commentary ` specifically, which
61- optimizes the ` commentstring ` updating logic so that it is not run
62- unnecessarily. If ` vim-commentary ` is detected, then this plugin automatically
63- sets up ` vim-commentary ` mappings to first update the ` commentstring ` , and then
64- trigger ` vim-commentary ` .
65-
66- Let me know if you'd like a similar integration for another commenting plugin.
60+ There are ways to make this plugin more efficient with some commenting plugins.
61+ See the [ Integrations] ( #integrations ) section for more information.
6762
6863
6964## Configuration
@@ -167,6 +162,53 @@ nnoremap <leader>c <cmd>lua require('ts_context_commentstring.internal').update_
167162` vim-commentary ` , the integration is set up automatically.
168163
169164
165+ ### Integrations
166+
167+ For some commenting plugins, it's possible to trigger the ` commentstring `
168+ calculation only when it is actually needed. Some commenting plugins require
169+ more configuration than others.
170+
171+ Let me know if you'd like to see more integrations for other commenting plugins.
172+ A PR is always appreciated :)
173+
174+
175+ #### [ ` vim-commentary ` ] ( https://github.com/tpope/vim-commentary/ )
176+
177+ There is an existing integration with ` vim-commentary ` , which triggers the
178+ ` commentstring ` updating logic only when needed (before commenting with ` gc ` ).
179+ If ` vim-commentary ` is detected, then this plugin automatically sets up
180+ ` vim-commentary ` mappings to first update the ` commentstring ` , and then trigger
181+ ` vim-commentary ` .
182+
183+
184+ #### [ ` kommentary ` ] ( https://github.com/b3nj5m1n/kommentary )
185+
186+ ` kommentary ` can also trigger the ` commentstring ` updating logic before
187+ commenting. However, it requires some configuration to set up.
188+
189+ First, disable the ` CursorHold ` autocommand of this plugin:
190+
191+ ``` lua
192+ require ' nvim-treesitter.configs' .setup {
193+ context_commentstring = {
194+ enable = true ,
195+ enable_autocmd = false ,
196+ }
197+ }
198+ ```
199+
200+ Then, configure ` kommentary ` to trigger the ` commentstring ` updating logic with
201+ its ` hook_function ` configuration:
202+
203+ ``` lua
204+ require (' kommentary.config' ).configure_language (' typescriptreact' , {
205+ hook_function = function ()
206+ require (' ts_context_commentstring.internal' ).update_commentstring ()
207+ end ,
208+ })
209+ ```
210+
211+
170212## More demos
171213
172214** React:**
0 commit comments