Skip to content

Add indentation rule for array creation expressions - #139

Merged
MrSubidubi merged 4 commits into
zed-extensions:mainfrom
carestad:fix/php-indent-array-short
Aug 7, 2026
Merged

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

Conversation

@carestad

@carestad carestad commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

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
Contributor 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
Contributor Author

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

@MrSubidubi Sure thing! Should be updated now 🙂

@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.

Appreciate it. Looks good now, thanks and congrats to your first contribution! 🎉

@MrSubidubi
MrSubidubi enabled auto-merge (squash) August 6, 2026 16:03
@carestad

carestad commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Appreciate it. Looks good now, thanks and congrats to your first contribution! 🎉

@MrSubidubi cheers, but it seems something failed again in the pipeline 😭

@MrSubidubi

Copy link
Copy Markdown
Contributor

Yep, GitHub outage yesterday 🥲 Love cleaning up after that

@MrSubidubi
MrSubidubi merged commit 355cdc1 into zed-extensions:main Aug 7, 2026
7 of 9 checks passed
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