nvim-treesitter / nvim-treesitter-textobjects

Apache License 2.0
2.11k stars 190 forks source link

(comment) for global. #204

Open singlexyz opened 2 years ago

singlexyz commented 2 years ago

I found that comments in most languages can be queried with (comment), Although only tested css, javascript, go, php, vue, I believe for comments, mostly the same (comment).

But now if want to add a query for (comment) for each language, you can only modify each file, which is tedious.

Is it possible to add a global filetype so that each language can apply the query inside.

图片
kiyoon commented 1 year ago

https://github.com/nvim-treesitter/nvim-treesitter-textobjects/blob/e0d2c72894db60001650b36357d3480f17e1c340/queries/javascript/textobjects.scm#L1

As you can see, javascript queries are inherited from other languages. Maybe you can use this to define sets of global queries and inherit them?