-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start Razor Language Server when new Razor LSP editor opens. (#1487)
- Included the LanguageServer core dlls as part of the VSIX install. To do this I had to expose the language server's output path via a target and then dynamically include its outputs in the VSIX output. - Given how VSIX's are built I could not privately reference our language server to ensure that it's built when the VSIX is built. To work around this limitation I added a `_BuildLanguageServer` target that calls MSBuild directly on the language server as part of build. - For now I'm dynamically booting the currently built language server that's deployed with the extension. I haven't given a lot of thought to what flavor of OS (x64 vs. x86) the server can run on; or if we need to ensure dotnet.exe is available. - Found that the VS LSP client and the O# language server library that we use don't inter-operate as we'd expect. The server ends up telling the client that it doesn't care about text document change events (we do). I've created a separate PR in O# to fix this: OmniSharp/csharp-language-server-protocol#199 - Add OmniSharp 3rd party library to signing information for VSIX insertions. dotnet/aspnetcore#17789
- Loading branch information
1 parent
ebb4980
commit 079aaaf
Showing
4 changed files
with
112 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
src/Razor/src/Microsoft.VisualStudio.LanguageServerClient.Razor/RazorLanguageServerClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.Composition; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.VisualStudio.LanguageServer.Client; | ||
using Microsoft.VisualStudio.Threading; | ||
using Microsoft.VisualStudio.Utilities; | ||
|
||
namespace Microsoft.VisualStudio.LanguageServerClient.Razor | ||
{ | ||
[Export(typeof(ILanguageClient))] | ||
[ContentType(RazorLSPContentTypeDefinition.Name)] | ||
internal class RazorLanguageServerClient : ILanguageClient | ||
{ | ||
public string Name => "Razor Language Server Client"; | ||
|
||
public IEnumerable<string> ConfigurationSections => null; | ||
|
||
public object InitializationOptions => null; | ||
|
||
public IEnumerable<string> FilesToWatch => null; | ||
|
||
public event AsyncEventHandler<EventArgs> StartAsync; | ||
public event AsyncEventHandler<EventArgs> StopAsync | ||
{ | ||
add { } | ||
remove { } | ||
} | ||
|
||
public async Task<Connection> ActivateAsync(CancellationToken token) | ||
{ | ||
await Task.Yield(); | ||
|
||
var currentAssembly = typeof(RazorLanguageServerClient).Assembly; | ||
var currentAssemblyLocation = currentAssembly.Location; | ||
var extensionDirectory = Path.GetDirectoryName(currentAssemblyLocation); | ||
var languageServerPath = Path.Combine(extensionDirectory, "LanguageServer", "rzls.exe"); | ||
var info = new ProcessStartInfo(); | ||
info.FileName = languageServerPath; | ||
info.Arguments = "-lsp --logLevel Trace"; | ||
info.RedirectStandardInput = true; | ||
info.RedirectStandardOutput = true; | ||
info.UseShellExecute = false; | ||
info.CreateNoWindow = true; | ||
|
||
Process process = new Process(); | ||
process.StartInfo = info; | ||
|
||
if (process.Start()) | ||
{ | ||
return new Connection(process.StandardOutput.BaseStream, process.StandardInput.BaseStream); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public async Task OnLoadedAsync() | ||
{ | ||
await StartAsync.InvokeAsync(this, EventArgs.Empty); | ||
} | ||
|
||
public Task OnServerInitializeFailedAsync(Exception e) | ||
{ | ||
return Task.CompletedTask; | ||
} | ||
|
||
public Task OnServerInitializedAsync() | ||
{ | ||
return Task.CompletedTask; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters