This sub-project is a prototype port of the VS Code “NC Viewer” extension into an IntelliJ Platform plugin that targets IntelliJ IDEA (and other 2024.2+ IDEs). It embeds the existing Three.js-based web viewer inside a JCEF panel and mirrors the VS Code messaging contract so caret changes and file edits stay in sync with the 3D preview.
- IntelliJ Platform: 2024.2 Community Edition (or newer) since the Gradle IntelliJ plugin is pinned to that build.
- JDK: 17 (JetBrains Runtime ships with the IDE; point Gradle to it to skip toolchain downloads).
- Gradle: Wrapper is included (
gradlew/gradlew.bat), so no global install required.
src/main/resources/ncviewer/media— bundled Three.js viewer assets copied directly from the VS Code project.src/main/kotlin/com/ncviewer/idea/ui/NcViewerPanel.kt— hosts the viewer inside aJBCefBrowserand bridges messages.src/main/kotlin/com/ncviewer/idea/actions/OpenNcViewerAction.kt— editor action that opens the tool window for.nc/.gcode/.cncfiles.src/main/kotlin/com/ncviewer/idea/service/NcViewerProjectService.kt— project-level service that wires actions and the tool window.src/main/resources/META-INF/plugin.xml— IntelliJ plugin metadata, action registrations, and tool window declaration.
cd nc_viewer_idea
./gradlew build # compiles Kotlin + packages plugin zip under build/distributions
./gradlew runIde # launches a sandboxed IntelliJ IDEA with the plugin installedIf you need Windows command prompts, substitute
gradlew.batfor./gradlew.
./gradlew test— runs Kotlin/JVM tests (currently placeholder)../gradlew verifyPlugin— JetBrains plugin validation (signatures, descriptors, etc.)../gradlew clean buildPlugin— produces the distributable archive you can install manually.
By default the Gradle IntelliJ plugin downloads the target IDE + JetBrains Runtime. You can instead point the build to your already-installed IntelliJ IDEA and its bundled JBR:
- Opt-in by editing
nc_viewer_idea/gradle.properties(or~/.gradle/gradle.properties) and setting:Use an IntelliJ build whoseidea.local.path=/path/to/idea-IC-242.23726.103/IntelliJ IDEA CE.app/Contents org.gradle.java.home=/path/to/idea-IC-242.23726.103/IntelliJ IDEA CE.app/Contents/jbr/Contents/HomeResources/product-info.jsonreports the same major version (2024.2) and whoselib/modulesdirectory contains version-suffixed jars (Toolbox installs auto-updated to 2025.x omit these and will fail to resolve dependencies). - Alternatively, pass the overrides per build:
./gradlew build -Didea.local.path="/path/to/idea-IC-242.23726.103/IntelliJ IDEA CE.app/Contents" \ -Dorg.gradle.java.home="/path/to/idea-IC-242.23726.103/IntelliJ IDEA CE.app/Contents/jbr/Contents/Home"
If the properties are left empty or point to an incompatible install, the build automatically falls back to downloading the matching IntelliJ distribution.
- Web Assets: The viewer expects the same relative file paths as the VS
Code extension. Copy updates from the root
media/folder intosrc/main/resources/ncviewer/mediato keep them in sync. - Message Bridge: Instead of relying on
JBCefJSQuery, the viewer now talks to the host over a localhttp://127.0.0.1:<port>/ncbridgeloopback server. Kotlin pushesloadGCode/contentChangedpayloads into the server, and the Three.js page polls + posts JSON so the contract (loadGCode,cursorPositionChanged,contentChanged,highlightLine,bridgeDebug) stays unchanged but is far more reliable. The webview also auto-syncs its light/dark palette toprefers-color-scheme(or anydata-themeoverride injected by the host) so it blends into the IDE theme automatically.
Verbose bridge logging is automatically enabled when
-Didea.is.internal=true; for production builds leave it unset (or pass-Dncviewer.verboseLog=false) to suppress per-message log spam. 3. Settings:NcViewerSettingsstores theexcludeCodesarray. A UI is not implemented yet; values can be tweaked via theNcViewerSettingsservice for now. 4. IDE Compatibility: Because the tool window usesJBCefBrowser, the target IDE must ship with JCEF (true for 2020.3+ builds). Stick to 2024.2+ until we broaden testing.
- Add a proper Settings/Preferences page to edit exclude-code lists.
Pushes to main/master run checks, while annotated tags trigger the release
pipeline defined in .github/workflows/build.yml. On tag builds the workflow
now:
- Builds the plugin ZIP via
./gradlew buildPlugin. - Publishes the artifact to the JetBrains Marketplace via
./gradlew publishPlugin. - Uploads the same ZIP to the GitHub release for convenience.
To enable Marketplace publishing, create a permanent token in your JetBrains
Marketplace profile and add it as the repository secret
JETBRAINS_MARKETPLACE_TOKEN. Optionally define
JETBRAINS_MARKETPLACE_CHANNELS (comma-delimited; defaults to default) to
steer which channel receives the upload.