-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
StreamConnectionProvider: getInitializationOptions with initial document URI #684
Comments
An Regarding the initializationOptions, they should just be historized when the LS is started, as they are read-only. I right now don't see the value of having a document there, as the language server instance is not document specific. Then they could be made accessible with a public method. |
How do you handle outdated initialProject/Path as described in #683 ?
The use case is a C/C++ language server: I want to set the fallback options for the clangd LS. These fallback compiler flags will be determined by fetching the compiler settings for the first opened file. Therefor I need the uri/path or document of the first file to be opened. |
I may not be understanding the issue - on startup of a language server, the initializationOptions contain the rootURI and workspace folders. We use these values. When the workspaceFolders change, we listen to the change method and act accordingly in the language server.
Hm, why can't you just fetch the compiler settings of the file that starts up a new instance? I really only half understand what is required here, but why can't a newly started instance set the fallback options for that instance? |
Okay. I have seen the following problem with start()/stop() of a LS and the lifetime of its wrapper:
That's what I want. But I need the file info before the new instance gets started (before var options = Optional.ofNullable(this.lspStreamProvider.getInitializationOptions(rootURI)).orElse(this.lspStreamProvider.getInitializationOptionsFromUri(initialFile));
initParams.setInitializationOptions(options);
try {
lspStreamProvider.start();
} catch (IOException e) {
throw new RuntimeException(e);
} |
Inheriting an old URI/project path sounds like a bug - this state should not be retained, in my opinion. |
I agree. That's why the start() method in the wrapper needs an argument for public synchronized void start(URI rootUri) throws IOException {
... |
As a 1st iteration, we can start by setting the rootUri to null when calling |
For some LS the determination of LS initialization options depends on the first uri to be opened and not on the first project or path. Therefor the getInitializationOptionsFromUri(URI) method has been added to the StreamConnectionProvider interface. It will be called when getInitializationOptions(URI) returns null. fixes eclipse#683 eclipse#684
For some LS the determination of LS initialization options depends on the first uri to be opened and not on the first project or path. Therefor the getInitializationOptionsFromUri(URI) method has been added to the StreamConnectionProvider interface. It will be called when getInitializationOptions(URI) returns null. fixes eclipse#683 eclipse#684
For some LS the determination of LS initialization options depends on the first uri to be opened and not on the first project or path. Therefor the getInitializationOptionsFromUri(URI) method has been added to the StreamConnectionProvider interface. It will be called when getInitializationOptions(URI) returns null. fixes eclipse#683 eclipse#684
For some LS the determination of LS initialization options depends on the first uri to be opened and not on the first project or path. Therefor the getInitializationOptionsFromUri(URI) method has been added to the StreamConnectionProvider interface. It will be called when getInitializationOptions(URI) returns null. fixes eclipse#683 eclipse#684
For some LS the determination of LS initialization options depends on the first uri to be opened and not on the first project or path. Therefor the getInitializationOptionsFromUri(URI) method has been added to the StreamConnectionProvider interface. It will be called when getInitializationOptions(URI) returns null. fixes eclipse#683 eclipse#684
In order to determine the initialization options for a LS, the initial document or its uri would be very helpful in
org.eclipse.cdt.lsp.internal.server.CLanguageServerStreamConnectionProvider.getInitializationOptions(URI)
.In order to prevent an API change, a new method
org.eclipse.cdt.lsp.internal.server.CLanguageServerStreamConnectionProvider.getInitializationOptionsForDocument(IDocument initialDocument)
could be provided.Since the
initialProject
orinitialPath
can be outdated as mentioned in #683 as well, a solution could be to provide aLanguageServerWrapper
start method with document/path/uri as argument:org.eclipse.lsp4e.LanguageServerWrapper.start(URI initialDocument)
as already mentioned in #157 by @sebthom.IMO an
initialDocument
would be better than aninitialProject
orinitialPath
. Both could be determined by the document.What are your opinions?
The text was updated successfully, but these errors were encountered: