Tree Sitter: Add custom predicates.

Review Request #14518 — Created July 26, 2025 and updated

Information

Review Board
master

Reviewers

The nvim-treesitter highlights files that we're using for most of our
supported languages make use of several custom predicates and
directives.

This change implements the following:

  • any-contains?
  • contains?
  • gsub!
  • has-ancestor?
  • has-parent?
  • not-has-ancestor?
  • not-has-parent?

Directives used in queries files which are not (yet) implemented here:

  • offset!

Predicates and directives implemented in neovim but which are not used
in any of the query files we are using:

  • any-lua-match?
  • any-vim-match?
  • not-vim-match?
  • vim-match?
  • trim!
  • Ran unit tests.
  • Verified that syntax highlighting that used these predicates and
    directives worked as expected.
Summary ID
Tree Sitter: Add custom predicates.
The nvim-treesitter highlights files that we're using for most of our supported languages make use of several custom predicates and directives. This change implements the following: - `any-contains?` - `contains?` - `gsub!` - `has-ancestor?` - `has-parent?` - `not-has-ancestor?` - `not-has-parent?` Directives used in queries files which are not (yet) implemented here: - `offset!` Predicates and directives implemented in neovim but which are not used in any of the query files we are using: - `any-lua-match?` - `any-vim-match?` - `not-vim-match?` - `vim-match?` - `trim!` Testing Done: - Ran unit tests. - Verified that syntax highlighting that used these predicates and directives worked as expected.
e83627bed8199ae25be6567922e15910aa5aec99
david
Review request changed
Change Summary:

assert False -> pytest.fail()

Commits:
Summary ID
Tree Sitter: Add custom predicates.
The nvim-treesitter highlights files that we're using for most of our supported languages make use of several custom predicates and directives. This change implements the following: - `any-contains?` - `contains?` - `gsub!` - `has-ancestor?` - `has-parent?` - `not-has-ancestor?` - `not-has-parent?` Directives used in queries files which are not (yet) implemented here: - `offset!` Predicates and directives implemented in neovim but which are not used in any of the query files we are using: - `any-lua-match?` - `any-vim-match?` - `not-vim-match?` - `vim-match?` - `trim!` Testing Done: - Ran unit tests. - Verified that syntax highlighting that used these predicates and directives worked as expected.
2dc8c533546dcc8fa967b739995abe765e00a927
Tree Sitter: Add custom predicates.
The nvim-treesitter highlights files that we're using for most of our supported languages make use of several custom predicates and directives. This change implements the following: - `any-contains?` - `contains?` - `gsub!` - `has-ancestor?` - `has-parent?` - `not-has-ancestor?` - `not-has-parent?` Directives used in queries files which are not (yet) implemented here: - `offset!` Predicates and directives implemented in neovim but which are not used in any of the query files we are using: - `any-lua-match?` - `any-vim-match?` - `not-vim-match?` - `vim-match?` - `trim!` Testing Done: - Ran unit tests. - Verified that syntax highlighting that used these predicates and directives worked as expected.
e83627bed8199ae25be6567922e15910aa5aec99

Checks run (2 succeeded)

flake8 passed.
JSHint passed.