Skip to content

Commit

Permalink
(GH-7) Initial attempt at getting LSP Client running
Browse files Browse the repository at this point in the history
  • Loading branch information
gep13 committed Apr 5, 2019
1 parent 5715c0a commit e1729e1
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 18 deletions.
68 changes: 68 additions & 0 deletions src/chocolatey-vs/ChocolateyLanguageClient.cs
Original file line number Diff line number Diff line change
@@ -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<string> ConfigurationSections => null;

public object InitializationOptions => null;

public IEnumerable<string> FilesToWatch => null;

public event AsyncEventHandler<EventArgs> StartAsync;
public event AsyncEventHandler<EventArgs> StopAsync;

public async Task<Connection> 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;
}
}
}
20 changes: 20 additions & 0 deletions src/chocolatey-vs/NuspecContentDefinition.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
11 changes: 10 additions & 1 deletion src/chocolatey-vs/chocolatey-vs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="ChocolateyLanguageClient.cs" />
<Compile Include="NuspecContentDefinition.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="chocolatey_vsPackage.cs" />
</ItemGroup>
Expand All @@ -55,10 +57,17 @@
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.LanguageServer.Client">
<Version>16.0.2264</Version>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.SDK" Version="15.9.3" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="16.0.2264" />
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="16.1.46">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != ''" />
Expand Down
35 changes: 18 additions & 17 deletions src/chocolatey-vs/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="chocolatey_vs.911bfdcf-86b4-4fd0-ae5e-a22f232dfb69" Version="1.0" Language="en-US" Publisher="Gary Ewan Park" />
<DisplayName>chocolatey_vs</DisplayName>
<Description>Empty VSIX Project.</Description>
</Metadata>
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[16.0, 17.0)" />
</Installation>
<Dependencies>
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5,)" />
</Dependencies>
<Prerequisites>
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[16.0,17.0)" DisplayName="Visual Studio core editor" />
</Prerequisites>
<Assets>
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" />
</Assets>
<Metadata>
<Identity Id="chocolatey_vs.911bfdcf-86b4-4fd0-ae5e-a22f232dfb69" Version="1.0" Language="en-US" Publisher="Gary Ewan Park" />
<DisplayName>chocolatey_vs</DisplayName>
<Description>Empty VSIX Project.</Description>
</Metadata>
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[16.0, 17.0)" />
</Installation>
<Dependencies>
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5,)" />
</Dependencies>
<Prerequisites>
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[16.0,17.0)" DisplayName="Visual Studio core editor" />
</Prerequisites>
<Assets>
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" />
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%|" />
</Assets>
</PackageManifest>

0 comments on commit e1729e1

Please sign in to comment.