fix: Better parity with the vscode zig plugin in the lsp
This commit is contained in:
parent
027c26b430
commit
cac455b460
2 changed files with 25 additions and 7 deletions
|
@ -36,6 +36,7 @@ import com.falsepattern.zigbrains.lsp.statusbar.LSPServerStatusWidget;
|
||||||
import com.falsepattern.zigbrains.lsp.statusbar.LSPServerStatusWidgetFactory;
|
import com.falsepattern.zigbrains.lsp.statusbar.LSPServerStatusWidgetFactory;
|
||||||
import com.falsepattern.zigbrains.lsp.utils.FileUtils;
|
import com.falsepattern.zigbrains.lsp.utils.FileUtils;
|
||||||
import com.falsepattern.zigbrains.lsp.utils.LSPException;
|
import com.falsepattern.zigbrains.lsp.utils.LSPException;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
|
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
|
||||||
import com.intellij.openapi.application.ApplicationInfo;
|
import com.intellij.openapi.application.ApplicationInfo;
|
||||||
import com.intellij.openapi.diagnostic.Logger;
|
import com.intellij.openapi.diagnostic.Logger;
|
||||||
|
@ -514,16 +515,28 @@ public class LanguageServerWrapper {
|
||||||
Class<? extends LanguageServer> remoteServerInterFace = extManager.getExtendedServerInterface();
|
Class<? extends LanguageServer> remoteServerInterFace = extManager.getExtendedServerInterface();
|
||||||
client = extManager.getExtendedClientFor(new ServerWrapperBaseClientContext(this));
|
client = extManager.getExtendedClientFor(new ServerWrapperBaseClientContext(this));
|
||||||
|
|
||||||
Launcher<? extends LanguageServer> launcher = Launcher
|
val launcher = new Launcher.Builder<LanguageServer>()
|
||||||
.createLauncher(client, remoteServerInterFace, inputStream, outputStream, executorService,
|
.setLocalService(client)
|
||||||
messageHandler);
|
.setRemoteInterface(remoteServerInterFace)
|
||||||
|
.setInput(inputStream)
|
||||||
|
.setOutput(outputStream)
|
||||||
|
.setExecutorService(executorService)
|
||||||
|
.wrapMessages(messageHandler)
|
||||||
|
.configureGson(GsonBuilder::disableHtmlEscaping)
|
||||||
|
.create();
|
||||||
languageServer = launcher.getRemoteProxy();
|
languageServer = launcher.getRemoteProxy();
|
||||||
launcherFuture = launcher.startListening();
|
launcherFuture = launcher.startListening();
|
||||||
} else {
|
} else {
|
||||||
client = new DefaultLanguageClient(new ServerWrapperBaseClientContext(this));
|
client = new DefaultLanguageClient(new ServerWrapperBaseClientContext(this));
|
||||||
Launcher<LanguageServer> launcher = Launcher
|
val launcher = new Launcher.Builder<LanguageServer>()
|
||||||
.createLauncher(client, LanguageServer.class, inputStream, outputStream, executorService,
|
.setLocalService(client)
|
||||||
messageHandler);
|
.setRemoteInterface(LanguageServer.class)
|
||||||
|
.setInput(inputStream)
|
||||||
|
.setOutput(outputStream)
|
||||||
|
.setExecutorService(executorService)
|
||||||
|
.wrapMessages(messageHandler)
|
||||||
|
.configureGson(GsonBuilder::disableHtmlEscaping)
|
||||||
|
.create();
|
||||||
languageServer = launcher.getRemoteProxy();
|
languageServer = launcher.getRemoteProxy();
|
||||||
launcherFuture = launcher.startListening();
|
launcherFuture = launcher.startListening();
|
||||||
}
|
}
|
||||||
|
@ -559,8 +572,13 @@ public class LanguageServerWrapper {
|
||||||
private InitializeParams getInitParams() throws URISyntaxException {
|
private InitializeParams getInitParams() throws URISyntaxException {
|
||||||
InitializeParams initParams = new InitializeParams();
|
InitializeParams initParams = new InitializeParams();
|
||||||
String projectRootUri = FileUtil.pathToUri(projectRootPath);
|
String projectRootUri = FileUtil.pathToUri(projectRootPath);
|
||||||
|
if (projectRootUri.endsWith("/")) {
|
||||||
|
projectRootUri = projectRootUri.substring(0, projectRootUri.length() - 1);
|
||||||
|
}
|
||||||
WorkspaceFolder workspaceFolder = new WorkspaceFolder(projectRootUri, this.project.getName());
|
WorkspaceFolder workspaceFolder = new WorkspaceFolder(projectRootUri, this.project.getName());
|
||||||
initParams.setWorkspaceFolders(Collections.singletonList(workspaceFolder));
|
initParams.setWorkspaceFolders(Collections.singletonList(workspaceFolder));
|
||||||
|
initParams.setProcessId((int) ProcessHandle.current().pid());
|
||||||
|
initParams.setLocale("en-us");
|
||||||
|
|
||||||
// workspace capabilities
|
// workspace capabilities
|
||||||
WorkspaceClientCapabilities workspaceClientCapabilities = new WorkspaceClientCapabilities();
|
WorkspaceClientCapabilities workspaceClientCapabilities = new WorkspaceClientCapabilities();
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class DocumentEventManager {
|
||||||
private final TextDocumentSyncKind syncKind;
|
private final TextDocumentSyncKind syncKind;
|
||||||
private final LanguageServerWrapper wrapper;
|
private final LanguageServerWrapper wrapper;
|
||||||
private final TextDocumentIdentifier identifier;
|
private final TextDocumentIdentifier identifier;
|
||||||
private int version = -1;
|
private int version = 0;
|
||||||
protected Logger LOG = Logger.getInstance(EditorEventManager.class);
|
protected Logger LOG = Logger.getInstance(EditorEventManager.class);
|
||||||
|
|
||||||
private final Set<Document> openDocuments = new HashSet<>();
|
private final Set<Document> openDocuments = new HashSet<>();
|
||||||
|
|
Loading…
Add table
Reference in a new issue