Skip to content

Commit 9f81e28

Browse files
committed
Support GoLand SDK
1 parent 9f85850 commit 9f81e28

File tree

9 files changed

+98
-14
lines changed

9 files changed

+98
-14
lines changed

CHANGELOG.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44

55
## [Unreleased] - 2024-06-30
66

7+
## [1.2.0] - 2024-07-21
8+
9+
- Add support for the Go SDK (GOROOT) integration from mise tools.
10+
11+
## [1.1.0] - 2024-07-20
12+
13+
### Added
14+
15+
- Add support for the JDK integration from mise tools.
16+
717
## [1.0.1] - 2024-07-03
818

919
### Added
@@ -12,12 +22,11 @@
1222
- Support environment variables for run configuration.
1323
- Supported IDEs: IntelliJ IDEA, WebStorm, GoLand.
1424

15-
## [1.1.0] - 2024-07-20
16-
1725
### Added
1826

1927
- Support JDK integration from mise tools.
2028

21-
[Unreleased]: https://github.com/134130/intellij-mise/compare/v1.1.0...HEAD
29+
[Unreleased]: https://github.com/134130/intellij-mise/compare/v1.2.0...HEAD
30+
[1.2.0]: https://github.com/134130/intellij-mise/compare/v1.1.0...v1.2.0
2231
[1.1.0]: https://github.com/134130/intellij-mise/compare/v1.0.1...v1.1.0
2332
[1.0.1]: https://github.com/134130/intellij-mise/releases/tag/v1.0.1

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
<!-- Plugin description -->
66
# Mise
77

8+
**[GitHub](https://github.com/134130/intellij-mise)** | **[Issue](https://github.com/134130/intellij-mise/issues)** | **[Changelog](https://github.com/134130/intellij-mise/blob/main/CHANGELOG.md)**
9+
810
**Mise** is a plugin for JetBrains IDEs that allows you to set environment variables for your run configurations
911
from mise config files. see: **[mise-en-place](https://mise.jdx.dev)**
1012

@@ -13,9 +15,21 @@ from mise config files. see: **[mise-en-place](https://mise.jdx.dev)**
1315
- **GoLand**
1416
- **WebStorm**
1517
- _Submit issue if you need other IDE_
16-
<!-- Plugin description end -->
1718

18-
**[GitHub](https://github.com/134130/intellij-mise)** | **[Issue](https://github.com/134130/intellij-mise/issues)**
19+
### Features
20+
- **Environment Variables**: Set environment variables for your run configurations from mise config files.
21+
- **JDK Integration**: Set JDK from mise config files.
22+
- **Go SDK Integration**: Set Go SDK (GOROOT) from mise config files.
23+
24+
### Screenshots
25+
26+
| - | Setup | Notification |
27+
|-----------------------|-------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------|
28+
| **IntelliJ IDEA** | ![image](https://github.com/user-attachments/assets/913911fe-19ec-4754-b1e0-31650e14fff0) | ![image](https://github.com/user-attachments/assets/a406ae15-20da-4044-a8c6-3f5f938e16f7) |
29+
| **GoLand** | ![image](https://github.com/user-attachments/assets/4a51b036-f2b3-48e9-b85d-eb114ea1af7c) | ![image](https://github.com/user-attachments/assets/e72fa0ac-4dc1-44ff-ac18-08883d0f9ede) |
30+
| **Run Configuration** | ![image](https://github.com/user-attachments/assets/2ad4239e-fd05-4291-8844-441dc47ffe11) | |
31+
32+
<!-- Plugin description end -->
1933

2034
## Installation
2135

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pluginGroup = com.github.l34130.mise
44
pluginName = mise
55
pluginRepositoryUrl = https://github.com/134130/intellij-mise
66
# SemVer format -> https://semver.org
7-
pluginVersion = 1.1.0
7+
pluginVersion = 1.2.0
88

99
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
1010
pluginSinceBuild = 223

modules/core/src/main/kotlin/com/github/l34130/mise/commands/MiseCmd.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package com.github.l34130.mise.commands
33
import com.github.l34130.mise.extensions.fromJson
44
import com.github.l34130.mise.notifications.Notification
55
import com.google.gson.FieldNamingPolicy
6-
import com.google.gson.Gson
76
import com.google.gson.GsonBuilder
87
import com.intellij.execution.configurations.GeneralCommandLine
98
import com.intellij.notification.NotificationType
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.github.l34130.mise.go
2+
3+
import com.github.l34130.mise.commands.MiseCmd
4+
import com.github.l34130.mise.notifications.Notification
5+
import com.goide.sdk.GoSdkImpl
6+
import com.goide.sdk.GoSdkService
7+
import com.goide.sdk.GoSdkUtil
8+
import com.intellij.notification.NotificationType
9+
import com.intellij.openapi.actionSystem.AnAction
10+
import com.intellij.openapi.actionSystem.AnActionEvent
11+
import com.intellij.openapi.application.WriteAction
12+
import com.intellij.openapi.project.Project
13+
import com.intellij.openapi.startup.StartupActivity
14+
import com.intellij.openapi.vfs.LocalFileSystem
15+
16+
class GoLandProjectGoSdkSetup : AnAction(), StartupActivity {
17+
override fun actionPerformed(e: AnActionEvent) {
18+
e.project?.let { runActivity(it) }
19+
}
20+
21+
override fun runActivity(project: Project) {
22+
val goTools = MiseCmd.loadTools(project.basePath)["go"] ?: return
23+
24+
WriteAction.runAndWait<Throwable> {
25+
for (tool in goTools) {
26+
val localFileSystem = LocalFileSystem.getInstance()
27+
val homeDir = localFileSystem.findFileByPath(tool.installPath)
28+
val sdkRoot = GoSdkUtil.adjustSdkDir(homeDir) ?: continue
29+
30+
val newSdk = GoSdkImpl(sdkRoot.url, tool.version, null)
31+
32+
if (goTools.size == 1) {
33+
GoSdkService.getInstance(project).setSdk(newSdk)
34+
Notification.notify("Go SDK set to ${tool.version} from ${tool.source.type}", NotificationType.INFORMATION, project)
35+
}
36+
}
37+
38+
if (goTools.size > 1) {
39+
Notification.notify("Multiple Go SDKs found. Not setting any.", NotificationType.WARNING, project)
40+
}
41+
}
42+
}
43+
}

modules/products/idea/src/main/kotlin/com/github/l34130/mise/jdk/IdeaProjectJdkSetup.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.github.l34130.mise.jdk
22

33
import com.github.l34130.mise.commands.MiseCmd
4+
import com.github.l34130.mise.notifications.Notification
5+
import com.intellij.notification.NotificationType
46
import com.intellij.openapi.actionSystem.AnAction
57
import com.intellij.openapi.actionSystem.AnActionEvent
68
import com.intellij.openapi.application.WriteAction
@@ -35,10 +37,15 @@ class IdeaProjectJdkSetup : AnAction(), StartupActivity {
3537
ProjectJdkTable.getInstance().addJdk(newJdk)
3638
}
3739

38-
if (javaTools.size == 1) {
40+
if (javaTools.size == 1 && oldJdk?.name != newJdk.name) {
3941
ProjectRootManager.getInstance(project).projectSdk = newJdk
42+
Notification.notify("JDK set to ${tool.version} from ${tool.source.type}", NotificationType.INFORMATION, project)
4043
}
4144
}
45+
46+
if (javaTools.size > 1) {
47+
Notification.notify("Multiple JDKs found. Not setting any.", NotificationType.WARNING, project)
48+
}
4249
}
4350
}
4451
}

src/main/resources/META-INF/mise-goland.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,13 @@
33
<runConfigurationExtension implementation="com.github.l34130.mise.runconfigs.GoLandRunConfigurationExtension"
44
id="miseGoLand"/>
55
</extensions>
6+
7+
<actions>
8+
<action id="com.github.l34130.mise.go.GoLandProjectGoSdkSetup"
9+
class="com.github.l34130.mise.go.GoLandProjectGoSdkSetup"
10+
text="Reload Go SDK"
11+
>
12+
<add-to-group group-id="ch.mise.actions"/>
13+
</action>
14+
</actions>
615
</idea-plugin>

src/main/resources/META-INF/mise-idea.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77
</extensions>
88

99
<actions>
10-
<group id="ch.mise.actions"
11-
text="Mise"
12-
popup="true"
13-
icon="com.github.l34130.mise.icons.PluginIcons.Default">
14-
<add-to-group group-id="ToolsMenu"/>
15-
</group>
1610
<action id="com.github.l34130.mise.jdk.IdeaProjectJdkSetup"
1711
class="com.github.l34130.mise.jdk.IdeaProjectJdkSetup"
1812
text="Reload JDK"

src/main/resources/META-INF/plugin.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@
1010
<notificationGroup displayType="BALLOON" id="Mise"/>
1111
</extensions>
1212

13+
<actions>
14+
<group id="ch.mise.actions"
15+
text="Mise"
16+
popup="true"
17+
icon="com.github.l34130.mise.icons.PluginIcons.Default">
18+
<add-to-group group-id="ToolsMenu"/>
19+
</group>
20+
</actions>
21+
1322
<depends optional="true" config-file="mise-idea.xml">com.intellij.java</depends>
1423
<depends optional="true" config-file="mise-gradle.xml">com.intellij.gradle</depends>
1524
<depends optional="true" config-file="mise-goland.xml">org.jetbrains.plugins.go</depends>

0 commit comments

Comments
 (0)