backport: 16.1.1
This commit is contained in:
parent
8f3cd2e954
commit
369de795a9
7 changed files with 62 additions and 10 deletions
11
CHANGELOG.md
11
CHANGELOG.md
|
@ -17,6 +17,17 @@ Changelog structure reference:
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [16.1.1]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Zig
|
||||||
|
- Standard library override always auto-enabling
|
||||||
|
- Better toolchain autodetect
|
||||||
|
|
||||||
|
- ZLS
|
||||||
|
- Better language server autodetect
|
||||||
|
|
||||||
## [16.1.0]
|
## [16.1.0]
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -11,7 +11,7 @@ baseIDE=clion
|
||||||
ideaVersion=2023.3.7
|
ideaVersion=2023.3.7
|
||||||
clionVersion=2023.3.5
|
clionVersion=2023.3.5
|
||||||
|
|
||||||
pluginVersion=16.1.0
|
pluginVersion=16.1.1
|
||||||
|
|
||||||
# Gradle Releases -> https://github.com/gradle/gradle/releases
|
# Gradle Releases -> https://github.com/gradle/gradle/releases
|
||||||
gradleVersion=8.9
|
gradleVersion=8.9
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class ZigProjectSettingsPanel implements MyDisposable {
|
||||||
.map(PathUtil::pathFromString)
|
.map(PathUtil::pathFromString)
|
||||||
.map(ZigToolchainProvider::findToolchain)
|
.map(ZigToolchainProvider::findToolchain)
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
return new ZigProjectSettings(StringUtil.blankToNull(pathToStdField.getText()), toolchain);
|
return new ZigProjectSettings(stdFieldOverride.isSelected() ? StringUtil.blankToNull(pathToStdField.getText()) : null, toolchain);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setData(ZigProjectSettings value) {
|
public void setData(ZigProjectSettings value) {
|
||||||
|
@ -115,7 +115,6 @@ public class ZigProjectSettingsPanel implements MyDisposable {
|
||||||
r.button("Autodetect", $f(this::autodetect));
|
r.button("Autodetect", $f(this::autodetect));
|
||||||
});
|
});
|
||||||
p2.cell("Toolchain version", toolchainVersion);
|
p2.cell("Toolchain version", toolchainVersion);
|
||||||
p2.cell("Override standard library path", stdFieldOverride);
|
|
||||||
p2.row("Standard library location", row -> {
|
p2.row("Standard library location", row -> {
|
||||||
row.cell(pathToStdField).resizableColumn().align(AlignX.FILL);
|
row.cell(pathToStdField).resizableColumn().align(AlignX.FILL);
|
||||||
row.cell(stdFieldOverride);
|
row.cell(stdFieldOverride);
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class ZigProjectSettings {
|
||||||
public String toolchainHomeDirectory;
|
public String toolchainHomeDirectory;
|
||||||
|
|
||||||
public ZigProjectSettings(String explicitPathToStd, AbstractZigToolchain toolchain) {
|
public ZigProjectSettings(String explicitPathToStd, AbstractZigToolchain toolchain) {
|
||||||
this(true, explicitPathToStd, (String)null);
|
this(explicitPathToStd != null, explicitPathToStd, null);
|
||||||
setToolchain(toolchain);
|
setToolchain(toolchain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,14 @@ public class ToolchainZLSConfigProvider implements ZLSConfigProvider {
|
||||||
public void getEnvironment(Project project, ZLSConfig.ZLSConfigBuilder builder) {
|
public void getEnvironment(Project project, ZLSConfig.ZLSConfigBuilder builder) {
|
||||||
val svc = ZigProjectSettingsService.getInstance(project);
|
val svc = ZigProjectSettingsService.getInstance(project);
|
||||||
val state = svc.getState();
|
val state = svc.getState();
|
||||||
val toolchain = state.getToolchain();
|
var toolchain = state.getToolchain();
|
||||||
if (toolchain == null)
|
if (toolchain == null) {
|
||||||
|
toolchain = AbstractZigToolchain.suggest();
|
||||||
|
if (toolchain == null) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
state.setToolchain(toolchain);
|
||||||
|
}
|
||||||
val projectDir = ProjectUtil.guessProjectDir(project);
|
val projectDir = ProjectUtil.guessProjectDir(project);
|
||||||
val env = toolchain.zig().getEnv(projectDir == null ? Path.of(".") : projectDir.toNioPath());
|
val env = toolchain.zig().getEnv(projectDir == null ? Path.of(".") : projectDir.toNioPath());
|
||||||
env.ifPresent(e -> builder.zig_exe_path(e.zigExecutable()).zig_lib_path(state.overrideStdPath ? Path.of(state.explicitPathToStd).getParent().toString() : e.libDirectory()));
|
env.ifPresent(e -> builder.zig_exe_path(e.zigExecutable()).zig_lib_path(state.overrideStdPath ? Path.of(state.explicitPathToStd).getParent().toString() : e.libDirectory()));
|
||||||
|
|
|
@ -31,6 +31,6 @@ public class ZLSLanguageServerFactory implements LanguageServerFactory, Language
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setEnabled(boolean enabled, @NotNull Project project) {
|
public void setEnabled(boolean enabled, @NotNull Project project) {
|
||||||
this.enabled = enabled && ZLSStreamConnectionProvider.getCommand(project) != null;
|
this.enabled = enabled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,12 @@ import com.google.gson.Gson;
|
||||||
import com.intellij.notification.Notification;
|
import com.intellij.notification.Notification;
|
||||||
import com.intellij.notification.NotificationType;
|
import com.intellij.notification.NotificationType;
|
||||||
import com.intellij.notification.Notifications;
|
import com.intellij.notification.Notifications;
|
||||||
|
import com.intellij.openapi.application.ApplicationManager;
|
||||||
import com.intellij.openapi.diagnostic.Logger;
|
import com.intellij.openapi.diagnostic.Logger;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
|
import com.intellij.openapi.project.ProjectUtil;
|
||||||
import com.intellij.openapi.util.io.FileUtil;
|
import com.intellij.openapi.util.io.FileUtil;
|
||||||
|
import com.intellij.openapi.vfs.VirtualFile;
|
||||||
import com.redhat.devtools.lsp4ij.server.ProcessStreamConnectionProvider;
|
import com.redhat.devtools.lsp4ij.server.ProcessStreamConnectionProvider;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
|
|
||||||
|
@ -19,17 +22,39 @@ import java.nio.file.InvalidPathException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
public class ZLSStreamConnectionProvider extends ProcessStreamConnectionProvider {
|
public class ZLSStreamConnectionProvider extends ProcessStreamConnectionProvider {
|
||||||
private static final Logger LOG = Logger.getInstance(ZLSStreamConnectionProvider.class);
|
private static final Logger LOG = Logger.getInstance(ZLSStreamConnectionProvider.class);
|
||||||
public ZLSStreamConnectionProvider(Project project) {
|
public ZLSStreamConnectionProvider(Project project) {
|
||||||
super.setCommands(getCommand(project));
|
val command = getCommand(project);
|
||||||
|
val projectDir = ProjectUtil.guessProjectDir(project);
|
||||||
|
if (projectDir != null) {
|
||||||
|
setWorkingDirectory(projectDir.getPath());
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
setCommands(command.get());
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> getCommand(Project project) {
|
private static List<String> doGetCommand(Project project) {
|
||||||
var svc = ZLSProjectSettingsService.getInstance(project);
|
var svc = ZLSProjectSettingsService.getInstance(project);
|
||||||
val state = svc.getState();
|
val state = svc.getState();
|
||||||
var zlsPath = state.zlsPath;
|
var zlsPath = state.zlsPath;
|
||||||
|
if (StringUtil.isEmpty(zlsPath)) {
|
||||||
|
zlsPath = com.falsepattern.zigbrains.common.util.FileUtil.findExecutableOnPATH("zls").map(Path::toString).orElse(null);
|
||||||
|
if (zlsPath == null) {
|
||||||
|
Notifications.Bus.notify(new Notification("ZigBrains.ZLS", "Could not detect ZLS binary! Please configure it!",
|
||||||
|
NotificationType.ERROR));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
state.setZlsPath(zlsPath);
|
||||||
|
}
|
||||||
if (!validatePath("ZLS Binary", zlsPath, false)) {
|
if (!validatePath("ZLS Binary", zlsPath, false)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -87,6 +112,18 @@ public class ZLSStreamConnectionProvider extends ProcessStreamConnectionProvider
|
||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Future<List<String>> getCommand(Project project) {
|
||||||
|
val future = new CompletableFuture<List<String>>();
|
||||||
|
ApplicationManager.getApplication().executeOnPooledThread(() -> {
|
||||||
|
try {
|
||||||
|
future.complete(doGetCommand(project));
|
||||||
|
} catch (Throwable t) {
|
||||||
|
future.completeExceptionally(t);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return future;
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean validatePath(String name, String pathTxt, boolean dir) {
|
private static boolean validatePath(String name, String pathTxt, boolean dir) {
|
||||||
if (pathTxt == null || pathTxt.isBlank()) {
|
if (pathTxt == null || pathTxt.isBlank()) {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue