Skip to content

Add coloration for @prop and @block Twig comments from Symfony UX#2545

Open
Kocal wants to merge 1 commit intoHaehnchen:masterfrom
Kocal:gh-2544
Open

Add coloration for @prop and @block Twig comments from Symfony UX#2545
Kocal wants to merge 1 commit intoHaehnchen:masterfrom
Kocal:gh-2544

Conversation

@Kocal
Copy link
Copy Markdown

@Kocal Kocal commented Feb 20, 2026

Close #2544

Mainly coded through Claude Opus 4.5, let me know what you think:
image

I re-used the colors from PHPDoc, but maybe it would be better if we re-use more "Twig" colors.

@Haehnchen
Copy link
Copy Markdown
Owner

I did a quick run to fix the tests https://github.com/Haehnchen/idea-php-symfony2-plugin/tree/pr-2545. By this the color changed to provide more defaults. Just maybe prop/block name should have a better twig/default color. i will check what is suitable and merge the implentation then.

It's a syntax only used by the Symfony UX Toolkit AFAIK, it's not something standard, but I feel like it could be nice to implement.

it would be even nice to have this as a documented standard, its also important for agents nowadays. It could also just easily take as the source for auto completion on the consuming side.

image

@Kocal
Copy link
Copy Markdown
Author

Kocal commented Feb 20, 2026

It's a syntax only used by the Symfony UX Toolkit AFAIK, it's not something standard, but I feel like it could be nice to implement.

it would be even nice to have this as a documented standard, its also important for agents nowadays. It could also just easily take as the source for auto completion on the consuming side.

Yeah totally, it must become a standard even if it's only for Symfony UX TwigComponent. It could help user by auto-completing properties or blocks when typing...

I don't know how auto-completion works, but adding the description for each prop/block could be super useful:
image

Note 1: the {# @prop #} syntax is not identical to /** @property */ from PHPDoc, the property name and types are inverted.

Note 2: identifying the type is super naive, it does not handle whitespaces. 😬
For the example, only array<string while be highlighted, which is not correct:

{# @prop data array<string, Collection<int, Item>> Nested data structure #}

@Kocal
Copy link
Copy Markdown
Author

Kocal commented Feb 20, 2026

Opened twigphp/Twig#4768

@Kocal
Copy link
Copy Markdown
Author

Kocal commented Feb 23, 2026

If twigphp/Twig#4770 gets merged, this PR will become useless and will have to be closed, since the description/docs will be parts of types and block tags (which are already correctly highlighted):
image

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.

Support syntax highlighting in Twig comments for @prop and @block (Symfony UX Toolkit)

2 participants