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 configuring tree traversal start location #27

Closed JoosepAlviste closed 2 years ago

JoosepAlviste commented 2 years ago

Original issue / problem: https://github.com/numToStr/Comment.nvim/issues/10#issuecomment-945556118

Add a way to customize the location where the treesitter tree traversal is started (currently only on the first non-blank char on the cursor's line). This would make it possible to comment something like this in JSX when running gciW:

<View /* style={styles.foobar} */ />

I think that it would make sense if update_commentstring would accept the position as an argument. If nothing passed in, then the cursor start of line, but if there is some location passed in, then we can use that one. For example, the Comment.nvim integration can use getpos("'<") to get the visual selection start location instead of the cursor location. Or if there's no visual selection, then for the above example use the cursor location (or motion start location somehow?).