From 9ef9a4ef0ef57f633c3f22b2009c12e329090e31 Mon Sep 17 00:00:00 2001 From: fox- <1127001585@qq.com> Date: Thu, 9 Aug 2018 02:45:32 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BD=BF=E7=94=A8lua-fmt=E5=BA=93(https://?= =?UTF-8?q?github.com/trixnz/lua-fmt)=20=E6=9D=A5=E6=95=B4=E7=90=86?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 16 ++++++++-------- src/extension.ts | 9 +++++++++ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index bcfb319..701cb94 100644 --- a/package.json +++ b/package.json @@ -104,7 +104,6 @@ "lua" ] }, - { "type": "emmylua_launch", "label": "EmmyLua Launch Debug", @@ -188,7 +187,7 @@ "workingDir", "arguments", "port" - ], + ], "properties": { "program": { "type": "string", @@ -300,17 +299,18 @@ "test": "npm run compile && node ./node_modules/vscode/bin/test" }, "devDependencies": { + "tslint": "^5.8.0", "typescript": "^2.6.1", - "vscode": "^1.1.6", - "tslint": "^5.8.0" + "vscode": "^1.1.6" }, "dependencies": { - "vscode-languageclient": "^3.3.0", - "vscode-debugadapter": "1.27.0", - "vscode-debugprotocol": "1.27.0", - "@types/node": "^7.0.43", "@types/mocha": "^2.2.42", + "@types/node": "^7.0.43", + "lua-fmt": "^2.6.0", "smart-buffer": "^4.0.1", + "vscode-debugadapter": "1.27.0", + "vscode-debugprotocol": "1.27.0", + "vscode-languageclient": "^3.3.0", "xml2js": "^0.4.19" } } diff --git a/src/extension.ts b/src/extension.ts index 30453bf..e6c39d2 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -10,6 +10,7 @@ import { LanguageClient, LanguageClientOptions, ServerOptions, StreamInfo } from import { Proposed } from 'vscode-languageserver-protocol'; import { AttachDebuggerProvider } from './debugger/AttachDebuggerProvider'; import { MobDebuggerProvider } from './debugger/MobDebuggerProvider'; +import { formatText } from 'lua-fmt'; const LANGUAGE_ID = 'lua'; //EmmyLua export let savedContext: vscode.ExtensionContext; @@ -32,6 +33,14 @@ export function activate(context: vscode.ExtensionContext) { vscode.commands.registerCommand("emmy.restartServer", restartServer); vscode.commands.registerCommand("emmy.showReferences", showReferences); + vscode.languages.registerDocumentFormattingEditProvider( + "lua", { + provideDocumentFormattingEdits(document, position, token): vscode.ProviderResult { + return [new vscode.TextEdit(new vscode.Range(0, 0, document.lineCount, 0), formatText(document.getText()))]; + } + } + ) + const attProvider = new AttachDebuggerProvider(); savedContext.subscriptions.push(vscode.debug.registerDebugConfigurationProvider("emmylua_attach", attProvider)); savedContext.subscriptions.push(vscode.debug.registerDebugConfigurationProvider("emmylua_launch", attProvider)); From 8c01eed0d9db7884c3d2a0f72389b722aff433f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E5=94=90?= <272669294@qq.com> Date: Fri, 17 Aug 2018 12:39:35 +0800 Subject: [PATCH 2/2] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 05dae9f..b64066b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# EmmyLua for VSCode +# EmmyLua for VSCode (Unstable) [![Online EmmyLua Doc](https://img.shields.io/badge/emmy-doc-46BC99.svg?style=flat-square)](https://emmylua.github.io) [![donate](https://img.shields.io/badge/donate-emmy-FF69B4.svg?style=flat-square)](https://emmylua.github.io/donate.html) @@ -16,4 +16,4 @@ ### 1.0.0 -Initial release of ... \ No newline at end of file +Initial release of ...