From 1b6e793126d5adbb4ad3b9f61b950b23abd4fdc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= <sumneko@hotmail.com> Date: Mon, 30 Jan 2023 18:04:38 +0800 Subject: [PATCH] command `lua.exportDocument` --- client/src/languageserver.ts | 26 +++++++++++++++++++++++++- package.json | 3 ++- package/package.lua | 8 ++++++-- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/client/src/languageserver.ts b/client/src/languageserver.ts index c81a053..7071996 100644 --- a/client/src/languageserver.ts +++ b/client/src/languageserver.ts @@ -47,10 +47,34 @@ function registerCustomCommands(context: ExtensionContext) { } } })) + + context.subscriptions.push(Commands.registerCommand('lua.exportDocument', async () => { + if (!defaultClient) { + return; + }; + let outputs = await vscode.window.showOpenDialog({ + defaultUri: vscode.Uri.joinPath( + context.extensionUri, + 'server', + 'log', + ), + openLabel: "Export documents to this folder", + canSelectFiles: false, + canSelectFolders: true, + canSelectMany: false, + }); + let output = outputs?.[0]; + if (!output) { + return; + }; + defaultClient.client.sendRequest(ExecuteCommandRequest.type, { + command: 'lua.exportDocument', + arguments: [output.toString()], + }) + })) } class LuaClient { - public client: LanguageClient; private disposables = new Array<Disposable>(); constructor(private context: ExtensionContext, diff --git a/package.json b/package.json index d9753d4..3818647 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ { "command": "lua.psi.view", "title": "Lua Psi Viewer" + "command": "lua.exportDocument", } ], "configuration": { @@ -2913,7 +2914,7 @@ "menus": { "editor/context": [ { - "command": "lua.psi.view", + "command": "lua.exportDocument", "group": "z_commands", "when": "resourceLangId == lua" } diff --git a/package/package.lua b/package/package.lua index 166ac43..0cec615 100644 --- a/package/package.lua +++ b/package/package.lua @@ -37,13 +37,17 @@ return { { command = "lua.psi.view", title = "Lua Psi Viewer" - } + }, + { + command = "lua.exportDocument", + title = "Export Document", + }, }, menus = { ["editor/context"] = { { when = "resourceLangId == lua", - command = "lua.psi.view", + command = "lua.exportDocument", group = "z_commands" } } -- GitLab