Skip to content

Integrate IntelliJ plugin into pnpm 🚀 #420

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/archive-vscode-artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ jobs:
- name: Setup antlr4
uses: ./.github/actions/setup-antlr4

- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'

- name: Install dependencies with frozen lock file and generate parser
run: npm ci

Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/benchmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ jobs:
- name: Setup antlr4
uses: ./.github/actions/setup-antlr4

- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'

- name: Install dependencies with frozen lock file and generate parser
run: npm ci

Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ jobs:
- name: Setup antlr4
uses: ./.github/actions/setup-antlr4

- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'

- name: Install dependencies with frozen lock file and generate parser
run: npm ci

Expand All @@ -45,6 +50,11 @@ jobs:
- name: Setup antlr4
uses: ./.github/actions/setup-antlr4

- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'

- name: Install dependencies with frozen lock file and generate parser
run: npm ci

Expand All @@ -63,6 +73,11 @@ jobs:
- name: Setup antlr4
uses: ./.github/actions/setup-antlr4

- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'

- name: Install dependencies
run: npm ci

Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/deploy-demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ jobs:
- name: Setup antlr4
uses: ./.github/actions/setup-antlr4

- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'

- name: Install dependencies with frozen lock file and generate parser
run: npm ci

Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/publish-vscode-extension.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ jobs:
- name: Setup antlr4
uses: ./.github/actions/setup-antlr4

- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'

- name: Install dependencies with frozen lock file
run: npm ci

Expand Down
47 changes: 45 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,49 @@ generated
*.tsbuildinfo
*.npmrc
benchmarks.txt
.idea/
vite.config.ts.timestamp*
.wdio-vscode-service
.wdio-vscode-service.gradle
.run

## Gradle ##
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/
.intellijPlatform

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store

### Javascript files
*.js
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The project comprises several packages:
- [language-support](./packages/language-support/README.md) - The core library implementing the language support features.
- [language-server](./packages/language-server/README.md) - The language server wrapper for the `language-support` package.
- [vscode-extension](./packages/vscode-extension/README.md) - The Neo4j VS Code extension which bundles the `language-server`
- [intellij-extension](./packages/intellij-extension/README.md) - The Neo4j Intellij plugin which bundles the `language-server`
- [react-codemirror](./packages/react-codemirror/README.md) - A set of [codemirror6](https://codemirror.net/) cypher language support plugins and a react wrapper.
- [react-codemirror-playground](./packages/react-codemirror-playground/README.md) - A playground for the codemirror integration.
- [schema-poller](./packages/schema-poller/README.md) - An internal package we use to manage the Neo4j connection and keep the schema (procedure names, labels, database names, etc.) up to date in the language server.
Expand Down
24 changes: 0 additions & 24 deletions editor-plugin/intellij/.run/Run IDE with Plugin.run.xml

This file was deleted.

8 changes: 0 additions & 8 deletions editor-plugin/intellij/README.md

This file was deleted.

9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"prepare": "husky install",
"build": "turbo run build",
"build-vscode": "turbo run neo4j-for-vscode#build:dev",
"build-intellij": "turbo run neo4j-for-intellij#build",
"release": "turbo run build && npx changeset publish",
"clean": "turbo run clean",
"watch": "turbowatch ./turbowatch.ts",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.gradle
.run
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
Expand Down
37 changes: 37 additions & 0 deletions packages/intellij-extension/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Neo4j Cypher LSP support for IntelliJ

## Build and run

Run through the [prerequisites](../../CONTRIBUTING.md#building-the-project).

You can build the plugin from the project root using [`turbo`](https://turbo.build):

```
$ npx turbo neo4j-for-intellij#build
```

`gradle` is also an option (and can be used from within IntelliJ):

```
$ cd packages/intellij-extension && ./gradlew buildPlugin
```

## Develop and test

If you want to test the plugin during a development workflow, you can spin up a temporary copy
of IntelliJ that runs with a freshly built version enabled by default:

```
$ npx turbo neo4j-for-intellij#runIde
```

...this target also exists in `gradle`:

```
$ cd packages/intellij-extension && ./gradlew runIde
```

## Installing the plugin manually

From IntelliJ, open Settings > Plugins > (cog icon) > Install Plugin from disk, and browse to the jar file
located in `packages/intellij-extension/build/distributions`.
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,48 @@ tasks {
}
}

prepareSandbox {
doFirst {
task("bundleServer") {
val outputFile = file("../language-server/dist/cypher-language-server.js")
val targetDir = file(".")

inputs.file(outputFile)
outputs.file(targetDir.resolve("cypher-language-server.js"))

doLast {
exec {
commandLine("bash", "-c", "cd ../.. && npm run build && cp packages/language-server/dist/cypher-language-server.js ./editor-plugin/intellij")
workingDir = file("../language-server")
commandLine = listOf("bash", "-c", "npm run bundle")
}

copy {
from(outputFile)
into(targetDir)
}
}
}

prepareSandbox {
dependsOn("bundleServer")

from(".") {
include("*.js")
into("cypher-lsp-support")
into("neo4j-for-intellij")
}
}

patchPluginXml {
sinceBuild.set("242")
untilBuild.set("242.*")
buildPlugin {
dependsOn(prepareSandbox)
}

runIde {
dependsOn(buildPlugin, prepareSandbox)

debugOptions {
enabled = false
port = 8000
server = true
suspend = true
}
}

signPlugin {
Expand Down
File renamed without changes.
14 changes: 14 additions & 0 deletions packages/intellij-extension/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "neo4j-for-intellij",
"version": "1.0.0",
"description": "Highlighting, completions and more for Neo4j Cypher in IntelliJ",
"publisher": "neo4j-extensions",
"author": "Neo4j Inc.",
"license": "Apache-2.0",
"preview": true,
"scripts": {
"build": "./gradlew -q buildPlugin",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to have this as:

if [[ \"$BUILD_INTELLIJ\" == \"true\" ]]; then ./gradlew -q buildPlugin; else echo 'Skipping Intellij build, set BUILD_INTELLIJ=true if that is not the desired behaviour'; fi

So this does not get executed for the people that work currently on the repo unless they specifically have that env variable set. The reason is we have 4 / 5 people that contribute regularly right now from the company, some of them using OSX, some using Windows, so I don't want to force them to install Kubernetes locally.

Copy link
Collaborator

@ncordon ncordon Apr 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anderson4j can you try this works for you if we gated the code?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, this skips and regular build works!

Copy link
Contributor Author

@jamthief jamthief Apr 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ncordon I think I get your gist - although it needs a single equals sign to work: [[ \"$BUILD_INTELLIJ\" = \"true\" ]] - unfortunately though, this gets cached by turbo. So running it with a different value will just do the same thing over and over, even if you change the environment variable. I guess we could make a special build target instead?

However, in principle, I want to argue against doing this anyway. My reasoning is as follows:

  • The VS code extension and the IntelliJ plugin are both at identical positions in the build hierarchy: they are dependent on the language server build, and they are leaf node outputs. Running a generalised build at the top level should be the equivalent of something like make all; it should attempt to build everything by default.
  • If a developer has a workflow involving one or the other plugin, they should use the specialised build target
  • If running the whole build doesn't work in CI, this PR is incomplete
  • If we don't attempt to build it regularly, and fail the build when it also fails, then we won't know when we've broken it, and the plugin will become stale

"clean": "./gradlew -q clean",
"runIde": "./gradlew -q runIde"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ pluginManagement {
}
}

rootProject.name = "cypher-lsp-support"
rootProject.name = "neo4j-for-intellij"
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package org.neo4j.intellij.lsp.language;

import com.intellij.lang.Language;
import org.jetbrains.annotations.NotNull;

public class CypherLanguage extends Language {

public static final CypherLanguage INSTANCE = new CypherLanguage();

private CypherLanguage() {
super("Cypher");
}

@Override
public @NotNull String getDisplayName() {
return "Cypher";
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<idea-plugin>
<id>org.neo4j.intellij.lsp.cypher-lsp-support</id>
<id>org.neo4j.intellij.lsp.neo4j-for-intellij</id>

<name>Cypher Lsp Support</name>
<!-- see https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html -->
<idea-version since-build="242.23339"/>

<name>Neo4j for IntelliJ</name>

<vendor url="https://www.neo4j.com">Neo4j Inc.</vendor>

Expand All @@ -17,11 +20,13 @@
<extensions defaultExtensionNs="com.intellij">
<platform.lsp.serverSupportProvider
implementation="org.neo4j.intellij.lsp.cypherlspsupport.CypherLspServerSupportProvider"/>

<fileType
name="Cypher File"
language="Cypher"
implementationClass="org.neo4j.intellij.lsp.language.CypherFileType"
extensions="cypher"
fieldName="INSTANCE"
language="Cypher"
extensions="cypher"/>
/>
</extensions>
</idea-plugin>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<font face="verdana" size="-1">This file template is used whenever you create a new Cypher file.</font>
Loading
Loading