JoosepAlviste / nvim-ts-context-commentstring

Neovim treesitter plugin for setting the commentstring based on the cursor location in a file.
MIT License
1.14k stars 34 forks source link

Allow customizing tree traversal start location #28

Closed JoosepAlviste closed 2 years ago

JoosepAlviste commented 2 years ago

Make it possible to configure where the commentstring detection logic starts in the treesitter AST. The default is to start at the start of the cursor's line (first non-blank character). However, this is not 100% correct when commenting with motions.

update_commentstring now accepts a location where to start the analysis so that when integrating with a commenting plugin, more granular control is possible.

Additionally, a few useful helper functions are exported from ts_context_commentstring.utils which make it simpler to pass in a location.

Resolves #27