Using the IntelliJ Ballerina Plugin
The below sections include information to start using the IntelliJ Ballerina plugin after installing it.
- Creating a New Ballerina Project
- Setting Up Ballerina SDK for an Existing Project
- Creating a New Ballerina File
- Configuring the Plugin Settings
Creating a New Ballerina Project
Follow the steps below to create a new Ballerina project.
-
Open IntelliJ, click File in the top menu, click New, and then click Project.
-
Select Ballerina as the type of the project, and click Next.
-
Select a Ballerina SDK for the project, and click Next.
Tip: If you do not have an already-configured Ballerina SDK to select, click Configure, select the location of the Ballerina distribution, click Open, and then click Next to continue with the project creation. However, if you do not configure, the plugin will auto detect the Ballerina Home by executing the
ballerina home
command. -
Enter a name for the project, a location to save it, and click Finish.
Now, you have successfully created a new Ballerina project.
Setting Up Ballerina SDK for an Existing Project
Follow the steps below to set up Ballerina SDK for an existing project.
- Open the Project to which you want to set up a Ballerina SDK.
-
In the IDE, click File in the top menu, and then click Project Structure.
-
If you do not have an already-configured Ballerina SDK, in the Project tab, click New under Project SDK:, click Ballerina SDK, and then click OK.
Tip: If you have already-configured Ballerina SDKs, select one under Project SDK:, and click OK to continue.
-
Select the location of the Ballerina distribution and click Open.
-
Click Apply to save the changes.
Tip This prompts a restart request. Click Restart to apply the changes.
Now, you have successfully added the Ballerina SDK to an existing project.
Creating a New Ballerina File
Follow the steps below to create a new Ballerina file within a Ballerina project.
-
Right-click on the name of the project, click New, and then click Ballerina File.
-
Enter a name for the file, and click OK.
Tip: In this example, since the default Main template is selected as the Kind, it creates a new file with a main function.
Now, you have successfully created a new Ballerina file with a main function.
Configuring the Plugin Settings
Ballerina Home Auto Detection
In order to automatically detect the Ballerina Home that is being used (without setting up a Ballerina SDK), enable the Settings -> Languages and Frameworks -> Ballerina -> Ballerina Home Auto Detection option.
Experimental Features
Ballerina Language Specification supports a set of experimental features such as transactions syntax. In order to be compatible with the experimental features and for supporting language intelligence in IntelliJ plugin, enable the Allow Experimental option in Settings -> Languages and Frameworks -> Ballerina -> Experimental Features.
Language Server Debug Logs
In order to view the plugin debug logs, enable the Settings -> Languages and Frameworks -> Ballerina -> Language Server Debug Logs option.
Then, the language server debug logs will be added to the IDEA log files. (Click Help -> Show Log In Files option to view them).
What’s Next?
Next, for information on using the features of the IntelliJ Ballerina plugin, see Using the IntelliJ plugin features.