diff --git a/core/src/main/kotlin/com/falsepattern/zigbrains/ZBStartup.kt b/core/src/main/kotlin/com/falsepattern/zigbrains/ZBStartup.kt
index 5d6a1d7f..88e78369 100644
--- a/core/src/main/kotlin/com/falsepattern/zigbrains/ZBStartup.kt
+++ b/core/src/main/kotlin/com/falsepattern/zigbrains/ZBStartup.kt
@@ -22,7 +22,6 @@
package com.falsepattern.zigbrains
-import com.falsepattern.zigbrains.direnv.DirenvCmd
import com.falsepattern.zigbrains.project.toolchain.local.LocalZigToolchain
import com.falsepattern.zigbrains.project.toolchain.base.suggestZigToolchain
import com.intellij.ide.BrowserUtil
diff --git a/core/src/main/kotlin/com/falsepattern/zigbrains/direnv/DirenvProjectService.kt b/core/src/main/kotlin/com/falsepattern/zigbrains/direnv/DirenvProjectService.kt
deleted file mode 100644
index fec31d4a..00000000
--- a/core/src/main/kotlin/com/falsepattern/zigbrains/direnv/DirenvProjectService.kt
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * This file is part of ZigBrains.
- *
- * Copyright (C) 2023-2025 FalsePattern
- * All Rights Reserved
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * ZigBrains is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, only version 3 of the License.
- *
- * ZigBrains is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with ZigBrains. If not, see .
- */
-
-package com.falsepattern.zigbrains.direnv
-
-import com.intellij.openapi.components.Service
-import com.intellij.openapi.components.service
-import com.intellij.openapi.project.Project
-import kotlinx.coroutines.sync.Mutex
-
-@Service(Service.Level.PROJECT)
-class DirenvProjectService {
- val mutex = Mutex()
-}
-
-val Project.direnvService get() = service()
\ No newline at end of file
diff --git a/core/src/main/kotlin/com/falsepattern/zigbrains/direnv/DirenvCmd.kt b/core/src/main/kotlin/com/falsepattern/zigbrains/direnv/DirenvService.kt
similarity index 80%
rename from core/src/main/kotlin/com/falsepattern/zigbrains/direnv/DirenvCmd.kt
rename to core/src/main/kotlin/com/falsepattern/zigbrains/direnv/DirenvService.kt
index 6c361bae..282b3783 100644
--- a/core/src/main/kotlin/com/falsepattern/zigbrains/direnv/DirenvCmd.kt
+++ b/core/src/main/kotlin/com/falsepattern/zigbrains/direnv/DirenvService.kt
@@ -29,23 +29,29 @@ import com.intellij.ide.impl.isTrusted
import com.intellij.notification.Notification
import com.intellij.notification.NotificationType
import com.intellij.notification.Notifications
+import com.intellij.openapi.components.Service
+import com.intellij.openapi.components.service
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.guessProjectDir
import com.intellij.platform.util.progress.withProgressText
import com.intellij.util.io.awaitExit
import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import kotlinx.coroutines.withContext
import kotlinx.serialization.json.Json
import java.nio.file.Path
-object DirenvCmd {
- suspend fun importDirenv(project: Project): Env {
- if (!direnvInstalled() || !project.isTrusted())
- return emptyEnv
- val workDir = project.guessProjectDir()?.toNioPath() ?: return emptyEnv
+@Service(Service.Level.PROJECT)
+class DirenvService(val project: Project) {
+ val mutex = Mutex()
- val runOutput = run(project, workDir, "export", "json")
+ suspend fun import(): Env {
+ if (!isInstalled || !project.isTrusted() || project.isDefault)
+ return Env.empty
+ val workDir = project.guessProjectDir()?.toNioPath() ?: return Env.empty
+
+ val runOutput = run(workDir, "export", "json")
if (runOutput.error) {
if (runOutput.output.contains("is blocked")) {
Notifications.Bus.notify(Notification(
@@ -54,7 +60,7 @@ object DirenvCmd {
ZigBrainsBundle.message("notification.content.direnv-blocked"),
NotificationType.ERROR
))
- return emptyEnv
+ return Env.empty
} else {
Notifications.Bus.notify(Notification(
GROUP_DISPLAY_ID,
@@ -62,22 +68,22 @@ object DirenvCmd {
ZigBrainsBundle.message("notification.content.direnv-error", runOutput.output),
NotificationType.ERROR
))
- return emptyEnv
+ return Env.empty
}
}
return if (runOutput.output.isBlank()) {
- emptyEnv
+ Env.empty
} else {
Env(Json.decodeFromString