diff --git a/.github/workflows/release_lsp.yml b/.github/workflows/release_lsp.yml
index ab26f4cafc34..525ca5a8d046 100644
--- a/.github/workflows/release_lsp.yml
+++ b/.github/workflows/release_lsp.yml
@@ -8,6 +8,7 @@ on:
- main
paths:
- editors/vscode/package.json
+ - editors/intellij/gradle.properties
jobs:
check:
@@ -16,12 +17,14 @@ jobs:
outputs:
# LSP Extension Version
version: ${{ env.version }}
+ intellij_version: ${{ env.intellij_version }}
# Version of the Biome binary
biome_version: ${{ env.biome_version }}
prerelease: ${{ env.prerelease }}
nightly: ${{ env.nightly }}
version_changed: ${{ steps.version.outputs.changed }}
+ intellij_version_changed: ${{ steps.intellij_version.outputs.changed }}
steps:
- uses: actions/checkout@v3
@@ -30,7 +33,7 @@ jobs:
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
run: echo "nightly=true" >> $GITHUB_ENV
- - name: Check version changes
+ - name: Check VSCode version changes
uses: EndBug/version-check@v2
if: env.nightly != 'true'
id: version
@@ -38,6 +41,14 @@ jobs:
diff-search: true
file-name: editors/vscode/package.json
+ - name: Check intellij plugin version changes
+ uses: victor-teles/gradle-properties-diff-checker@v1
+ if: env.nightly != 'true'
+ id: intellij_version
+ with:
+ file-name: editors/intellij/gradle.properties
+ property: pluginVersion
+
- name: Check Biome version changes
uses: EndBug/version-check@v2
if: env.nightly != 'true'
@@ -50,6 +61,7 @@ jobs:
run: |
echo "version=${{ steps.version.outputs.version }}" >> $GITHUB_ENV
echo "biome_version=${{ steps.biome_version.outputs.version }}" >> $GITHUB_ENV
+ echo "intellij_version=${{ steps.intellij_version.outputs.version }}" >> $GITHUB_ENV
- name: Check prerelease status
id: prerelease
@@ -58,10 +70,15 @@ jobs:
echo "prerelease=true" >> $GITHUB_ENV
node ./editors/vscode/scripts/update-nightly-version.mjs >> $GITHUB_ENV
echo "biome_version=$(node packages/@biomejs/biome/scripts/update-nightly-version.mjs)" >> $GITHUB_ENV
+ echo "intellij_version=$(node ./editors/intellij/scripts/update-nightly-version.mjs)" >> $GITHUB_ENV
- - name: Check version status
+ - name: Check VSCode version status
if: steps.version.outputs.changed == 'true'
- run: 'echo "Version change found! New version: ${{ steps.version.outputs.version }} (${{ steps.version.outputs.version_type }})"'
+ run: 'echo "VSCode Version change found! New version: ${{ steps.version.outputs.version }} (${{ steps.version.outputs.version_type }})"'
+
+ - name: Check intellij version status
+ if: steps.intellij_version.outputs.changed == 'true'
+ run: 'echo "Intellij Version change found! New version: ${{ steps.intellij_version.outputs.version }}'
- name: Biome Check version status
if: steps.biome_version.outputs.changed == 'true'
@@ -90,7 +107,7 @@ jobs:
target: aarch64-apple-darwin
code-target: darwin-arm64
- name: Package ${{ matrix.code-target }}
+ name: Package VSCode ${{ matrix.code-target }}
runs-on: ${{ matrix.os }}
needs: check
@@ -148,7 +165,7 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18
-
+
- name: Setup pnpm
uses: pnpm/action-setup@v2.4.0
with:
@@ -187,7 +204,7 @@ jobs:
if-no-files-found: error
publish:
- name: Publish
+ name: Publish VSCode
runs-on: ubuntu-latest
needs: build
environment: marketplace
@@ -212,7 +229,7 @@ jobs:
with:
version: latest
run_install: true
-
+
- name: Install VCSE
run: pnpm add -g @vscode/vsce
@@ -255,3 +272,101 @@ jobs:
biome_lsp-*.vsix
fail_on_unmatched_files: true
generate_release_notes: true
+
+ build-intellij:
+ name: Build Intellij LSP
+ runs-on: ubuntu-latest
+ needs: check
+ env:
+ version: ${{ needs.check.outputs.intellij_version }}
+
+ if: needs.check.outputs.intellij_version_changed == 'true' || needs.check.outputs.nightly == 'true'
+ outputs:
+ version: ${{ env.version }}
+ prerelease: ${{ env.prerelease }}
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v3
+
+ - name: Setup Java
+ uses: actions/setup-java@v3
+ with:
+ distribution: zulu
+ java-version: 17
+
+ - name: Setup Gradle
+ uses: gradle/gradle-build-action@v2
+ with:
+ gradle-home-cache-cleanup: true
+
+ - name: Update plugin version
+ if: needs.check.outputs.prerelease == 'true'
+ working-directory: editors/intellij
+ run: |
+ node ./scripts/update-nightly-version.mjs >> $GITHUB_ENV
+
+ - name: Build plugin
+ working-directory: editors/intellij
+ run: ./gradlew buildPlugin
+
+ - name: Upload artifact
+ uses: actions/upload-artifact@v3
+ with:
+ name: intellij_package
+ path: ./editors/intellij/build/distributions/intellij-biome-*.zip
+ if-no-files-found: error
+
+ publish-intellij:
+ name: Publish Intellij LSP
+ runs-on: ubuntu-latest
+ needs: build-intellij
+ environment: intellij-plugin
+ permissions:
+ contents: write
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: Download extension artifacts
+ uses: actions/download-artifact@v3
+ with:
+ name: intellij_package
+ path: ./editors/intellij/build/distributions
+
+ - name: Setup Java
+ uses: actions/setup-java@v3
+ with:
+ distribution: zulu
+ java-version: 17
+
+ - name: Setup Gradle
+ uses: gradle/gradle-build-action@v2
+ with:
+ gradle-home-cache-cleanup: true
+
+ - name: Publish Plugin
+ env:
+ PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
+ CERTIFICATE_CHAIN: ${{ secrets.CERTIFICATE_CHAIN }}
+ PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
+ PRIVATE_KEY_PASSWORD: ${{ secrets.PRIVATE_KEY_PASSWORD }}
+ run: ./gradlew publishPlugin
+ working-directory: editors/intellij
+
+ - name: Extract changelog
+ run: |
+ bash scripts/print-changelog.sh ${{ needs.build.outputs.version }} >| ${{ github.workspace }}/RELEASE_NOTES
+ - name: Create GitHub release and tag
+ uses: softprops/action-gh-release@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ name: Intellij Plugin v${{ needs.build.outputs.version }}
+ tag_name: lsp-intellij/v${{ needs.build.outputs.version }}
+ draft: false
+ prerelease: ${{ needs.build.outputs.prerelease == 'true' }}
+ body_path: ${{ github.workspace }}/RELEASE_NOTES
+ files: |
+ ./editors/intellij/build/distributions/intellij-biome-*.zip
+ fail_on_unmatched_files: true
+ generate_release_notes: true
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 4d21e756eb8e..941c967e0c32 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -169,6 +169,25 @@ If files specific to your local development environment should be ignored, pleas
You can find more information on this process [here](https://help.github.com/en/github/using-git/ignoring-files#configuring-ignored-files-for-all-repositories-on-your-computer).
+## Intellij plugin
+
+To start development from source, navigate to the `editors/intellij` directory.
+
+Build and run the plugin requires:
+
+- Java development kit 17+
+- IntelliJ IDEA (Ultimate edition or community edition)
+
+### Running the plugin on IDEA
+```bash
+./gradlew runIde
+```
+
+### Build the plugin
+```bash
+./gradlew buildPlugin
+```
+
## Node.js development
The npm module `npm/biome` contains Biome's Node JS API that supports different backends:
diff --git a/editors/intellij/.gitignore b/editors/intellij/.gitignore
new file mode 100644
index 000000000000..e2e5d94ec76b
--- /dev/null
+++ b/editors/intellij/.gitignore
@@ -0,0 +1,4 @@
+.gradle
+.idea
+.qodana
+build
diff --git a/editors/intellij/.run/Run IDE for UI Tests.run.xml b/editors/intellij/.run/Run IDE for UI Tests.run.xml
new file mode 100644
index 000000000000..ee99b7edd496
--- /dev/null
+++ b/editors/intellij/.run/Run IDE for UI Tests.run.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ false
+ false
+
+
+
\ No newline at end of file
diff --git a/editors/intellij/.run/Run Plugin.run.xml b/editors/intellij/.run/Run Plugin.run.xml
new file mode 100644
index 000000000000..d15ff681a0de
--- /dev/null
+++ b/editors/intellij/.run/Run Plugin.run.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ false
+
+
+
\ No newline at end of file
diff --git a/editors/intellij/.run/Run Qodana.run.xml b/editors/intellij/.run/Run Qodana.run.xml
new file mode 100644
index 000000000000..c92f33c7cd68
--- /dev/null
+++ b/editors/intellij/.run/Run Qodana.run.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ false
+ false
+
+
+
\ No newline at end of file
diff --git a/editors/intellij/.run/Run Tests.run.xml b/editors/intellij/.run/Run Tests.run.xml
new file mode 100644
index 000000000000..132d9ad7416f
--- /dev/null
+++ b/editors/intellij/.run/Run Tests.run.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ false
+
+
+
diff --git a/editors/intellij/.run/Run Verifications.run.xml b/editors/intellij/.run/Run Verifications.run.xml
new file mode 100644
index 000000000000..3a8d68859b1d
--- /dev/null
+++ b/editors/intellij/.run/Run Verifications.run.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ false
+
+
+
+
+
\ No newline at end of file
diff --git a/editors/intellij/README.md b/editors/intellij/README.md
new file mode 100644
index 000000000000..02f2e607f1e8
--- /dev/null
+++ b/editors/intellij/README.md
@@ -0,0 +1,44 @@
+# Biome JetBrains IDEs Plugin
+
+https://biomejs.dev plugin for JetBrains IDEs.
+
+## features
+
+- Linting
+- Quickfix
+- Formatting
+
+---
+
+## Installation
+
+### From JetBrains IDEs
+
+- Press `⌘Сmd,` to open the IDE settings and then select Plugins.
+![Plugins](https://resources.jetbrains.com/help/img/idea/2023.2/ws_plugins_settings.png)
+- Search for Biome and click `install`
+
+### From disk
+
+- Download the plugin .zip from releases tab.
+- Press `⌘Сmd,` to open the IDE settings and then select Plugins.
+- On the Plugins page, click The Settings button and then click Install Plugin from Disk….
+
+## Building and running the plugin
+
+Build and run the plugin requires:
+
+- Java development kit 17+
+- IntelliJ IDEA (Ultimate edition or community edition)
+
+### Running the plugin on IDEA
+
+```shell
+./gradlew runIde
+```
+
+### Build the plugin
+
+```shell
+./gradlew buildPlugin
+```
diff --git a/editors/intellij/build.gradle.kts b/editors/intellij/build.gradle.kts
new file mode 100644
index 000000000000..948fa3f57ff3
--- /dev/null
+++ b/editors/intellij/build.gradle.kts
@@ -0,0 +1,71 @@
+fun properties(key: String) = providers.gradleProperty(key)
+fun environment(key: String) = providers.environmentVariable(key)
+
+plugins {
+ id("java") // Java support
+ alias(libs.plugins.kotlin) // Kotlin support
+ alias(libs.plugins.gradleIntelliJPlugin) // Gradle IntelliJ Plugin
+}
+
+group = properties("pluginGroup").get()
+version = properties("pluginVersion").get()
+
+// Configure project's dependencies
+repositories {
+ mavenCentral()
+}
+
+// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog
+dependencies {
+// implementation(libs.annotations)
+}
+
+// Set the JVM language level used to build the project. Use Java 11 for 2020.3+, and Java 17 for 2022.2+.
+kotlin {
+ jvmToolchain(17)
+}
+
+// Configure Gradle IntelliJ Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
+intellij {
+ pluginName = properties("pluginName")
+ version = properties("platformVersion")
+ type = properties("platformType")
+
+ // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
+ plugins = properties("platformPlugins").map { it.split(',').map(String::trim).filter(String::isNotEmpty) }
+}
+
+tasks {
+ wrapper {
+ gradleVersion = properties("gradleVersion").get()
+ }
+
+ patchPluginXml {
+ version = properties("pluginVersion")
+ sinceBuild = properties("pluginSinceBuild")
+ untilBuild = properties("pluginUntilBuild")
+ }
+
+ // Configure UI tests plugin
+ // Read more: https://github.com/JetBrains/intellij-ui-test-robot
+ runIdeForUiTests {
+ systemProperty("robot-server.port", "8082")
+ systemProperty("ide.mac.message.dialogs.as.sheets", "false")
+ systemProperty("jb.privacy.policy.text", "")
+ systemProperty("jb.consents.confirmation.enabled", "false")
+ }
+
+ signPlugin {
+ certificateChain = environment("CERTIFICATE_CHAIN")
+ privateKey = environment("PRIVATE_KEY")
+ password = environment("PRIVATE_KEY_PASSWORD")
+ }
+
+ publishPlugin {
+ token = environment("PUBLISH_TOKEN")
+ // The pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
+ // Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:
+ // https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
+ channels = properties("pluginVersion").map { listOf(it.split('-').getOrElse(1) { "default" }.split('.').first()) }
+ }
+}
diff --git a/editors/intellij/gradle.properties b/editors/intellij/gradle.properties
new file mode 100644
index 000000000000..67f6942706ff
--- /dev/null
+++ b/editors/intellij/gradle.properties
@@ -0,0 +1,34 @@
+# IntelliJ Platform Artifacts Repositories -> https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html
+
+pluginGroup = com.github.biomejs.intellijbiome
+pluginName = Biome
+pluginRepositoryUrl = https://github.com/biomejs/biome
+# SemVer format -> https://semver.org
+pluginVersion = 0.0.1
+
+# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
+pluginSinceBuild = 232
+pluginUntilBuild = 232.*
+
+# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
+platformType = IU
+platformVersion = 232-EAP-SNAPSHOT
+
+# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
+# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
+platformPlugins=JavaScript
+
+# Gradle Releases -> https://github.com/gradle/gradle/releases
+gradleVersion = 8.2.1
+
+# Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib
+kotlin.stdlib.default.dependency = false
+
+# Enable Gradle Configuration Cache -> https://docs.gradle.org/current/userguide/configuration_cache.html
+org.gradle.configuration-cache = true
+
+# Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html
+org.gradle.caching = true
+
+# Enable Gradle Kotlin DSL Lazy Property Assignment -> https://docs.gradle.org/current/userguide/kotlin_dsl.html#kotdsl:assignment
+systemProp.org.gradle.unsafe.kotlin.assignment = true
diff --git a/editors/intellij/gradle/libs.versions.toml b/editors/intellij/gradle/libs.versions.toml
new file mode 100644
index 000000000000..99297ef93f53
--- /dev/null
+++ b/editors/intellij/gradle/libs.versions.toml
@@ -0,0 +1,14 @@
+[versions]
+# libraries
+annotations = "24.0.1"
+
+# plugins
+kotlin = "1.9.0"
+gradleIntelliJPlugin = "1.15.0"
+
+[libraries]
+annotations = { group = "org.jetbrains", name = "annotations", version.ref = "annotations" }
+
+[plugins]
+gradleIntelliJPlugin = { id = "org.jetbrains.intellij", version.ref = "gradleIntelliJPlugin" }
+kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
diff --git a/editors/intellij/gradle/wrapper/gradle-wrapper.jar b/editors/intellij/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 000000000000..033e24c4cdf4
Binary files /dev/null and b/editors/intellij/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/editors/intellij/gradle/wrapper/gradle-wrapper.properties b/editors/intellij/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 000000000000..9f4197d5f4b9
--- /dev/null
+++ b/editors/intellij/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,7 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/editors/intellij/gradlew b/editors/intellij/gradlew
new file mode 100755
index 000000000000..fcb6fca147c0
--- /dev/null
+++ b/editors/intellij/gradlew
@@ -0,0 +1,248 @@
+#!/bin/sh
+
+#
+# Copyright © 2015-2021 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC3045
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command;
+# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
+# shell script including quotes and variable substitutions, so put them in
+# double quotes to make sure that they get re-expanded; and
+# * put everything else in single quotes, so that it's not re-expanded.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/editors/intellij/gradlew.bat b/editors/intellij/gradlew.bat
new file mode 100644
index 000000000000..93e3f59f135d
--- /dev/null
+++ b/editors/intellij/gradlew.bat
@@ -0,0 +1,92 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%"=="" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if %ERRORLEVEL% equ 0 goto execute
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if %ERRORLEVEL% equ 0 goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/editors/intellij/qodana.yml b/editors/intellij/qodana.yml
new file mode 100644
index 000000000000..f388de9a89c4
--- /dev/null
+++ b/editors/intellij/qodana.yml
@@ -0,0 +1,12 @@
+# Qodana configuration:
+# https://www.jetbrains.com/help/qodana/qodana-yaml.html
+
+version: 1.0
+linter: jetbrains/qodana-jvm-community:latest
+projectJDK: 17
+profile:
+ name: qodana.recommended
+exclude:
+ - name: All
+ paths:
+ - .qodana
diff --git a/editors/intellij/scripts/update-nightly-version.mjs b/editors/intellij/scripts/update-nightly-version.mjs
new file mode 100644
index 000000000000..75f41a7e29e4
--- /dev/null
+++ b/editors/intellij/scripts/update-nightly-version.mjs
@@ -0,0 +1,28 @@
+import * as fs from "node:fs";
+import { resolve } from "node:path";
+import { fileURLToPath } from "node:url";
+
+const EXTENSION_ROOT = resolve(fileURLToPath(import.meta.url), "../..");
+const GRADLE_PROPERTIES_PATH = resolve(EXTENSION_ROOT, "gradle.properties");
+const semverRegex =
+ /(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-(0|[1-9A-Za-z-][0-9A-Za-z-]*)(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?/g;
+const gradleProperties = fs
+ .readFileSync(GRADLE_PROPERTIES_PATH)
+ .toString("utf-8");
+const versionLineRegex = /^(pluginVersion =) (.+)$/gm;
+const versionLine = gradleProperties.match(versionLineRegex)[0];
+let version = versionLine.match(semverRegex);
+
+if (
+ typeof process.env.GITHUB_SHA !== "string" ||
+ process.env.GITHUB_SHA === ""
+) {
+ throw new Error("GITHUB_SHA environment variable is undefined");
+}
+
+version += `-nightly.${process.env.GITHUB_SHA.substring(0, 7)}`;
+
+const content = gradleProperties.replace(versionLineRegex, `$1 ${version}`);
+fs.writeFileSync(GRADLE_PROPERTIES_PATH, content);
+
+console.log(version);
diff --git a/editors/intellij/settings.gradle.kts b/editors/intellij/settings.gradle.kts
new file mode 100644
index 000000000000..30eabbe74cd5
--- /dev/null
+++ b/editors/intellij/settings.gradle.kts
@@ -0,0 +1 @@
+rootProject.name = "intellij-biome"
diff --git a/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/BiomeBundle.kt b/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/BiomeBundle.kt
new file mode 100644
index 000000000000..f039b999d2b2
--- /dev/null
+++ b/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/BiomeBundle.kt
@@ -0,0 +1,21 @@
+package com.github.biomejs.intellijbiome
+
+import com.intellij.DynamicBundle
+import org.jetbrains.annotations.NonNls
+import org.jetbrains.annotations.PropertyKey
+
+@NonNls
+private const val BUNDLE = "messages.BiomeBundle"
+
+object BiomeBundle : DynamicBundle(BUNDLE) {
+
+ @Suppress("SpreadOperator")
+ @JvmStatic
+ fun message(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) =
+ getMessage(key, *params)
+
+ @Suppress("SpreadOperator", "unused")
+ @JvmStatic
+ fun messagePointer(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) =
+ getLazyMessage(key, *params)
+}
diff --git a/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/BiomeUtils.kt b/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/BiomeUtils.kt
new file mode 100644
index 000000000000..4456481f31fa
--- /dev/null
+++ b/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/BiomeUtils.kt
@@ -0,0 +1,57 @@
+package com.github.biomejs.intellijbiome
+
+import com.github.biomejs.intellijbiome.settings.BiomeSettings
+import com.intellij.execution.configurations.GeneralCommandLine
+import com.intellij.execution.util.ExecUtil
+import com.intellij.javascript.nodejs.library.node_modules.NodeModulesDirectoryManager
+import com.intellij.openapi.diagnostic.Logger
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.vfs.VirtualFile
+import com.intellij.util.SmartList
+import java.io.File
+
+
+object BiomeUtils {
+ fun isSupportedFileType(file: VirtualFile): Boolean = when (file.extension) {
+ "js", "mjs", "cjs", "jsx", "ts", "mts", "cts", "tsx", "d.ts", "json", "jsonc" -> true
+ else -> false
+ }
+
+ fun getBiomeVersion(project: Project, binaryPath: String): String? {
+ if (binaryPath.isEmpty()) {
+ return null
+ }
+
+ val versionRegex = Regex("\\d{1,2}\\.\\d{1,2}\\.\\d{1,3}")
+ val commandLine = createVersionCommandLine(project, binaryPath)
+
+ val output = ExecUtil.execAndGetOutput(commandLine)
+
+ val matchResult = versionRegex.find(output.stdout)
+
+ return matchResult?.value
+ }
+
+ fun getBiomeExecutablePath(project: Project): String? {
+ val directoryManager = NodeModulesDirectoryManager.getInstance(project)
+ val executablePath = BiomeSettings.getInstance(project).executablePath
+ val biomeBinFile = directoryManager.nodeModulesDirs
+ .asSequence()
+ .mapNotNull { it.findFileByRelativePath(".bin/biome") }
+ .filter { it.isValid }
+ .firstOrNull()
+
+ if (executablePath.isEmpty()) {
+ return biomeBinFile?.path
+ }
+
+ return executablePath
+ }
+
+ private fun createVersionCommandLine(project: Project, binaryPath: String): GeneralCommandLine {
+ return GeneralCommandLine()
+ .withWorkDirectory(project.basePath)
+ .withExePath(binaryPath)
+ .withParameters("--version")
+ }
+}
diff --git a/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/actions/RestartBiomeServerAction.kt b/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/actions/RestartBiomeServerAction.kt
new file mode 100644
index 000000000000..aeab4f549cb6
--- /dev/null
+++ b/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/actions/RestartBiomeServerAction.kt
@@ -0,0 +1,18 @@
+package com.github.biomejs.intellijbiome.actions
+
+import com.intellij.openapi.actionSystem.AnAction
+import com.intellij.openapi.actionSystem.AnActionEvent
+import com.intellij.openapi.components.service
+import com.github.biomejs.intellijbiome.services.BiomeServerService
+
+class RestartBiomeServerAction : AnAction() {
+ override fun actionPerformed(actionEvent: AnActionEvent) {
+ val project = actionEvent.project
+ if (project == null || project.isDefault) return
+
+ val biomeServerService = project.service()
+
+ biomeServerService.restartBiomeServer()
+ biomeServerService.notifyRestart()
+ }
+}
diff --git a/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/formatter/BiomeFormatterProvider.kt b/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/formatter/BiomeFormatterProvider.kt
new file mode 100644
index 000000000000..7eb229465a53
--- /dev/null
+++ b/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/formatter/BiomeFormatterProvider.kt
@@ -0,0 +1,79 @@
+package com.github.biomejs.intellijbiome.formatter
+
+import com.github.biomejs.intellijbiome.BiomeBundle
+import com.github.biomejs.intellijbiome.BiomeUtils
+import com.intellij.execution.configurations.GeneralCommandLine
+import com.intellij.execution.process.CapturingProcessAdapter
+import com.intellij.execution.process.OSProcessHandler
+import com.intellij.execution.process.ProcessEvent
+import com.intellij.formatting.service.AsyncDocumentFormattingService
+import com.intellij.formatting.service.AsyncFormattingRequest
+import com.intellij.formatting.service.FormattingService.Feature
+import com.intellij.openapi.diagnostic.thisLogger
+import com.intellij.psi.PsiFile
+import com.intellij.util.SmartList
+import org.jetbrains.annotations.NotNull
+import java.nio.charset.StandardCharsets
+import java.util.EnumSet
+import com.intellij.execution.ExecutionException
+
+class BiomeFormatterProvider : AsyncDocumentFormattingService() {
+ override fun getFeatures(): MutableSet = EnumSet.noneOf(Feature::class.java)
+
+ override fun canFormat(file: PsiFile): Boolean =
+ file.virtualFile?.let { BiomeUtils.isSupportedFileType(it) } ?: false
+
+ override fun getNotificationGroupId(): String = "Biome"
+
+ override fun getName(): String = "Biome"
+
+ override fun createFormattingTask(request: AsyncFormattingRequest): FormattingTask? {
+ val ioFile = request.ioFile ?: return null
+ val project = request.context.project
+ val params = SmartList("format", "--stdin-file-path", ioFile.path)
+
+ val exePath = BiomeUtils.getBiomeExecutablePath(project)
+
+ if (exePath.isNullOrEmpty()) {
+ throw ExecutionException(BiomeBundle.message("biome.language.server.not.found"))
+ }
+
+ try {
+ val commandLine: GeneralCommandLine = GeneralCommandLine()
+ .withExePath(exePath)
+ .withParentEnvironmentType(GeneralCommandLine.ParentEnvironmentType.CONSOLE)
+ .withInput(ioFile)
+ .withParameters(params)
+
+ val handler = OSProcessHandler(commandLine.withCharset(StandardCharsets.UTF_8))
+ return object : FormattingTask {
+ override fun run() {
+ handler.addProcessListener(object : CapturingProcessAdapter() {
+ override fun processTerminated(@NotNull event: ProcessEvent) {
+ val exitCode = event.exitCode
+ if (exitCode == 0) {
+ request.onTextReady(output.stdout)
+ } else {
+ request.onError(BiomeBundle.message("biome.formatting.failure"), output.stderr)
+ }
+ }
+ })
+ handler.startNotify()
+ }
+
+ override fun cancel(): Boolean {
+ handler.destroyProcess()
+ return true
+ }
+
+ override fun isRunUnderProgress(): Boolean {
+ return true
+ }
+ }
+ } catch (error: ExecutionException) {
+ val message = error.message ?: ""
+ request.onError(BiomeBundle.message("biome.formatting.failure"), message)
+ return null
+ }
+ }
+}
diff --git a/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/listeners/BiomeConfigListener.kt b/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/listeners/BiomeConfigListener.kt
new file mode 100644
index 000000000000..c3d79807e9fb
--- /dev/null
+++ b/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/listeners/BiomeConfigListener.kt
@@ -0,0 +1,20 @@
+package com.github.biomejs.intellijbiome.listeners
+
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.vfs.newvfs.BulkFileListener
+import com.intellij.openapi.vfs.newvfs.events.VFileEvent
+import com.intellij.openapi.components.service
+import com.github.biomejs.intellijbiome.services.BiomeServerService
+
+class BiomeConfigListener(val project: Project) : BulkFileListener {
+ override fun after(events: MutableList) {
+ super.after(events)
+ events.forEach {
+ if (it.file?.name?.contains("biome.json") == true) {
+ val biomeServerService = project.service()
+
+ biomeServerService.restartBiomeServer()
+ }
+ }
+ }
+}
diff --git a/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/lsp/BiomeLspServerSupportProvider.kt b/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/lsp/BiomeLspServerSupportProvider.kt
new file mode 100644
index 000000000000..e4cd108e331c
--- /dev/null
+++ b/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/lsp/BiomeLspServerSupportProvider.kt
@@ -0,0 +1,51 @@
+package com.github.biomejs.intellijbiome.lsp
+
+import com.github.biomejs.intellijbiome.BiomeBundle
+import com.github.biomejs.intellijbiome.BiomeUtils
+import com.intellij.execution.ExecutionException
+import com.intellij.execution.configurations.GeneralCommandLine
+import com.intellij.openapi.diagnostic.thisLogger
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.vfs.VirtualFile
+import com.intellij.platform.lsp.api.LspServerSupportProvider
+import com.intellij.platform.lsp.api.ProjectWideLspServerDescriptor
+import com.intellij.platform.lsp.api.customization.LspCodeActionsSupport
+import com.intellij.platform.lsp.api.customization.LspDiagnosticsSupport
+import com.intellij.util.SmartList
+import org.eclipse.lsp4j.*
+
+@Suppress("UnstableApiUsage")
+class BiomeLspServerSupportProvider : LspServerSupportProvider {
+
+ override fun fileOpened(
+ project: Project,
+ file: VirtualFile,
+ serverStarter: LspServerSupportProvider.LspServerStarter
+ ) {
+ if (BiomeUtils.isSupportedFileType(file)) {
+ val executable = BiomeUtils.getBiomeExecutablePath(project) ?: return
+
+ serverStarter.ensureServerStarted(BiomeLspServerDescriptor(project, executable))
+ }
+ }
+}
+
+@Suppress("UnstableApiUsage")
+private class BiomeLspServerDescriptor(project: Project, val executable: String) :
+ ProjectWideLspServerDescriptor(project, "Biome") {
+ override fun isSupportedFile(file: VirtualFile) = BiomeUtils.isSupportedFileType(file)
+ override fun createCommandLine(): GeneralCommandLine {
+ val params = SmartList("lsp-proxy")
+
+ if (executable.isEmpty()) {
+ throw ExecutionException(BiomeBundle.message("biome.language.server.not.found"))
+ }
+
+ return GeneralCommandLine()
+ .withExePath(executable)
+ .withParameters(params)
+ }
+
+ override val lspGoToDefinitionSupport = false
+ override val lspCompletionSupport = null
+}
diff --git a/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/services/BiomeServerService.kt b/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/services/BiomeServerService.kt
new file mode 100644
index 000000000000..9a2ea950dccb
--- /dev/null
+++ b/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/services/BiomeServerService.kt
@@ -0,0 +1,28 @@
+package com.github.biomejs.intellijbiome.services
+
+import com.intellij.openapi.components.Service
+import com.intellij.openapi.project.Project
+import com.github.biomejs.intellijbiome.BiomeBundle
+import com.github.biomejs.intellijbiome.lsp.BiomeLspServerSupportProvider
+import com.intellij.notification.NotificationGroupManager
+import com.intellij.notification.NotificationType
+import com.intellij.platform.lsp.api.LspServerManager
+
+@Service(Service.Level.PROJECT)
+class BiomeServerService(private val project: Project) {
+
+ fun restartBiomeServer() {
+ LspServerManager.getInstance(project).stopAndRestartIfNeeded(BiomeLspServerSupportProvider::class.java)
+ }
+
+ fun notifyRestart() {
+ NotificationGroupManager.getInstance()
+ .getNotificationGroup("Biome")
+ .createNotification(
+ BiomeBundle.message("biome.language.server.restarted"),
+ "",
+ NotificationType.INFORMATION
+ )
+ .notify(project)
+ }
+}
diff --git a/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/settings/BiomeSettings.kt b/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/settings/BiomeSettings.kt
new file mode 100644
index 000000000000..b61bc307d87e
--- /dev/null
+++ b/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/settings/BiomeSettings.kt
@@ -0,0 +1,20 @@
+package com.github.biomejs.intellijbiome.settings
+
+import com.intellij.openapi.components.*
+import com.intellij.openapi.project.Project
+
+@Service(Service.Level.PROJECT)
+@State(name = "BiomeSettings", storages = [(Storage("biome.xml"))])
+class BiomeSettings :
+ SimplePersistentStateComponent(BiomeSettingsState()) {
+ var executablePath: String
+ get() = state.executablePath ?: ""
+ set(value) {
+ state.executablePath = value
+ }
+
+ companion object {
+ @JvmStatic
+ fun getInstance(project: Project): BiomeSettings = project.service()
+ }
+}
diff --git a/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/settings/BiomeSettingsConfigurable.kt b/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/settings/BiomeSettingsConfigurable.kt
new file mode 100644
index 000000000000..faec24836183
--- /dev/null
+++ b/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/settings/BiomeSettingsConfigurable.kt
@@ -0,0 +1,39 @@
+package com.github.biomejs.intellijbiome.settings
+
+import com.github.biomejs.intellijbiome.BiomeBundle
+import com.github.biomejs.intellijbiome.services.BiomeServerService
+import com.intellij.openapi.components.service
+import com.intellij.openapi.options.BoundSearchableConfigurable
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.ui.DialogPanel
+import com.intellij.openapi.vfs.VirtualFile
+import com.intellij.ui.dsl.builder.bindText
+import com.intellij.ui.dsl.builder.panel
+
+class BiomeSettingsConfigurable(internal val project: Project) :
+ BoundSearchableConfigurable(
+ BiomeBundle.message("biome.settings.name"),
+ BiomeBundle.message("biome.settings.name")
+ ) {
+ override fun createPanel(): DialogPanel {
+ val settings: BiomeSettings = BiomeSettings.getInstance(project)
+ val biomeServerService = project.service()
+
+ return panel {
+ row(BiomeBundle.message("biome.path.label")) {
+ textFieldWithBrowseButton(BiomeBundle.message("biome.path.label")) { fileChosen(it) }
+ .bindText(settings::executablePath)
+ }
+
+ onApply {
+ biomeServerService.restartBiomeServer()
+ biomeServerService.notifyRestart()
+ }
+ }
+
+ }
+
+ fun fileChosen(file: VirtualFile): String {
+ return file.path
+ }
+}
diff --git a/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/settings/BiomeSettingsState.kt b/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/settings/BiomeSettingsState.kt
new file mode 100644
index 000000000000..aea197f20726
--- /dev/null
+++ b/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/settings/BiomeSettingsState.kt
@@ -0,0 +1,11 @@
+package com.github.biomejs.intellijbiome.settings
+
+import com.intellij.openapi.components.BaseState
+import com.intellij.openapi.components.Service
+import org.jetbrains.annotations.ApiStatus
+
+@Service
+@ApiStatus.Internal
+class BiomeSettingsState : BaseState() {
+ var executablePath by string()
+}
diff --git a/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/widgets/BiomeStatusBarWidgetFactory.kt b/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/widgets/BiomeStatusBarWidgetFactory.kt
new file mode 100644
index 000000000000..85b8200e1f02
--- /dev/null
+++ b/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/widgets/BiomeStatusBarWidgetFactory.kt
@@ -0,0 +1,19 @@
+package com.github.biomejs.intellijbiome.widgets
+
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.wm.StatusBarWidget
+import com.intellij.openapi.wm.StatusBarWidgetFactory
+
+class BiomeStatusBarWidgetFactory : StatusBarWidgetFactory {
+ override fun getId(): String {
+ return "BiomeWidget"
+ }
+
+ override fun getDisplayName(): String {
+ return "Biome"
+ }
+
+ override fun createWidget(project: Project): StatusBarWidget {
+ return BiomeWidget(project)
+ }
+}
diff --git a/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/widgets/BiomeWidget.kt b/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/widgets/BiomeWidget.kt
new file mode 100644
index 000000000000..a6fbc72f6d7f
--- /dev/null
+++ b/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/widgets/BiomeWidget.kt
@@ -0,0 +1,16 @@
+package com.github.biomejs.intellijbiome.widgets
+
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.wm.StatusBarWidget
+import com.intellij.openapi.wm.impl.status.EditorBasedWidget
+
+class BiomeWidget(myProject: Project) : EditorBasedWidget(myProject) {
+
+ override fun ID(): String {
+ return "BiomeWidget"
+ }
+
+ override fun getPresentation(): StatusBarWidget.WidgetPresentation {
+ return BiomeWidgetPresentation(project)
+ }
+}
diff --git a/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/widgets/BiomeWidgetPresentation.kt b/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/widgets/BiomeWidgetPresentation.kt
new file mode 100644
index 000000000000..a757d9068631
--- /dev/null
+++ b/editors/intellij/src/main/kotlin/com/github/biomejs/intellijbiome/widgets/BiomeWidgetPresentation.kt
@@ -0,0 +1,49 @@
+package com.github.biomejs.intellijbiome.widgets
+
+import com.github.biomejs.intellijbiome.BiomeBundle
+import com.github.biomejs.intellijbiome.BiomeUtils
+import com.github.biomejs.intellijbiome.lsp.BiomeLspServerSupportProvider
+import com.intellij.openapi.progress.ProgressManager
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.wm.StatusBarWidget
+import com.intellij.platform.lsp.api.LspServerManager
+import com.intellij.platform.lsp.impl.LspServerImpl
+
+@Suppress("UnstableApiUsage")
+class BiomeWidgetPresentation(private val project: Project) : StatusBarWidget.MultipleTextValuesPresentation {
+ override fun getSelectedValue(): String? {
+ val biomeBin = BiomeUtils.getBiomeExecutablePath(project)
+ val progressManager = ProgressManager.getInstance()
+
+ if (biomeBin == null) {
+ return null
+ }
+
+ val version = progressManager.runProcessWithProgressSynchronously({
+ BiomeUtils.getBiomeVersion(project, biomeBin)
+ }, BiomeBundle.message("biome.loading"), true, project)
+
+
+ return "Biome ${version}"
+ }
+
+ override fun getTooltipText(): String? {
+ val lspServerManager = LspServerManager.getInstance(project)
+ val lspServer = lspServerManager.getServersForProvider(BiomeLspServerSupportProvider::class.java).firstOrNull()
+
+ return when (lspServer) {
+ is LspServerImpl -> {
+ if (lspServer.isRunning) {
+ BiomeBundle.message("biome.language.server.is.running")
+ } else {
+ BiomeBundle.message("biome.language.server.is.stopped")
+ }
+ }
+
+ else -> {
+ BiomeBundle.message("biome.language.server.is.stopped")
+ }
+ }
+
+ }
+}
diff --git a/editors/intellij/src/main/resources/META-INF/plugin.xml b/editors/intellij/src/main/resources/META-INF/plugin.xml
new file mode 100644
index 000000000000..22484394b3bf
--- /dev/null
+++ b/editors/intellij/src/main/resources/META-INF/plugin.xml
@@ -0,0 +1,57 @@
+
+
+ com.github.biomejs.intellijbiome
+ Biome
+ biomejs
+ Biome plugin for JetBrains IDEs.
+
+ Features
+
+
+ - Linting
+ - Quick Fix (from mouse-over,
⌥⏎
or Alt+Enter
)
+ - Reformat your code with
⌥⇧ ⌘ L
or Ctrl+Alt+L
+
+ ]]>
+
+
+ com.intellij.modules.platform
+ com.intellij.modules.ultimate
+ JavaScript
+
+ messages.BiomeBundle
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/editors/intellij/src/main/resources/META-INF/pluginIcon.svg b/editors/intellij/src/main/resources/META-INF/pluginIcon.svg
new file mode 100644
index 000000000000..32969871b8c3
--- /dev/null
+++ b/editors/intellij/src/main/resources/META-INF/pluginIcon.svg
@@ -0,0 +1,4 @@
+
diff --git a/editors/intellij/src/main/resources/icons/pluginIcon.svg b/editors/intellij/src/main/resources/icons/pluginIcon.svg
new file mode 100644
index 000000000000..bed6c6efcf9d
--- /dev/null
+++ b/editors/intellij/src/main/resources/icons/pluginIcon.svg
@@ -0,0 +1,3 @@
+
diff --git a/editors/intellij/src/main/resources/messages/BiomeBundle.properties b/editors/intellij/src/main/resources/messages/BiomeBundle.properties
new file mode 100644
index 000000000000..14ec8b7ccb0a
--- /dev/null
+++ b/editors/intellij/src/main/resources/messages/BiomeBundle.properties
@@ -0,0 +1,9 @@
+name=Biome
+biome.path.label=Biome CLI Path
+biome.settings.name=Biome Settings
+biome.formatting.failure=Formatting error
+biome.language.server.not.found=Biome language server is not found, make sure you have @biomejs/biome installed.
+biome.loading=Biome is loading...
+biome.language.server.is.running=Biome server is running
+biome.language.server.is.stopped=Biome server is stopped
+biome.language.server.restarted=Biome server restarted
diff --git a/editors/intellij/src/test/kotlin/com/github/biomejs/intellijbiome/MyPluginTest.kt b/editors/intellij/src/test/kotlin/com/github/biomejs/intellijbiome/MyPluginTest.kt
new file mode 100644
index 000000000000..27a4f7d92ed5
--- /dev/null
+++ b/editors/intellij/src/test/kotlin/com/github/biomejs/intellijbiome/MyPluginTest.kt
@@ -0,0 +1,11 @@
+package com.github.biomejs.intellijbiome
+
+import com.intellij.testFramework.TestDataPath
+import com.intellij.testFramework.fixtures.BasePlatformTestCase
+
+@TestDataPath("\$CONTENT_ROOT/src/test/testData")
+class MyPluginTest : BasePlatformTestCase() {
+ fun testExample() {
+ assert("hello-world" == "hello-world")
+ }
+}