• 
      

    Vendor interesting_lines.scm queries from nvim-treesitter-textobjects.

    Review Request #15255 — Created Aug. 27, 2026 and submitted

    Information

    Review Board
    release-9.x

    Reviewers

    This change vendors textobjects.scm files from the
    nvim-treesitter-textobjects repository (Apache-2.0, same org as
    nvim-treesitter) as interesting_lines.scm, filtered down to the patterns
    capturing @function.outer and @class.outer. These will drive
    tree-sitter-based interesting lines detection in the diff viewer,
    covering 49 languages.

    update-queries.py now takes a second argument pointing to a
    nvim-treesitter-textobjects checkout, and processes each vendored file
    from a per-file source spec (repository, queries path, source URL,
    input/output filenames, and an optional transform). The existing
    inherits resolution, commit-history fallback, and grammar validation
    apply to both repositories, with transforms applied before validation so
    we validate what we ship.

    The textobjects transform (query_utils.filter_query_patterns) keeps
    only patterns using the captures we want, drops the comments attached to
    dropped patterns, dedupes patterns duplicated by inherits resolution
    (javascript pulls ecma in twice), and drops per-language wrapper
    patterns that would yield the wrong header line (a decorated Python
    definition would report the first decorator line; the plain
    function_definition pattern already yields the def line).

    Each vendored file is recorded in queries.lock with the textobjects
    repository URL and commit. Upstream has no usable function or class
    captures for some languages (such as perl), which simply do not get an
    interesting_lines.scm and will fall back to the regex scanner.

    The actual vendored files are part of my commit but I've excluded them
    from the posted change here.

    • Ran update-queries.py against fresh checkouts of both repositories,
      with nvim-treesitter pinned to the queries.lock commit. The existing
      highlights.scm and injections.scm files regenerated byte-identical.
    • Added a test compiling every vendored interesting_lines.scm against
      its grammar, plus unit tests for filter_query_patterns().
    • Spot-checked the vendored output for Python, JavaScript, TypeScript,
      C, and C++.
    • Ran unit tests (reviewboard/treesitter).
    Summary ID
    Vendor interesting_lines.scm queries from nvim-treesitter-textobjects.
    This change vendors textobjects.scm files from the nvim-treesitter-textobjects repository (Apache-2.0, same org as nvim-treesitter) as interesting_lines.scm, filtered down to the patterns capturing @function.outer and @class.outer. These will drive tree-sitter-based interesting lines detection in the diff viewer, covering 49 languages. update-queries.py now takes a second argument pointing to a nvim-treesitter-textobjects checkout, and processes each vendored file from a per-file source spec (repository, queries path, source URL, input/output filenames, and an optional transform). The existing inherits resolution, commit-history fallback, and grammar validation apply to both repositories, with transforms applied before validation so we validate what we ship. The textobjects transform (`query_utils.filter_query_patterns`) keeps only patterns using the captures we want, drops the comments attached to dropped patterns, dedupes patterns duplicated by inherits resolution (javascript pulls ecma in twice), and drops per-language wrapper patterns that would yield the wrong header line (a decorated Python definition would report the first decorator line; the plain function_definition pattern already yields the def line). Each vendored file is recorded in queries.lock with the textobjects repository URL and commit. Upstream has no usable function or class captures for some languages (such as perl), which simply do not get an interesting_lines.scm and will fall back to the regex scanner. Testing Done: - Ran update-queries.py against fresh checkouts of both repositories, with nvim-treesitter pinned to the queries.lock commit. The existing highlights.scm and injections.scm files regenerated byte-identical. - Added a test compiling every vendored interesting_lines.scm against its grammar, plus unit tests for filter_query_patterns(). - Spot-checked the vendored output for Python, JavaScript, TypeScript, C, and C++. - Ran unit tests (reviewboard/treesitter).
    uvzxmtwkyutolnknputnxksxpxmxnzzo
    Description From Last Updated

    Missing "Version Added".

    chipx86 chipx86

    "Git", here and below.

    chipx86 chipx86

    This is all internal. We don't really need a frozenset here. It's just a lot of extra noise.

    chipx86 chipx86

    This is all internal. We don't really need a frozenset here. It's just a lot of extra noise.

    chipx86 chipx86

    No need to use frozenset in this file. We don't need this protection.

    chipx86 chipx86

    Should be "Git".

    chipx86 chipx86

    Can you fix these to be in alphabetical order?

    chipx86 chipx86

    We never use this form. Big Claude smell.

    chipx86 chipx86

    We should keep this sorted.

    chipx86 chipx86

    Can we pull this out out of the loops so we're not reconstructing it every iteration?

    chipx86 chipx86

    Can you use the standard multi-line form for the comprehension?

    chipx86 chipx86

    Might be cheaper to check not in seen_patterns first, and then maybe the drop_node_types one, since we're not having to …

    chipx86 chipx86
    chipx86
    1. 
        
    2. contrib/internal/treesitter/update-queries.py (Diff revision 1)
       
       
       
       
       
      Show all issues

      Missing "Version Added".

    3. Show all issues

      "Git", here and below.

    4. contrib/internal/treesitter/update-queries.py (Diff revision 1)
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
      Show all issues

      This is all internal. We don't really need a frozenset here. It's just a lot of extra noise.

    5. contrib/internal/treesitter/update-queries.py (Diff revision 1)
       
       
       
       
       
       
       
      Show all issues

      This is all internal. We don't really need a frozenset here. It's just a lot of extra noise.

    6. Show all issues

      No need to use frozenset in this file. We don't need this protection.

    7. contrib/internal/treesitter/update-queries.py (Diff revision 1)
       
       
       
       
       
      Show all issues

      Should be "Git".

    8. Show all issues

      Can you fix these to be in alphabetical order?

    9. Show all issues

      We never use this form. Big Claude smell.

    10. contrib/internal/treesitter/update-queries.py (Diff revision 1)
       
       
       
       
       
      Show all issues

      We should keep this sorted.

    11. reviewboard/treesitter/query_utils.py (Diff revision 1)
       
       
       
      Show all issues

      Can we pull this out out of the loops so we're not reconstructing it every iteration?

    12. reviewboard/treesitter/query_utils.py (Diff revision 1)
       
       
      Show all issues

      Can you use the standard multi-line form for the comprehension?

    13. reviewboard/treesitter/query_utils.py (Diff revision 1)
       
       
       
       
      Show all issues

      Might be cheaper to check not in seen_patterns first, and then maybe the drop_node_types one, since we're not having to loop within the entry.

      1. I mean sure, but this runs only as part of the vendoring step when we want to update our queries from upstream. Performance isn't really something worth worrying about here.

    14. 
        
    david
    chipx86
    1. Ship It!
    2. 
        
    david
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-9.x (5527951)