backport: 17.1.0
This commit is contained in:
parent
58201b4868
commit
ca226586f2
7 changed files with 92 additions and 26 deletions
12
CHANGELOG.md
12
CHANGELOG.md
|
@ -17,6 +17,18 @@ Changelog structure reference:
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [17.1.0]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Project
|
||||||
|
- Relative paths in zig toolchain configuration would break the entire IDE
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- ZLS
|
||||||
|
- Obsolete config options which are no longer used since migrating to LSP4IJ
|
||||||
|
|
||||||
## [17.0.0]
|
## [17.0.0]
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -11,7 +11,7 @@ baseIDE=clion
|
||||||
ideaVersion=2023.2.7
|
ideaVersion=2023.2.7
|
||||||
clionVersion=2023.2.4
|
clionVersion=2023.2.4
|
||||||
|
|
||||||
pluginVersion=17.0.0
|
pluginVersion=17.1.0
|
||||||
|
|
||||||
# Gradle Releases -> https://github.com/gradle/gradle/releases
|
# Gradle Releases -> https://github.com/gradle/gradle/releases
|
||||||
gradleVersion=8.9
|
gradleVersion=8.9
|
||||||
|
|
|
@ -19,10 +19,15 @@ package com.falsepattern.zigbrains.project.toolchain;
|
||||||
import com.falsepattern.zigbrains.project.openapi.components.ZigProjectSettingsService;
|
import com.falsepattern.zigbrains.project.openapi.components.ZigProjectSettingsService;
|
||||||
import com.falsepattern.zigbrains.zig.environment.ZLSConfig;
|
import com.falsepattern.zigbrains.zig.environment.ZLSConfig;
|
||||||
import com.falsepattern.zigbrains.zig.environment.ZLSConfigProvider;
|
import com.falsepattern.zigbrains.zig.environment.ZLSConfigProvider;
|
||||||
|
import com.intellij.notification.Notification;
|
||||||
|
import com.intellij.notification.NotificationType;
|
||||||
|
import com.intellij.notification.Notifications;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import com.intellij.openapi.project.ProjectUtil;
|
import com.intellij.openapi.project.ProjectUtil;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
|
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.InvalidPathException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
public class ToolchainZLSConfigProvider implements ZLSConfigProvider {
|
public class ToolchainZLSConfigProvider implements ZLSConfigProvider {
|
||||||
|
@ -39,7 +44,76 @@ public class ToolchainZLSConfigProvider implements ZLSConfigProvider {
|
||||||
state.setToolchain(toolchain);
|
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 oEnv = toolchain.zig().getEnv(projectDir == null ? null : projectDir.toNioPath());
|
||||||
env.ifPresent(e -> builder.zig_exe_path(e.zigExecutable()).zig_lib_path(state.overrideStdPath ? Path.of(state.explicitPathToStd).getParent().toString() : e.libDirectory()));
|
if (oEnv.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
val env = oEnv.get();
|
||||||
|
Path exe;
|
||||||
|
try {
|
||||||
|
exe = Path.of(env.zigExecutable());
|
||||||
|
} catch (InvalidPathException e) {
|
||||||
|
Notifications.Bus.notify(new Notification("ZigBrains.Project",
|
||||||
|
"Invalid zig executable path: " + env.zigExecutable(),
|
||||||
|
NotificationType.ERROR));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!exe.isAbsolute()) {
|
||||||
|
exe = toolchain.getLocation().resolve(exe);
|
||||||
|
}
|
||||||
|
if (!Files.exists(exe)) {
|
||||||
|
Notifications.Bus.notify(new Notification("ZigBrains.Project",
|
||||||
|
"Zig executable path does not exist: " + env.zigExecutable(),
|
||||||
|
NotificationType.ERROR));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Path lib = null;
|
||||||
|
override:
|
||||||
|
if (state.overrideStdPath) {
|
||||||
|
try {
|
||||||
|
lib = Path.of(state.explicitPathToStd);
|
||||||
|
} catch (InvalidPathException e) {
|
||||||
|
Notifications.Bus.notify(new Notification("ZigBrains.Project",
|
||||||
|
"Invalid zig standard library path override: " + env.zigExecutable(),
|
||||||
|
NotificationType.ERROR));
|
||||||
|
state.overrideStdPath = false;
|
||||||
|
break override;
|
||||||
|
}
|
||||||
|
if (!lib.isAbsolute()) {
|
||||||
|
lib = toolchain.getLocation().resolve(lib);
|
||||||
|
}
|
||||||
|
if (!Files.exists(lib)) {
|
||||||
|
Notifications.Bus.notify(new Notification("ZigBrains.Project",
|
||||||
|
"Zig standard library path override does not exist: " + env.zigExecutable(),
|
||||||
|
NotificationType.ERROR));
|
||||||
|
lib = null;
|
||||||
|
state.overrideStdPath = false;
|
||||||
|
break override;
|
||||||
|
} else {
|
||||||
|
state.explicitPathToStd = lib.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (lib == null) {
|
||||||
|
try {
|
||||||
|
lib = Path.of(env.libDirectory());
|
||||||
|
} catch (InvalidPathException e) {
|
||||||
|
Notifications.Bus.notify(new Notification("ZigBrains.Project",
|
||||||
|
"Invalid zig standard library path: " + env.zigExecutable(),
|
||||||
|
NotificationType.ERROR));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!lib.isAbsolute()) {
|
||||||
|
lib = toolchain.getLocation().resolve(lib);
|
||||||
|
}
|
||||||
|
if (!Files.exists(lib)) {
|
||||||
|
Notifications.Bus.notify(new Notification("ZigBrains.Project",
|
||||||
|
"Zig standard library path does not exist: " +
|
||||||
|
env.zigExecutable(), NotificationType.ERROR));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
builder.zig_exe_path(exe.toString());
|
||||||
|
builder.zig_lib_path(lib.toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,19 +38,11 @@ public final class ZLSProjectSettingsService extends WrappingStateComponent<ZLSS
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isModified(ZLSSettings otherData) {
|
public boolean isModified(ZLSSettings otherData) {
|
||||||
val myData = this.getState();
|
|
||||||
boolean modified = zlsSettingsModified(otherData);
|
|
||||||
modified |= myData.asyncFolding != otherData.asyncFolding;
|
|
||||||
return modified;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean zlsSettingsModified(ZLSSettings otherData) {
|
|
||||||
val myData = this.getState();
|
val myData = this.getState();
|
||||||
boolean modified = !Objects.equals(myData.zlsPath, otherData.zlsPath);
|
boolean modified = !Objects.equals(myData.zlsPath, otherData.zlsPath);
|
||||||
modified |= !Objects.equals(myData.zlsConfigPath, otherData.zlsConfigPath);
|
modified |= !Objects.equals(myData.zlsConfigPath, otherData.zlsConfigPath);
|
||||||
modified |= myData.debug != otherData.debug;
|
modified |= myData.debug != otherData.debug;
|
||||||
modified |= myData.messageTrace != otherData.messageTrace;
|
modified |= myData.messageTrace != otherData.messageTrace;
|
||||||
modified |= myData.increaseTimeouts != otherData.increaseTimeouts;
|
|
||||||
modified |= myData.buildOnSave != otherData.buildOnSave;
|
modified |= myData.buildOnSave != otherData.buildOnSave;
|
||||||
modified |= !Objects.equals(myData.buildOnSaveStep, otherData.buildOnSaveStep);
|
modified |= !Objects.equals(myData.buildOnSaveStep, otherData.buildOnSaveStep);
|
||||||
modified |= myData.highlightGlobalVarDeclarations != otherData.highlightGlobalVarDeclarations;
|
modified |= myData.highlightGlobalVarDeclarations != otherData.highlightGlobalVarDeclarations;
|
||||||
|
|
|
@ -26,8 +26,6 @@ import org.jetbrains.annotations.Nullable;
|
||||||
public final class ZLSSettings {
|
public final class ZLSSettings {
|
||||||
public @Nullable String zlsPath;
|
public @Nullable String zlsPath;
|
||||||
public @NotNull String zlsConfigPath;
|
public @NotNull String zlsConfigPath;
|
||||||
public boolean increaseTimeouts;
|
|
||||||
public boolean asyncFolding;
|
|
||||||
public boolean debug;
|
public boolean debug;
|
||||||
public boolean messageTrace;
|
public boolean messageTrace;
|
||||||
public boolean buildOnSave;
|
public boolean buildOnSave;
|
||||||
|
@ -36,6 +34,6 @@ public final class ZLSSettings {
|
||||||
public boolean dangerousComptimeExperimentsDoNotEnable;
|
public boolean dangerousComptimeExperimentsDoNotEnable;
|
||||||
|
|
||||||
public ZLSSettings() {
|
public ZLSSettings() {
|
||||||
this(null, "", false, true, false, false, false, "install", false, false);
|
this(null, "", false, false, false, "install", false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class ZLSSettingsConfigurable implements SubConfigurable {
|
||||||
public void apply() {
|
public void apply() {
|
||||||
var settings = ZLSProjectSettingsService.getInstance(project);
|
var settings = ZLSProjectSettingsService.getInstance(project);
|
||||||
val data = appSettingsComponent.getData();
|
val data = appSettingsComponent.getData();
|
||||||
boolean reloadZLS = settings.zlsSettingsModified(data);
|
boolean reloadZLS = settings.isModified(data);
|
||||||
settings.loadState(data);
|
settings.loadState(data);
|
||||||
if (reloadZLS) {
|
if (reloadZLS) {
|
||||||
ZLSStartupActivity.startLSP(project, true);
|
ZLSStartupActivity.startLSP(project, true);
|
||||||
|
|
|
@ -42,8 +42,6 @@ public class ZLSSettingsPanel implements Disposable {
|
||||||
private final TextFieldWithBrowseButton zlsConfigPath = TextFieldUtil.pathToFileTextField(this,
|
private final TextFieldWithBrowseButton zlsConfigPath = TextFieldUtil.pathToFileTextField(this,
|
||||||
"Path to the Custom ZLS Config File (Optional)",
|
"Path to the Custom ZLS Config File (Optional)",
|
||||||
() -> {});
|
() -> {});
|
||||||
private final JBCheckBox asyncFolding = new JBCheckBox();
|
|
||||||
private final JBCheckBox increaseTimeouts = new JBCheckBox();
|
|
||||||
|
|
||||||
private final JBCheckBox buildOnSave = new JBCheckBox();
|
private final JBCheckBox buildOnSave = new JBCheckBox();
|
||||||
private final JBTextField buildOnSaveStep = new ExtendableTextField();
|
private final JBTextField buildOnSaveStep = new ExtendableTextField();
|
||||||
|
@ -76,16 +74,12 @@ public class ZLSSettingsPanel implements Disposable {
|
||||||
Optional.ofNullable(ZLSProjectSettingsService.getInstance(ProjectManager.getInstance().getDefaultProject()))
|
Optional.ofNullable(ZLSProjectSettingsService.getInstance(ProjectManager.getInstance().getDefaultProject()))
|
||||||
.map(ZLSProjectSettingsService::getState)
|
.map(ZLSProjectSettingsService::getState)
|
||||||
.ifPresent(this::setData);
|
.ifPresent(this::setData);
|
||||||
panel.group("ZLS launch settings", true, p -> {
|
panel.group("ZLS Settings", true, p -> {
|
||||||
p.row("Executable path", r -> {
|
p.row("Executable path", r -> {
|
||||||
r.cell(zlsPath).resizableColumn().align(AlignX.FILL);
|
r.cell(zlsPath).resizableColumn().align(AlignX.FILL);
|
||||||
r.button("Autodetect", $f(this::autodetect));
|
r.button("Autodetect", $f(this::autodetect));
|
||||||
});
|
});
|
||||||
p.cell("Config path (leave empty to use built-in config)", zlsConfigPath, AlignX.FILL);
|
p.cell("Config path (leave empty to use built-in config)", zlsConfigPath, AlignX.FILL);
|
||||||
p.cell("Increase timeouts", increaseTimeouts);
|
|
||||||
p.cell("Asynchronous code folding ranges", asyncFolding);
|
|
||||||
});
|
|
||||||
panel.group("ZLS Configuration", false, p -> {
|
|
||||||
p.cell("Build on save", buildOnSave);
|
p.cell("Build on save", buildOnSave);
|
||||||
p.row("Build on save step", r -> {
|
p.row("Build on save step", r -> {
|
||||||
r.cell(buildOnSaveStep).resizableColumn().align(AlignX.FILL);
|
r.cell(buildOnSaveStep).resizableColumn().align(AlignX.FILL);
|
||||||
|
@ -102,8 +96,6 @@ public class ZLSSettingsPanel implements Disposable {
|
||||||
public ZLSSettings getData() {
|
public ZLSSettings getData() {
|
||||||
return new ZLSSettings(zlsPath.getText(),
|
return new ZLSSettings(zlsPath.getText(),
|
||||||
zlsConfigPath.getText(),
|
zlsConfigPath.getText(),
|
||||||
increaseTimeouts.isSelected(),
|
|
||||||
asyncFolding.isSelected(),
|
|
||||||
debug.isSelected(),
|
debug.isSelected(),
|
||||||
messageTrace.isSelected(),
|
messageTrace.isSelected(),
|
||||||
buildOnSave.isSelected(),
|
buildOnSave.isSelected(),
|
||||||
|
@ -115,8 +107,6 @@ public class ZLSSettingsPanel implements Disposable {
|
||||||
public void setData(ZLSSettings value) {
|
public void setData(ZLSSettings value) {
|
||||||
zlsPath.setText(value.zlsPath == null ? "" : value.zlsPath);
|
zlsPath.setText(value.zlsPath == null ? "" : value.zlsPath);
|
||||||
zlsConfigPath.setText(value.zlsConfigPath);
|
zlsConfigPath.setText(value.zlsConfigPath);
|
||||||
increaseTimeouts.setSelected(value.increaseTimeouts);
|
|
||||||
asyncFolding.setSelected(value.asyncFolding);
|
|
||||||
debug.setSelected(value.debug);
|
debug.setSelected(value.debug);
|
||||||
messageTrace.setSelected(value.messageTrace);
|
messageTrace.setSelected(value.messageTrace);
|
||||||
buildOnSave.setSelected(value.buildOnSave);
|
buildOnSave.setSelected(value.buildOnSave);
|
||||||
|
|
Loading…
Add table
Reference in a new issue