Skip to content

Conversation

@Aerex
Copy link
Contributor

@Aerex Aerex commented Dec 7, 2020

I took the liberty to add some queries for php. I still new on the query language. I was not able to get if_statement
to work correctly at the moment. Also, I wanted the ability to select the body of a function, excluding the { and }.

I reviewed Add @parameter.outer for Python/C/C++ PR but was not able the result that I am looking for. I am not sure if excluding the braces is feasibly in treesitter at the moment.

@theHamsta
Copy link
Member

Thanks for your contribution. Sorry for forgetting to review!

Regarding { }, at the moment tree-sitter makes it difficult to select the last named node of a node. In theory, this is possible

(some_node .
         (node_type) @function.inner.start
         (node_type) @function.inner.end .        ; the dot enforces this to be the last named node in this block "}" is not named
          )

However, some bug prevents to capture the last node when another nodes is captured at the same time. The above example would work with out last? directive which we removed in favor of the built-in variant.

What could also work would be this offset! directive: (will be extended to strip! directive at some point): neovim/neovim#13367

@theHamsta theHamsta merged commit 9f3cd89 into nvim-treesitter:master Dec 13, 2020
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

Successfully merging this pull request may close these issues.

2 participants