feat: Better ZLS autodetect

This commit is contained in:
FalsePattern 2024-07-26 16:45:40 +02:00
parent 765cd23897
commit e68b89b6ed
Signed by: falsepattern
GPG key ID: E930CDEC50C50E23
2 changed files with 13 additions and 1 deletions

View file

@ -23,6 +23,9 @@ Changelog structure reference:
- Standard library override always auto-enabling
- Better toolchain autodetect
- ZLS
- Better language server autodetect
## [16.1.0]
### Added

View file

@ -23,13 +23,22 @@ import java.util.List;
public class ZLSStreamConnectionProvider extends ProcessStreamConnectionProvider {
private static final Logger LOG = Logger.getInstance(ZLSStreamConnectionProvider.class);
public ZLSStreamConnectionProvider(Project project) {
super.setCommands(getCommand(project));
super(getCommand(project));
}
public static List<String> getCommand(Project project) {
var svc = ZLSProjectSettingsService.getInstance(project);
val state = svc.getState();
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)) {
return null;
}