feat!(lsp): Temporary way to increasing the timeouts
Also added some Windows-specific command line tweaks, and non-blocking language server setup.
This commit is contained in:
parent
d18ca32b9b
commit
e967b1c5ad
5 changed files with 81 additions and 32 deletions
|
@ -4,6 +4,11 @@
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
#### LSP
|
||||||
|
- Temporary "increase timeout" toggle (currently, it bumps all timeouts to 15 seconds)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
#### Highlighting
|
#### Highlighting
|
||||||
|
@ -12,6 +17,9 @@
|
||||||
#### Folding
|
#### Folding
|
||||||
- Occasional NPE in LSP4IntellIJ
|
- Occasional NPE in LSP4IntellIJ
|
||||||
|
|
||||||
|
#### LSP
|
||||||
|
- (Windows) ZLS binary not executing if the file path has weird characters
|
||||||
|
|
||||||
## [0.2.0]
|
## [0.2.0]
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -20,6 +20,7 @@ import com.falsepattern.zigbrains.settings.AppSettingsState;
|
||||||
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.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import com.intellij.openapi.startup.StartupActivity;
|
import com.intellij.openapi.startup.StartupActivity;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
@ -30,9 +31,14 @@ import java.nio.file.Files;
|
||||||
import java.nio.file.InvalidPathException;
|
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.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
public class ZLSStartupActivity implements StartupActivity {
|
public class ZLSStartupActivity implements StartupActivity {
|
||||||
|
private static final ReentrantLock lock = new ReentrantLock();
|
||||||
public static void initZLS() {
|
public static void initZLS() {
|
||||||
|
ApplicationManager.getApplication().executeOnPooledThread(() -> {
|
||||||
|
lock.lock();
|
||||||
|
try {
|
||||||
var settings = AppSettingsState.getInstance();
|
var settings = AppSettingsState.getInstance();
|
||||||
var zlsPath = settings.zlsPath;
|
var zlsPath = settings.zlsPath;
|
||||||
if (!validatePath("ZLS Binary", zlsPath, false)) {
|
if (!validatePath("ZLS Binary", zlsPath, false)) {
|
||||||
|
@ -42,8 +48,8 @@ public class ZLSStartupActivity implements StartupActivity {
|
||||||
boolean configOK = true;
|
boolean configOK = true;
|
||||||
if (!"".equals(configPath) && !validatePath("ZLS Config", configPath, false)) {
|
if (!"".equals(configPath) && !validatePath("ZLS Config", configPath, false)) {
|
||||||
configOK = false;
|
configOK = false;
|
||||||
Notifications.Bus.notify(new Notification("ZigBrains.Nag", "Using default config path.",
|
Notifications.Bus.notify(
|
||||||
NotificationType.INFORMATION));
|
new Notification("ZigBrains.Nag", "Using default config path.", NotificationType.INFORMATION));
|
||||||
}
|
}
|
||||||
if ("".equals(configPath)) {
|
if ("".equals(configPath)) {
|
||||||
configOK = false;
|
configOK = false;
|
||||||
|
@ -58,13 +64,34 @@ public class ZLSStartupActivity implements StartupActivity {
|
||||||
cmd.add("--config-path");
|
cmd.add("--config-path");
|
||||||
cmd.add(configPath);
|
cmd.add(configPath);
|
||||||
}
|
}
|
||||||
|
// TODO make this properly configurable
|
||||||
|
if (settings.increaseTimeouts) {
|
||||||
|
for (var timeout : IntellijLanguageClient.getTimeouts().keySet()) {
|
||||||
|
IntellijLanguageClient.setTimeout(timeout, 15000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (settings.debug) {
|
if (settings.debug) {
|
||||||
cmd.add("--enable-debug-log");
|
cmd.add("--enable-debug-log");
|
||||||
}
|
}
|
||||||
if (settings.messageTrace) {
|
if (settings.messageTrace) {
|
||||||
cmd.add("--enable-message-tracing");
|
cmd.add("--enable-message-tracing");
|
||||||
}
|
}
|
||||||
|
for (var wrapper : IntellijLanguageClient.getAllServerWrappersFor("zig")) {
|
||||||
|
wrapper.removeServerWrapper();
|
||||||
|
}
|
||||||
|
if (System.getProperty("os.name").toLowerCase().contains("win")) {
|
||||||
|
for (int i = 0; i < cmd.size(); i++) {
|
||||||
|
if (cmd.get(i).contains(" ")) {
|
||||||
|
cmd.set(i, '"' + cmd.get(i) + '"');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
IntellijLanguageClient.addServerDefinition(new RawCommandServerDefinition("zig", cmd.toArray(String[]::new)));
|
IntellijLanguageClient.addServerDefinition(new RawCommandServerDefinition("zig", cmd.toArray(String[]::new)));
|
||||||
|
} finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean validatePath(String name, String pathTxt, boolean dir) {
|
private static boolean validatePath(String name, String pathTxt, boolean dir) {
|
||||||
|
|
|
@ -32,6 +32,7 @@ public class AppSettingsComponent {
|
||||||
private final TextFieldWithBrowseButton zlsConfigPathText = new TextFieldWithBrowseButton();
|
private final TextFieldWithBrowseButton zlsConfigPathText = new TextFieldWithBrowseButton();
|
||||||
private final JBCheckBox debugCheckBox = new JBCheckBox();
|
private final JBCheckBox debugCheckBox = new JBCheckBox();
|
||||||
private final JBCheckBox messageTraceCheckBox = new JBCheckBox();
|
private final JBCheckBox messageTraceCheckBox = new JBCheckBox();
|
||||||
|
private final JBCheckBox increaseTimeouts = new JBCheckBox();
|
||||||
|
|
||||||
public AppSettingsComponent() {
|
public AppSettingsComponent() {
|
||||||
zlsPathText.addBrowseFolderListener(
|
zlsPathText.addBrowseFolderListener(
|
||||||
|
@ -41,8 +42,9 @@ public class AppSettingsComponent {
|
||||||
.addVerticalGap(10)
|
.addVerticalGap(10)
|
||||||
.addLabeledComponent(new JBLabel("ZLS path: "), zlsPathText, 1, false)
|
.addLabeledComponent(new JBLabel("ZLS path: "), zlsPathText, 1, false)
|
||||||
.addLabeledComponent(new JBLabel("ZLS config path (leave empty to use default): "), zlsConfigPathText, 1, false)
|
.addLabeledComponent(new JBLabel("ZLS config path (leave empty to use default): "), zlsConfigPathText, 1, false)
|
||||||
|
.addLabeledComponent(new JBLabel("Increase timeouts"), increaseTimeouts, 1, false)
|
||||||
.addSeparator()
|
.addSeparator()
|
||||||
.addComponent(new JBLabel("Developer settings"))
|
.addComponent(new JBLabel("Developer settings (only usable when the IDE was launched with the runIDE gradle task in ZigBrains!)"))
|
||||||
.addVerticalGap(10)
|
.addVerticalGap(10)
|
||||||
.addLabeledComponent(new JBLabel("ZLS debug log: "), debugCheckBox, 1, false)
|
.addLabeledComponent(new JBLabel("ZLS debug log: "), debugCheckBox, 1, false)
|
||||||
.addLabeledComponent(new JBLabel("ZLS message trace: "), messageTraceCheckBox, 1, false)
|
.addLabeledComponent(new JBLabel("ZLS message trace: "), messageTraceCheckBox, 1, false)
|
||||||
|
@ -72,6 +74,14 @@ public class AppSettingsComponent {
|
||||||
zlsConfigPathText.setText(newText);
|
zlsConfigPathText.setText(newText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getIncreaseTimeouts() {
|
||||||
|
return increaseTimeouts.isSelected();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIncreaseTimeouts(boolean state) {
|
||||||
|
increaseTimeouts.setSelected(state);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean getDebug() {
|
public boolean getDebug() {
|
||||||
return debugCheckBox.isSelected();
|
return debugCheckBox.isSelected();
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ public class AppSettingsConfigurable implements Configurable {
|
||||||
modified |= !settings.zlsConfigPath.equals(appSettingsComponent.getZLSConfigPath());
|
modified |= !settings.zlsConfigPath.equals(appSettingsComponent.getZLSConfigPath());
|
||||||
modified |= settings.debug != appSettingsComponent.getDebug();
|
modified |= settings.debug != appSettingsComponent.getDebug();
|
||||||
modified |= settings.messageTrace != appSettingsComponent.getMessageTrace();
|
modified |= settings.messageTrace != appSettingsComponent.getMessageTrace();
|
||||||
|
modified |= settings.increaseTimeouts != appSettingsComponent.getIncreaseTimeouts();
|
||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +54,7 @@ public class AppSettingsConfigurable implements Configurable {
|
||||||
settings.zlsConfigPath = appSettingsComponent.getZLSConfigPath();
|
settings.zlsConfigPath = appSettingsComponent.getZLSConfigPath();
|
||||||
settings.debug = appSettingsComponent.getDebug();
|
settings.debug = appSettingsComponent.getDebug();
|
||||||
settings.messageTrace = appSettingsComponent.getMessageTrace();
|
settings.messageTrace = appSettingsComponent.getMessageTrace();
|
||||||
|
settings.increaseTimeouts = appSettingsComponent.getIncreaseTimeouts();
|
||||||
ZLSStartupActivity.initZLS();
|
ZLSStartupActivity.initZLS();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +65,7 @@ public class AppSettingsConfigurable implements Configurable {
|
||||||
appSettingsComponent.setZLSConfigPath(settings.zlsConfigPath);
|
appSettingsComponent.setZLSConfigPath(settings.zlsConfigPath);
|
||||||
appSettingsComponent.setDebug(settings.debug);
|
appSettingsComponent.setDebug(settings.debug);
|
||||||
appSettingsComponent.setMessageTrace(settings.messageTrace);
|
appSettingsComponent.setMessageTrace(settings.messageTrace);
|
||||||
|
appSettingsComponent.setIncreaseTimeouts(settings.increaseTimeouts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -32,6 +32,7 @@ public final class AppSettingsState implements PersistentStateComponent<AppSetti
|
||||||
public String zlsConfigPath = "";
|
public String zlsConfigPath = "";
|
||||||
public boolean debug = false;
|
public boolean debug = false;
|
||||||
public boolean messageTrace = false;
|
public boolean messageTrace = false;
|
||||||
|
public boolean increaseTimeouts = false;
|
||||||
|
|
||||||
public static AppSettingsState getInstance() {
|
public static AppSettingsState getInstance() {
|
||||||
return ApplicationManager.getApplication().getService(AppSettingsState.class);
|
return ApplicationManager.getApplication().getService(AppSettingsState.class);
|
||||||
|
|
Loading…
Add table
Reference in a new issue