IntelliJ NEON Nette Support

Getting Started

NEON (Nette Object Notation; Neon format) is a custom configuration language similar to YAML.

Useful links

Migration guide from free plugin

  • Do not forget to uninstalling old free plugin

Installing the Plugin

Installation of IntelliJ NEON Nette Support is done through IntelliJ IDEA's integrated plugin manager. From within the application, open Preferences and select Plugins from the list on the left-hand side. This will show you the list of currently installed plugins. If you are currently using Neon free plugin then you must uninstall it before install NEON Nette Support.

feature-completion

Next, click the Marketplace tab, which allows you to browse through the plugins available on JetBrains' Marketplace. Enter "NEON" into the search field in the top left corner and select NEON Nette Support from the list. Finally, click the green Install button and restart the application. The plugin should now be installed, and you can set up your project.

feature-completion

Recommendations

If you are using integer keys, use:

20: test
Instead of:
"20": test

If you are using key after bullets definition and need more dimension arrays, use:

services:
	- factory: Foo\Bar
	  setup:
	  	key: [foo: 123, bar: 456]
Instead of:
services:
	- factory: Foo\Bar
	  setup:
		key:
			foo: 123
			bar: 456

Features

  • Coding assistance (highlighting, completion, formatting, refactorings, etc.)
  • Navigation, search, information about types and implicits
  • Integration with PHP (completion, references, refactorings, etc.)
  • Integration with Nette framework (extension keywords, services, etc.
  • Structure view, typing helpers, etc.
feature-completion feature-find-usages

XML configuration

XML configuration files for Neon plugin are files that contain information about extensions, parameters, services etc.

  • Plugin loads all files named intellij-neon-pro.xml in your project including vendor folder or some other folders except ignored folders.
  • You can use more intellij-neon-pro.xml files. All will be loaded, but must have different value in vendor attribute.
  • Tip: distribute intellij-neon-pro.xml files with your Composer package
  • Here is Neon XSD definition
  • You may need to adjust the path to the XSD .idea/intellij-neon-pro/xmlSources/Neon.xsd if you are not in the root directory.

This is example file content with sample values:

  • Replace myVendor/myPackage to your unique vendor name
<?xml version="1.0" encoding="UTF-8"?>
<neon vendor="myVendor/myPackage"
	  version="1"
	  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	  xsi:noNamespaceSchemaLocation=".idea/intellij-neon-pro/xmlSources/Neon.xsd">
	<project>
		<useExtension name="tracy" type="Tracy\Bridges\Nette\TracyExtension" />
	</project>
	<extensions>
		<extension type="Tracy\Bridges\Nette\TracyExtension">
			<schema>
				<structure>
					<field name="email">
						<email />
						<anyOf>
							<listOf>
								<value><email /></value>
							</listOf>
						</anyOf>
					</field>
					<field name="fromEmail"><email /></field>
					<field name="emailSnooze"><string /></field>
					<field name="logSeverity">
						<useReusable ref="phpSeverity"/>
					</field>
					<field name="strictMode">
						<useReusable ref="phpSeverity"/>
					</field>
					<field name="scream">
						<useReusable ref="phpSeverity"/>
					</field>
					<field name="editor"><type value="string|null" /></field>
					<field name="browser"><string /></field>
					<field name="errorTemplate"><string /></field>
					<field name="dumpTheme"><string /></field>
					<field name="showBar"><bool /></field>
					<field name="showLocation"><bool /></field>
					<field name="maxLength"><int /></field>
					<field name="maxDepth"><int /></field>
					<field name="maxItems"><int /></field>
					<field name="keysToHide">
						<arrayOf>
							<value><type value="string|int|null" /></value>
						</arrayOf>
					</field>
					<field name="bar">
						<listOf>
							<value><type value="string|\Nette\DI\Definitions\Statement" /></value>
						</listOf>
					</field>
					<field name="blueScreen"><callable /></field>
					<field name="editorMapping" default="null">
						<anyOf>
							<null />
							<arrayOf>
								<key><string /><int /></key>
								<value><string /></value>
							</arrayOf>
						</anyOf>
					</field>
					<field name="netteMailer"><bool /></field>
				</structure>
			</schema>
			<services>
				<service name="logger" type="\Tracy\ILogger"/>
				<service name="blueScreen" type="\Tracy\BlueScreen"/>
				<service name="bar" type="\Tracy\Bar"/>
			</services>
		</extension>
	</extensions>
	<reusables>
		<reusable id="phpSeverity">
			<anyOf>
				<bool />
				<int />
				<string pattern="(E_(?:ALL|PARSE|STRICT|RECOVERABLE_ERROR|(?:CORE|COMPILE)_(?:ERROR|WARNING)|(?:USER_)?(?:ERROR|WARNING|NOTICE|DEPRECATED))|[ &|~()])+" />
				<listOf>
					<value><string pattern="E_(?:ALL|PARSE|STRICT|RECOVERABLE_ERROR|(?:CORE|COMPILE)_(?:ERROR|WARNING)|(?:USER_)?(?:ERROR|WARNING|NOTICE|DEPRECATED))" /></value>
				</listOf>
			</anyOf>
		</reusable>
	</reusables>
</neon>

Allowed XML Elements and Attributes

This documentation describes the basic structure and constraints defined in the Neon XSD schema.

<neon>

Attribute Required Default Possible Values Description
vendor yes none any string Vendor name
version yes none any int Schema version

Sub-elements of <neon>

Element Required Description
<project> no Defines project-specific configurations
<extensions> no Defines extensions schema and services
<reusables> no Reusable configurations

<project>

The <project> element can contain the following sub-elements:

  • <useExtension>: Specifies an extension to use (required attributes: name, type).
  • <file>: Specifies a file (required attributes: type, path).
  • <parameters>: Defines project parameters.

<extensions>

The <extensions> element defines available extensions. It contains one or more extension sub-elements with the following attributes:

Attribute Required Default Description
type yes none Type of the extension

The <extension> element can contain the following sub-elements:

  • <schema>: Defines the structure of the extension configuration, allowing for nested fields and reusable types.
  • <services>: Specifies a list of services associated with the extension, including their names and types.

An example is provided above.

<reusables>

The <reusables> element defines reusable configurations for schemas. It contains one or more <reusable> sub-elements, each uniquely identified by the id attribute.

Element Attribute Required Description
<reusables> None No Container for reusable schema definitions.
<reusable> id Yes Unique identifier for the reusable schema definition.
Example:
<reusables>
    <reusable id="exampleSchema1">
        <anyOf>
            <string minLength="1" maxLength="255" />
            <int min="0" max="100" />
        </anyOf>
    </reusable>
    <reusable id="exampleSchema2">
        <listOf>
            <value>
                <type value="string" />
            </value>
        </listOf>
    </reusable>
</reusables>

Known limitations

Services and parameters refactoring

  • Here problem with refactoring services and parameters that have more than one definition (only usages will be refactored)
  • For services and parameters with only one definition everything works fine

Do not use mixed indents

  • Do not use mixed indents. Use only tabs or spaces
  • If you use spaces, use same count of spaces on all levels
  • Exception is only key after bullet where are used two spaces

Compatibility

Since 1.0.0, IntelliJ NEON Nette Support plugin is compatible with all major JetBrains IDEs with version 2021.1.1 and higher.

Bug Reports

Bug reports can be realized in GitHub public repository.

© 2022 Matouš Němec