Skip to content

Commit 1b6e793

Browse files
committed
command lua.exportDocument
1 parent 4de1e43 commit 1b6e793

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

client/src/languageserver.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,34 @@ function registerCustomCommands(context: ExtensionContext) {
4747
}
4848
}
4949
}))
50+
51+
context.subscriptions.push(Commands.registerCommand('lua.exportDocument', async () => {
52+
if (!defaultClient) {
53+
return;
54+
};
55+
let outputs = await vscode.window.showOpenDialog({
56+
defaultUri: vscode.Uri.joinPath(
57+
context.extensionUri,
58+
'server',
59+
'log',
60+
),
61+
openLabel: "Export documents to this folder",
62+
canSelectFiles: false,
63+
canSelectFolders: true,
64+
canSelectMany: false,
65+
});
66+
let output = outputs?.[0];
67+
if (!output) {
68+
return;
69+
};
70+
defaultClient.client.sendRequest(ExecuteCommandRequest.type, {
71+
command: 'lua.exportDocument',
72+
arguments: [output.toString()],
73+
})
74+
}))
5075
}
5176

5277
class LuaClient {
53-
5478
public client: LanguageClient;
5579
private disposables = new Array<Disposable>();
5680
constructor(private context: ExtensionContext,

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
{
2626
"command": "lua.psi.view",
2727
"title": "Lua Psi Viewer"
28+
"command": "lua.exportDocument",
2829
}
2930
],
3031
"configuration": {
@@ -2913,7 +2914,7 @@
29132914
"menus": {
29142915
"editor/context": [
29152916
{
2916-
"command": "lua.psi.view",
2917+
"command": "lua.exportDocument",
29172918
"group": "z_commands",
29182919
"when": "resourceLangId == lua"
29192920
}

package/package.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,17 @@ return {
3737
{
3838
command = "lua.psi.view",
3939
title = "Lua Psi Viewer"
40-
}
40+
},
41+
{
42+
command = "lua.exportDocument",
43+
title = "Export Document",
44+
},
4145
},
4246
menus = {
4347
["editor/context"] = {
4448
{
4549
when = "resourceLangId == lua",
46-
command = "lua.psi.view",
50+
command = "lua.exportDocument",
4751
group = "z_commands"
4852
}
4953
}

0 commit comments

Comments
 (0)