Skip to content

Commit e1729e1

Browse files
committed
(GH-7) Initial attempt at getting LSP Client running
1 parent 5715c0a commit e1729e1

File tree

4 files changed

+116
-18
lines changed

4 files changed

+116
-18
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+

2+
3+
using Microsoft.VisualStudio.LanguageServer.Client;
4+
using Microsoft.VisualStudio.Threading;
5+
using Microsoft.VisualStudio.Utilities;
6+
using System;
7+
using System.Collections.Generic;
8+
using System.ComponentModel.Composition;
9+
using System.Diagnostics;
10+
using System.Threading;
11+
using System.Threading.Tasks;
12+
13+
namespace chocolatey_vs
14+
{
15+
[ContentType("nuspec")]
16+
[Export(typeof(ILanguageClient))]
17+
public class ChocolateyLanguageClient : ILanguageClient
18+
{
19+
public string Name => "Chocolatey Language Server Client";
20+
21+
public IEnumerable<string> ConfigurationSections => null;
22+
23+
public object InitializationOptions => null;
24+
25+
public IEnumerable<string> FilesToWatch => null;
26+
27+
public event AsyncEventHandler<EventArgs> StartAsync;
28+
public event AsyncEventHandler<EventArgs> StopAsync;
29+
30+
public async Task<Connection> ActivateAsync(CancellationToken token)
31+
{
32+
await Task.Yield();
33+
34+
var info = new ProcessStartInfo();
35+
info.FileName = "dotnet";
36+
info.Arguments = "C:\\github_local\\gep13\\chocolatey-vs\\lib\\ChocolateyLanguageServer\\Chocolatey.Language.Server.dll";
37+
info.RedirectStandardInput = true;
38+
info.RedirectStandardOutput = true;
39+
info.UseShellExecute = false;
40+
info.CreateNoWindow = true;
41+
42+
Process process = new Process();
43+
process.StartInfo = info;
44+
45+
if (process.Start())
46+
{
47+
return new Connection(process.StandardOutput.BaseStream, process.StandardInput.BaseStream);
48+
}
49+
50+
return null;
51+
}
52+
53+
public async Task OnLoadedAsync()
54+
{
55+
await StartAsync?.InvokeAsync(this, EventArgs.Empty);
56+
}
57+
58+
public Task OnServerInitializedAsync()
59+
{
60+
return Task.CompletedTask;
61+
}
62+
63+
public Task OnServerInitializeFailedAsync(Exception e)
64+
{
65+
return Task.CompletedTask;
66+
}
67+
}
68+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Microsoft.VisualStudio.LanguageServer.Client;
2+
using Microsoft.VisualStudio.Utilities;
3+
using System.ComponentModel.Composition;
4+
5+
namespace chocolatey_vs
6+
{
7+
public class NuspecContentDefinition
8+
{
9+
[Export]
10+
[Name("nuspec")]
11+
[BaseDefinition(CodeRemoteContentDefinition.CodeRemoteContentTypeName)]
12+
internal static ContentTypeDefinition NuspecContentTypeDefinition;
13+
14+
15+
[Export]
16+
[FileExtension(".nuspec")]
17+
[ContentType("nuspec")]
18+
internal static FileExtensionToContentTypeDefinition NuspecFileExtensionDefinition;
19+
}
20+
}

src/chocolatey-vs/chocolatey-vs.csproj

+10-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
<WarningLevel>4</WarningLevel>
4646
</PropertyGroup>
4747
<ItemGroup>
48+
<Compile Include="ChocolateyLanguageClient.cs" />
49+
<Compile Include="NuspecContentDefinition.cs" />
4850
<Compile Include="Properties\AssemblyInfo.cs" />
4951
<Compile Include="chocolatey_vsPackage.cs" />
5052
</ItemGroup>
@@ -55,10 +57,17 @@
5557
</ItemGroup>
5658
<ItemGroup>
5759
<Reference Include="System" />
60+
<Reference Include="System.ComponentModel.Composition" />
5861
</ItemGroup>
5962
<ItemGroup>
63+
<PackageReference Include="Microsoft.VisualStudio.LanguageServer.Client">
64+
<Version>16.0.2264</Version>
65+
</PackageReference>
6066
<PackageReference Include="Microsoft.VisualStudio.SDK" Version="15.9.3" ExcludeAssets="runtime" />
61-
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="16.0.2264" />
67+
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="16.1.46">
68+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
69+
<PrivateAssets>all</PrivateAssets>
70+
</PackageReference>
6271
</ItemGroup>
6372
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
6473
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != ''" />
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<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">
3-
<Metadata>
4-
<Identity Id="chocolatey_vs.911bfdcf-86b4-4fd0-ae5e-a22f232dfb69" Version="1.0" Language="en-US" Publisher="Gary Ewan Park" />
5-
<DisplayName>chocolatey_vs</DisplayName>
6-
<Description>Empty VSIX Project.</Description>
7-
</Metadata>
8-
<Installation>
9-
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[16.0, 17.0)" />
10-
</Installation>
11-
<Dependencies>
12-
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5,)" />
13-
</Dependencies>
14-
<Prerequisites>
15-
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[16.0,17.0)" DisplayName="Visual Studio core editor" />
16-
</Prerequisites>
17-
<Assets>
18-
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" />
19-
</Assets>
3+
<Metadata>
4+
<Identity Id="chocolatey_vs.911bfdcf-86b4-4fd0-ae5e-a22f232dfb69" Version="1.0" Language="en-US" Publisher="Gary Ewan Park" />
5+
<DisplayName>chocolatey_vs</DisplayName>
6+
<Description>Empty VSIX Project.</Description>
7+
</Metadata>
8+
<Installation>
9+
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[16.0, 17.0)" />
10+
</Installation>
11+
<Dependencies>
12+
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5,)" />
13+
</Dependencies>
14+
<Prerequisites>
15+
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[16.0,17.0)" DisplayName="Visual Studio core editor" />
16+
</Prerequisites>
17+
<Assets>
18+
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" />
19+
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%|" />
20+
</Assets>
2021
</PackageManifest>

0 commit comments

Comments
 (0)