Skip to content

Commit

Permalink
Support plugins configuration in omnisharp.json
Browse files Browse the repository at this point in the history
  • Loading branch information
dmgonch committed Sep 1, 2019
1 parent aeb1b50 commit 4486c87
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
12 changes: 10 additions & 2 deletions src/OmniSharp.Host/CommandLineApplicationExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Linq;
using Microsoft.Extensions.Configuration;
using OmniSharp.Options;
using OmniSharp.Plugins;
using OmniSharp.Services;

Expand All @@ -15,9 +17,15 @@ public static OmniSharpEnvironment CreateEnvironment(this CommandLineApplication
application.OtherArgs.ToArray<string>());
}

public static PluginAssemblies CreatePluginAssemblies(this CommandLineApplication application)
public static PluginAssemblies CreatePluginAssemblies(this CommandLineApplication application,
IConfigurationRoot configuration,
OmniSharpEnvironment environment)
{
return new PluginAssemblies(application.Plugin);
var pluginsConfiguration = configuration.GetSection("Plugins");
var extensionsOptions = new OmniSharpExtensionsOptions();
ConfigurationBinder.Bind(pluginsConfiguration, extensionsOptions);

return new PluginAssemblies(application.Plugin.Concat(extensionsOptions.GetNormalizedLocationPaths(environment)));
}
}
}
3 changes: 2 additions & 1 deletion src/OmniSharp.Http.Driver/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ static int Main(string[] args) => HostHelpers.Start(() =>
Configuration.ZeroBasedIndices = application.ZeroBasedIndices;

var writer = new SharedTextWriter(Console.Out);
var plugins = application.CreatePluginAssemblies();
var configuration = new ConfigurationBuilder(environment).Build();
var plugins = application.CreatePluginAssemblies(configuration, environment);

var host = new Host(environment, writer, plugins, application.Port, application.Interface);
host.Start();
Expand Down
2 changes: 1 addition & 1 deletion src/OmniSharp.LanguageServerProtocol/LanguageServerHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private void CreateCompositionHost(InitializeParams initializeParams)
_eventEmitter = new LanguageServerEventEmitter();
_serviceProvider = CompositionHostBuilder.CreateDefaultServiceProvider(_environment, configurationRoot, _eventEmitter, _services);

var plugins = _application.CreatePluginAssemblies();
var plugins = _application.CreatePluginAssemblies(configurationRoot, _environment);

var assemblyLoader = _serviceProvider.GetRequiredService<IAssemblyLoader>();
var compositionHostBuilder = new CompositionHostBuilder(_serviceProvider)
Expand Down
6 changes: 5 additions & 1 deletion src/OmniSharp.Shared/Options/RoslynExtensionsOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@

namespace OmniSharp.Options
{
public class RoslynExtensionsOptions
public class RoslynExtensionsOptions : OmniSharpExtensionsOptions
{
public bool EnableAnalyzersSupport { get; set; }
public int DocumentAnalysisTimeoutMs { get; set; } = 10 * 1000;
}

public class OmniSharpExtensionsOptions
{

public string[] LocationPaths { get; set; }

Expand Down
4 changes: 2 additions & 2 deletions src/OmniSharp.Stdio.Driver/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ static int Main(string[] args) => HostHelpers.Start(() =>

var environment = application.CreateEnvironment();
Configuration.ZeroBasedIndices = application.ZeroBasedIndices;
var configuration = new ConfigurationBuilder(environment).Build();
var writer = new SharedTextWriter(output);
var configuration = new ConfigurationBuilder(environment).Build();
var serviceProvider = CompositionHostBuilder.CreateDefaultServiceProvider(environment, configuration, new StdioEventEmitter(writer),
configureLogging: builder => builder.AddStdio(writer));

var loggerFactory = serviceProvider.GetRequiredService<ILoggerFactory>();
var assemblyLoader = serviceProvider.GetRequiredService<IAssemblyLoader>();

var plugins = application.CreatePluginAssemblies();
var plugins = application.CreatePluginAssemblies(configuration, environment);

var compositionHostBuilder = new CompositionHostBuilder(serviceProvider)
.WithOmniSharpAssemblies()
Expand Down

0 comments on commit 4486c87

Please sign in to comment.