Skip to content

Add indentation rule for array creation expressions - #139

Open
carestad wants to merge 4 commits into
zed-extensions:mainfrom
carestad:fix/php-indent-array-short
Open

Add indentation rule for array creation expressions#139
carestad wants to merge 4 commits into
zed-extensions:mainfrom
carestad:fix/php-indent-array-short

Conversation

@carestad

@carestad carestad commented Aug 1, 2026

Copy link
Copy Markdown

Adds indentation rules for PHP array creation expressions.

Pressing Enter after an opening [ or array( left the new line at column 0. indents.scm only matched nodes containing {/}, so neither array form was covered - both use brackets or parentheses.

Before:

$foo->bar([
line at column 0
]);

After:

$foo->bar([
    line indented one level
]);

Both short [] and legacy array() syntax are handled; in tree-sitter-php both produce an array_creation_expression` node, differing only in the closing delimiter.

Note the rules are scoped to array_creation_expression rather than matching ] or ) generally, since ] also closes array access ($foo['bar']).

Tested locally on Zed v1.13.1 with a fresh profile.

Fixes #138

@cla-bot

cla-bot Bot commented Aug 1, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @carestad on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@carestad

carestad commented Aug 1, 2026

Copy link
Copy Markdown
Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed label Aug 1, 2026
@cla-bot

cla-bot Bot commented Aug 1, 2026

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

@carestad carestad changed the title Add indentation rule for short array creation expressions Add indentation rule for array creation expressions Aug 1, 2026

@MrSubidubi MrSubidubi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but needs some reformatting as noted in CI. Could you look into that, please?

@carestad

carestad commented Aug 4, 2026

Copy link
Copy Markdown
Author

Looks good, but needs some reformatting as noted in CI. Could you look into that, please?

@MrSubidubi Sure thing! Should be updated now 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

buggy auto-indent inside array syntax [] and array()

2 participants