Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

marker as node for the comment marker #16

Open
yochem opened this issue Mar 7, 2023 · 1 comment
Open

marker as node for the comment marker #16

yochem opened this issue Mar 7, 2023 · 1 comment

Comments

@yochem
Copy link

yochem commented Mar 7, 2023

Dear @stsewd,

Again thanks for this TS parser, I really like it.

I was working on providing text objects for V (nvim-treesitter/nvim-treesitter-textobjects#404), and wanted to implement @comment.inner, to delete the whole line comment, except the comment marker and leading space:

// this is a comment
// |

Where | denotes the cursor. Since neovim does not support quantifiers for nodes yet (nvim-treesitter/nvim-treesitter-textobjects#102 (comment)), it did not seem possible for us to also support e.g. /// documentation, i.e. any number of comment markers.

Then I thought about this parser, and thought it would be a good thing to have a marker node for comments. This would make cic (change inner comment) very easy to implement. I would also argue that the marker is an important node in the comment syntax, and different from the actual text of the comment.

The only problem would be that every language has a different comment marker. I don't know if it would be even possible for this parser to know what the comment marker would be. Maybe there is a way to find out? Or infer?

Let me know if this is something that would be possible. It would be really cool to have a comment marker node in the tree, especially for textobjects, but also for highlighting.

@stsewd
Copy link
Owner

stsewd commented Jun 4, 2023

Hi, sorry for the late reply (I had the feeling that I already replied to this, maybe I forgot to submit my reply :_)

As you already described, adding that will mean adding it for all languages and make it work for all. I think this can be solved by each language grammar by providing the tokens for the inner content of the comments and the symbols delimiting it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants