Syntax highlighting for Fenom templates in JetBrains IDEs (PhpStorm, IntelliJ IDEA Ultimate with PHP plugin).
- Syntax highlighting for Fenom template tags and expressions
- Support for Fenom 3.x operators:
??,?.,?->,~,~~,~=,..,->,::,?: - Highlighting for keywords:
if,else,elseif,foreach,foreachelse,set,var,include,insert,block,extends,parent,as,default,matches,not, and more - Variable, string, number, modifier, operator, and comment highlighting
- Configurable color schemes via Settings → Editor → Color Scheme → Fenom
- File types:
*.fenom,*.tpl,*.fm
- Download or build
Fenom.jar - Open Settings → Plugins → ⚙️ → Install Plugin from Disk...
- Select
Fenom.jar - Restart the IDE
| Plugin Version | IDE Version |
|---|---|
| 1.0.0 | PhpStorm 2025.1+ |
By default, the plugin registers for *.fenom and *.fm files. To enable highlighting for *.tpl files:
- Settings → Editor → File Types
- Find Fenom template in the list
- Add
*.tplto the registered patterns
Customize colors at Settings → Editor → Color Scheme → Fenom. Available elements:
| Element | Description |
|---|---|
| Comments | {* comment *} |
| Keywords | if, foreach, set, etc. |
| Variables | $variable |
| Strings | 'string', "string" |
| Numbers | 42, 3.14 |
| Operators | ??, ?., ~, .., ->, :: |
| Brackets | {, } |
| Punctuation | ., ,, : |
{* Template comment *}
<h1>{$title|default:'Hello World'}</h1>
{set $user = $app->getUser()}
{if $user?->name ?? 'Guest'}
<p>Welcome, {$user?->name}!</p>
<p>City: {$user?.address?.city}</p>
{elseif $name is not empty}
<p>Hello {$name ~ '!'}</p>
{else}
<p>Welcome, stranger!</p>
{/if}
{foreach $items as $item index $i}
{if $item.published}
<div>{$i}. {$item.title} — {$item.price ?? 'free'}</div>
{/if}
{foreachelse}
<p>No items found.</p>
{/foreach}
{include 'pagination.tpl' pages=$pages}
- JDK 17+
- JFlex 1.9.1+ (only needed if modifying
.flexfiles) - PhpStorm installed (provides the SDK JARs for compilation)
# Set PhpStorm path (optional, defaults to /Applications/PhpStorm.app/Contents on macOS)
export PS_HOME="/Applications/PhpStorm.app/Contents"
# Build the plugin
./build.shThe output JAR will be at build/Fenom.jar.
If you modify src/ru/maxisoft/fenom/lexer/FenomTop.flex or FenomSub.flex, regenerate the lexers:
jflex -d src/ru/maxisoft/fenom/lexer/ src/ru/maxisoft/fenom/lexer/FenomTop.flex
jflex -d src/ru/maxisoft/fenom/lexer/ src/ru/maxisoft/fenom/lexer/FenomSub.flexDo not edit the generated *FlexLexer.java files directly — they are overwritten by JFlex.
├── META-INF/
│ └── plugin.xml Plugin descriptor
├── src/ru/maxisoft/fenom/
│ ├── FenomLanguage.java Language registration
│ ├── editor/ Syntax highlighter & color settings
│ ├── file/ File type, icons, view provider
│ ├── lexer/ Two-stage lexer (JFlex)
│ │ ├── FenomTop.flex Top-level lexer (HTML vs macros)
│ │ ├── FenomSub.flex Macro body lexer (tokens)
│ │ └── LayeredLexer.java Wires both lexers together
│ ├── parser/ PSI parser definition
│ └── psi/ Token types & PSI elements
├── build.sh Build script
└── README.md
This project is licensed under the MIT License.
Push a version tag to trigger automatic build and GitHub Release creation:
git tag v1.0.0
git push origin v1.0.0This creates a release with Fenom.jar attached, ready for download.