diff --git a/YarnSpinner.LanguageServer.Tests/CommandTests.cs b/YarnSpinner.LanguageServer.Tests/CommandTests.cs index 95565f46c..1a045b1a5 100644 --- a/YarnSpinner.LanguageServer.Tests/CommandTests.cs +++ b/YarnSpinner.LanguageServer.Tests/CommandTests.cs @@ -325,5 +325,4 @@ public async Task Server_CanListProjects() result.Should().ContainSingle(p => p.Uri!.Path.EndsWith("Project1.yarnproject")); result.Should().ContainSingle(p => p.Uri!.Path.EndsWith("Project2.yarnproject")); } - } diff --git a/YarnSpinner.LanguageServer/src/Server/Commands/Commands.cs b/YarnSpinner.LanguageServer/src/Server/Commands/Commands.cs index 07136f09a..53b7d350f 100644 --- a/YarnSpinner.LanguageServer/src/Server/Commands/Commands.cs +++ b/YarnSpinner.LanguageServer/src/Server/Commands/Commands.cs @@ -69,4 +69,8 @@ public static class Commands /// The command to get all projects in the current workspace. /// public const string ListProjects = "yarnspinner.listProjects"; + + public const string GenerateDebugOutput = "yarnspinner.generateDebugOutput"; + + public const string GetEmptyYarnProjectJSON = "yarnspinner.getEmptyYarnProjectJSON"; } diff --git a/YarnSpinner.LanguageServer/src/Server/YarnLanguageServer.cs b/YarnSpinner.LanguageServer/src/Server/YarnLanguageServer.cs index 2e7ec81ee..92ccf6e81 100644 --- a/YarnSpinner.LanguageServer/src/Server/YarnLanguageServer.cs +++ b/YarnSpinner.LanguageServer/src/Server/YarnLanguageServer.cs @@ -158,6 +158,15 @@ public static LanguageServerOptions ConfigureOptions(LanguageServerOptions optio } ); + // register 'return json for new project' command + options.OnExecuteCommand( + (commandParams) => GetEmptyYarnProjectJSON(workspace, commandParams), + (_, _) => new ExecuteCommandRegistrationOptions + { + Commands = new[] { Commands.GetEmptyYarnProjectJSON }, + } + ); + return options; } @@ -725,5 +734,13 @@ private static Task> ListProjects(Workspace workspace, Ex }); return Task.FromResult(Container.From(info)); } + + + public static Task GetEmptyYarnProjectJSON(Workspace workspace, ExecuteCommandParams commandParams) { + + var project = new Yarn.Compiler.Project(); + + return Task.FromResult(project.GetJson()); + } } }