From e1729e12ab193715ae0ce70d00e1142d534b3998 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Fri, 5 Apr 2019 10:22:49 +0100 Subject: [PATCH] (GH-7) Initial attempt at getting LSP Client running --- src/chocolatey-vs/ChocolateyLanguageClient.cs | 68 +++++++++++++++++++ src/chocolatey-vs/NuspecContentDefinition.cs | 20 ++++++ src/chocolatey-vs/chocolatey-vs.csproj | 11 ++- .../source.extension.vsixmanifest | 35 +++++----- 4 files changed, 116 insertions(+), 18 deletions(-) create mode 100644 src/chocolatey-vs/ChocolateyLanguageClient.cs create mode 100644 src/chocolatey-vs/NuspecContentDefinition.cs diff --git a/src/chocolatey-vs/ChocolateyLanguageClient.cs b/src/chocolatey-vs/ChocolateyLanguageClient.cs new file mode 100644 index 0000000..eec4558 --- /dev/null +++ b/src/chocolatey-vs/ChocolateyLanguageClient.cs @@ -0,0 +1,68 @@ + + +using Microsoft.VisualStudio.LanguageServer.Client; +using Microsoft.VisualStudio.Threading; +using Microsoft.VisualStudio.Utilities; +using System; +using System.Collections.Generic; +using System.ComponentModel.Composition; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; + +namespace chocolatey_vs +{ + [ContentType("nuspec")] + [Export(typeof(ILanguageClient))] + public class ChocolateyLanguageClient : ILanguageClient + { + public string Name => "Chocolatey Language Server Client"; + + public IEnumerable ConfigurationSections => null; + + public object InitializationOptions => null; + + public IEnumerable FilesToWatch => null; + + public event AsyncEventHandler StartAsync; + public event AsyncEventHandler StopAsync; + + public async Task ActivateAsync(CancellationToken token) + { + await Task.Yield(); + + var info = new ProcessStartInfo(); + info.FileName = "dotnet"; + info.Arguments = "C:\\github_local\\gep13\\chocolatey-vs\\lib\\ChocolateyLanguageServer\\Chocolatey.Language.Server.dll"; + 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 OnServerInitializedAsync() + { + return Task.CompletedTask; + } + + public Task OnServerInitializeFailedAsync(Exception e) + { + return Task.CompletedTask; + } + } +} diff --git a/src/chocolatey-vs/NuspecContentDefinition.cs b/src/chocolatey-vs/NuspecContentDefinition.cs new file mode 100644 index 0000000..778dce8 --- /dev/null +++ b/src/chocolatey-vs/NuspecContentDefinition.cs @@ -0,0 +1,20 @@ +using Microsoft.VisualStudio.LanguageServer.Client; +using Microsoft.VisualStudio.Utilities; +using System.ComponentModel.Composition; + +namespace chocolatey_vs +{ + public class NuspecContentDefinition + { + [Export] + [Name("nuspec")] + [BaseDefinition(CodeRemoteContentDefinition.CodeRemoteContentTypeName)] + internal static ContentTypeDefinition NuspecContentTypeDefinition; + + + [Export] + [FileExtension(".nuspec")] + [ContentType("nuspec")] + internal static FileExtensionToContentTypeDefinition NuspecFileExtensionDefinition; + } +} diff --git a/src/chocolatey-vs/chocolatey-vs.csproj b/src/chocolatey-vs/chocolatey-vs.csproj index d076481..2f151d1 100644 --- a/src/chocolatey-vs/chocolatey-vs.csproj +++ b/src/chocolatey-vs/chocolatey-vs.csproj @@ -45,6 +45,8 @@ 4 + + @@ -55,10 +57,17 @@ + + + 16.0.2264 + - + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + diff --git a/src/chocolatey-vs/source.extension.vsixmanifest b/src/chocolatey-vs/source.extension.vsixmanifest index 7f5c79c..8dacd51 100644 --- a/src/chocolatey-vs/source.extension.vsixmanifest +++ b/src/chocolatey-vs/source.extension.vsixmanifest @@ -1,20 +1,21 @@ - - - chocolatey_vs - Empty VSIX Project. - - - - - - - - - - - - - + + + chocolatey_vs + Empty VSIX Project. + + + + + + + + + + + + + +