diff --git a/src/OmniSharp.Host/CommandLineApplicationExtensions.cs b/src/OmniSharp.Host/CommandLineApplicationExtensions.cs index 4f00e0642b..5f2469d7a3 100644 --- a/src/OmniSharp.Host/CommandLineApplicationExtensions.cs +++ b/src/OmniSharp.Host/CommandLineApplicationExtensions.cs @@ -1,4 +1,6 @@ using System.Linq; +using Microsoft.Extensions.Configuration; +using OmniSharp.Options; using OmniSharp.Plugins; using OmniSharp.Services; @@ -15,9 +17,15 @@ public static OmniSharpEnvironment CreateEnvironment(this CommandLineApplication application.OtherArgs.ToArray()); } - 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))); } } } diff --git a/src/OmniSharp.Http.Driver/Program.cs b/src/OmniSharp.Http.Driver/Program.cs index 7830e2f144..cec1ffe12a 100644 --- a/src/OmniSharp.Http.Driver/Program.cs +++ b/src/OmniSharp.Http.Driver/Program.cs @@ -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(); diff --git a/src/OmniSharp.LanguageServerProtocol/LanguageServerHost.cs b/src/OmniSharp.LanguageServerProtocol/LanguageServerHost.cs index e5a6662283..8cd5c36402 100644 --- a/src/OmniSharp.LanguageServerProtocol/LanguageServerHost.cs +++ b/src/OmniSharp.LanguageServerProtocol/LanguageServerHost.cs @@ -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(); var compositionHostBuilder = new CompositionHostBuilder(_serviceProvider) diff --git a/src/OmniSharp.Shared/Options/RoslynExtensionsOptions.cs b/src/OmniSharp.Shared/Options/RoslynExtensionsOptions.cs index ac875a47a8..9518e9bbeb 100644 --- a/src/OmniSharp.Shared/Options/RoslynExtensionsOptions.cs +++ b/src/OmniSharp.Shared/Options/RoslynExtensionsOptions.cs @@ -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; } diff --git a/src/OmniSharp.Stdio.Driver/Program.cs b/src/OmniSharp.Stdio.Driver/Program.cs index 94917f163b..49c45e9918 100644 --- a/src/OmniSharp.Stdio.Driver/Program.cs +++ b/src/OmniSharp.Stdio.Driver/Program.cs @@ -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(); var assemblyLoader = serviceProvider.GetRequiredService(); - var plugins = application.CreatePluginAssemblies(); + var plugins = application.CreatePluginAssemblies(configuration, environment); var compositionHostBuilder = new CompositionHostBuilder(serviceProvider) .WithOmniSharpAssemblies()