nvim-treesitter / playground

Treesitter playground integrated into Neovim
Apache License 2.0
896 stars 47 forks source link

Sibling nodes and quantifiers #3

Open vigoux opened 4 years ago

vigoux commented 4 years ago

Hey, I was playing a bit with the playground, it is really nice !

Though I encountered issues with the following query :

("function" @id "end" @id)
((comment)+ @doc . (function))
  1. Putting the cursor on the first @id does not do anything.
  2. Putting the cursor on @doc only highlights the very last comment before a function, while it should highlight the group of comments before the function.

By the way, the first match does not seem to be parsed correctly.

steelsojka commented 4 years ago

The first issue seems to be an issue with the grammar. The string is getting greedy. I'll fix that in the grammar. I'll check what matches we are getting back for the comment query. Also, the immediate child operator isn't supported yet by the grammar (but treesitter should still accept it). I'll have something for that soon.

steelsojka commented 4 years ago

@vigoux After researching the second issue, it seems to be a problem with iter_prepared_matches in nvim-treesitter. It only gives us the first node. I will submit a PR to fix it.

EDIT: Actually I think this is a problem in nvim core. The treesitter api only gives us one matched node.

vigoux commented 4 years ago

Oh, nice catch then, was worth looking into.

steelsojka commented 4 years ago

@vigoux The second one seems to be in the tree sitter api in nvim. It only gives us one node of the match.

vigoux commented 4 years ago

That's interesting Raise the issue in nvim, so that we continue the discussion there, will work on this later.

steelsojka commented 4 years ago

@vigoux I'll fix the first issue. I want to get a simple reproduction before I submit an issue in nvim.

steelsojka commented 4 years ago

https://github.com/nvim-treesitter/tree-sitter-query/pull/2 Fixes the string issue.