Componette

Componette

nette-intellij

nette-intellij / intellij-latte v1.1.5

Latte plugin for IntelliJ IDEA platform

Latte Plugin for IntelliJ IDEA / PhpStorm

Provides support for Latte – a template engine for PHP. It's a must-have plugin for Nette developers.

Installation

Settings → Plugins → Browse repositories → Find "Latte" → Install Plugin → Restart IDE

Sponsors

FutureRockstars

Does GitHub already have your 💳? Does Nette plugins save you development time? Send a couple of 💸 a month my way too. Thank you!

To request an invoice, contact me through e-mail.

Supported Features

  • Syntax highlighting
  • Code completion for PHP, classic HTML, attribute tags and more
  • Registering custom tags, filters and custom functions

Testing EAP versions

Latte plugin for IntelliJ is downloadable from the JetBrains plugin repository directly in the PHPStorm. Latte plugin for IntelliJ using channel eap which contains the latest release candidate.

  • Here is, how to set up custom release channels in PHPStorm: Custom release channels
  • You have to add this link: https://plugins.jetbrains.com/plugins/eap/list to your Custom plugin repositories
  • After you add the link above, you can refresh your plugins Marketplace and you will see RC versions for Latte plugin

Building

Plugin uses Gradle to build, but before build you need to install Grammar-Kit plugin to Intellij Idea, right click in file explorer to LatteParser.bnf located in com.jantvrdik.intellij.latte, click to Generate Parser Code, then select PSI root to src/main/gen/com/jantvrdik/intellij/latte/psi and generated parser as src/main/gen/com/jantvrdik/intellij/latte/parser/LatteParser.class

After generating parser files, you need to generate a .flex file from the same .bnf file, right click to file and choose option Generate JFlex Lexer and generate _LatteLexer.flex in the same folder.

Now you can build plugin using gradle, and it will automatically generate another classes from .flex files, if you want you can help us automate system, so next time no one must do the manual generation work.

$ gradlew build

To build .jar file to local install to IDE run gradle task buildPlugin. .jar file with plugin will be located in build/libs

Run IDE for testing

Create file local.properties in project and insert next content with path to IDE directory:

For your current OS see default IDE paths: https://www.jetbrains.com/help/idea/tuning-the-ide.html#default-dirs

runIdeDirectory = /Users/<user id>/Library/Application Support/JetBrains/Toolbox/apps/PhpStorm/ch-0/201.7223.96/PhpStorm 2019.3 EAP.app/Contents

And run gradle task :runIde ideally by run configurations in IDEA (it supports debugging).

Known Limitations

  • Low-level macros {syntax} is not supported, {contentType} is supported partially.

Screenshot

  • v1.1.5 v1.1.5

    Changed

    • Auto completion for classes now suggest also interfaces (#195)

    Fixed

    • Fixed errors while parsing .latte files (#189, #191, #192)
  • v1.1.4 v1.1.4

    • upgraded LatteReparseUtil for reloading config from XML without user interaction (issue #161, #167)
    • added showing completion auto popup after type ->, ::, , $, | (issue #76)
    • added support for caching identifiers in PsiElements (performance improvement)
    • added support for Latte tag {parameters}
    • moved Latte filters and their arguments to one PSI element (issue #108)
    • added LattePhpTypeDetector (faster PhpTypes detector)
    • added stub index for PhpType (issue #180)
    • fixed detect for variable if reference is in foreach value
    • fixed ? in type definitions like ?int, ?string, ...
    • fixed and removed more deprecated usages (prepare for higher versions)
    • fixed problem with resolving methods witch use array access for variables defined by templateType tag (issue #179)
  • v1.1.3 v1.1.3

    • added missing tags and filters for latest Latte version
    • better completion for tags with optional closing tag (issue #110)
    • fixed for 2021.1 (issue #163, #164)
    • fixed methods with variable in name (issue #153, #166)
    • fixed and improved variables inspections, implemented variable context (issue #104)
    • fixed detection for variable types in varType tag (issue #107)
    • fixed problem with multiple variable definitions (issue #124)
    • added more tests for psi helpers and variable inspections
  • v1.1.2 v1.1.2

    • Just released
  • v1.1.2-RC1 v1.1.2-RC1

    • fixed bug with bad ASTNode creating (issue #135)
    • fixed for PhpStorm 2020.3
    • fixed class completion if part of namespace is typed (and for classes without namespace)
    • fixed saving settings (tags, etc...) (issue #136, #145, #149)
    • fixed /} for {block /} and {label /} tags
  • v1.1.1 v1.1.1

    • minor changes for PhpStorm 2020.3
    • increased minimum compatibility to 2020.2.4
    • added new tags {try} {rollback} {ifchanged} {skipIf}
    • added new filters |clamp |sort and custom function clamp()
    • added support for references to core functions with , e.g. \current()
    • added support for floats, hex, oct, bin and numbers with exponent (issue #123)
    • added support for UNPAIRED_ATTR tags (issue #120)
    • fixed undefined variable problem in n:for loop (issue #98)
    • fixed marked parameters as link (issue #102)
    • fixed bug with nested blocks used as n: attributes (issue #109)
    • fixed bug in code formatting for AUTO_EMPTY tags (issue #114, #125, #116)
    • fixed performance bugs (issue #105, #117)
    • fixed bug with double-click behavior in double quoted strings (issue #111)
    • added stub indexes - it improve performance if references are resolved (issue #100)
    • added better support for XML configuration files (references to .latte templates etc.)
    • added .dtd file for validate XML configurations in IDE
    • fixed bug in auto completion for methods (now it is not detected as PHP function)
  • v1.1.0 v1.1.0

    • added support for iterable types (issue #70)
    • added new inspections for iterable types (issue #78)
    • added support for array access (eg. $arr[][]) to parser (issue #82)
    • added support for define variables in tag {define} (issue #84)
    • added live template {va
    • fixed detecting variable type from code
    • fixed bug in autocomplete inside var macro
    • added support for load configuration from XML files (issue #81)
    • added support for multi line macro settings
    • added support for reformat code for spaces around assignment and equality operators
    • added support for reformat code for spaces after tag name and before closing tag
    • added support for reformat code for spaces before tag filters
    • added support for change syntax highlight for operators
    • added Latte context for live templates
    • added live templates {fore, {forek, {fori and {ife
    • added new tags {do}, {sandbox}, {widget} and {varPrint}
    • added new filter |batch:(array, length [, item])
    • added tag {inputError} - (reload for Nette tag settings needed)
    • switched to not deprecated api around Latte code formatter
    • upgraded more deprecated usages
    • improved LattePhpType to use less memory and work faster (about -75% processing time)
    • implemented Gradle (for better plugin development)
    • tag {? ...} was tagged as deprecated since Nette 2.4
    • increased minimum compatibility to PhpStorm 193.5233.102
    • added support for use HTML elements in PSI tree (internal feature for future improvements)
    • fixed issue #66 - methods, constants and properties are now recognized for static classes
    • fixed issue #64 - ifcontent is now macro without parameters
    • fixed issue #61 - improved working with methods (now it is prepared for future enhacements)
    • fixed issue #69 - determine type for a variable, if call some on this now working
    • fixed issue #62 - now is space after function name allowed and it is determined as function
    • fixed issue #80 - better parsing for namespaces and classes and fixed refactoring for classes
    • fixed issue #72 - added support for double colons in filters
    • fixed issue #77 - added inspection for deprecated and internal usages
    • fixed issue #55 - fixed macro {label foo} as unpaired (also fixed other AUTO_EMPTY tags)
  • v1.0.2 v1.0.2

    • added code style settings (settings for use tabs or spaces) (issue #46, #30)
    • added support for define variable in tag {default $foo = 123}
    • added class namespaces completion
    • added support for define variables by {php [$foo, $bar] = $arr}
    • implemented some performance improvements
    • fixed resolving methods if a type is more classes FooClass|BarClass
    • fixed completion for unpaired macro after if missing end }
    • fixed filters on variables (issue #47)
    • fixed wrong indent for elseifset (issue #42)
    • fixed multiple variable definitions in for/foreach cycles
    • fixed auto-complete (disabled in strings, more improvements)
    • increased minimum compatibility to 2018.3
  • v1.0.1 v1.0.1

    • Fixed compatibility issues
    • Fixed structure view (added n:tags and images)
  • v1.0.0 v1.0.0 - PHP content support

    • Added PHP content support
  • v0.3.3

    • fixed null pointer exception
  • v0.3.2

    • fixed disappearing comments
    • Latte 2.4: added new macros
    • Latte 2.4: added AUTO_EMPTY support
    • Latte 2.4: added info about deprecated macro(s)
  • v0.3.1

    Fixed compatibility with PhpStorm 9.0

  • v0.3.0

    • fixed comment parsing ("todo" support)
    • added "modifier not allowed" inspection
    • added structure view
    • improved macro folding
  • v0.2.0

    • html/xml support
    • better macro content parsing
    • parsing of n:macros content
Componette Componette felix@nette.org