├── .eslintrc.json ├── .github └── workflows │ └── build.yml ├── .gitignore ├── .vscode ├── extensions.json ├── launch.json ├── settings.json └── tasks.json ├── .vscodeignore ├── CHANGELOG.md ├── README.md ├── README_EN.md ├── build ├── config.js └── prepare.js ├── package.json ├── src ├── extension.ts └── test │ ├── runTest.ts │ └── suite │ ├── extension.test.ts │ └── index.ts ├── tsconfig.json └── vsc-extension-quickstart.md /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "@typescript-eslint/parser", 4 | "parserOptions": { 5 | "ecmaVersion": 6, 6 | "sourceType": "module" 7 | }, 8 | "plugins": [ 9 | "@typescript-eslint" 10 | ], 11 | "rules": { 12 | "@typescript-eslint/naming-convention": "warn", 13 | "@typescript-eslint/semi": "warn", 14 | "curly": "warn", 15 | "eqeqeq": "warn", 16 | "no-throw-literal": "warn", 17 | "semi": "off" 18 | }, 19 | "ignorePatterns": [ 20 | "out", 21 | "dist", 22 | "**/*.d.ts" 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Node CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | tags: 8 | - "*.*.*" 9 | 10 | jobs: 11 | build: 12 | strategy: 13 | matrix: 14 | include: 15 | - os: windows-latest 16 | platform: win32 17 | arch: x64 18 | npm_config_arch: x64 19 | target: win32-x64 20 | - os: ubuntu-latest 21 | platform: linux 22 | arch: x64 23 | npm_config_arch: x64 24 | target: linux-x64 25 | - os: macos-latest 26 | platform: darwin 27 | arch: x64 28 | npm_config_arch: x64 29 | target: darwin-x64 30 | - os: macos-latest 31 | platform: darwin 32 | arch: arm64 33 | npm_config_arch: arm64 34 | target: darwin-arm64 35 | runs-on: ubuntu-latest 36 | 37 | steps: 38 | - uses: actions/checkout@master 39 | - name: Set node 20.x 40 | uses: actions/setup-node@v3 41 | with: 42 | node-version: 20.x 43 | - name: Install 44 | uses: borales/actions-yarn@v4 45 | with: 46 | cmd: install 47 | env: 48 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 49 | npm_config_arch: ${{ matrix.npm_config_arch }} 50 | - name: build 51 | run: | 52 | node ./build/prepare.js ${{ matrix.target }} 53 | npx vsce package --target ${{ matrix.target }} 54 | - name: Upload 55 | uses: actions/upload-artifact@v2 56 | with: 57 | name: ${{ matrix.target }} 58 | path: ${{ github.workspace }}/emmylua-unity*.vsix 59 | publish: 60 | runs-on: ubuntu-latest 61 | needs: build 62 | if: success() && startsWith(github.ref, 'refs/tags/') 63 | steps: 64 | - uses: actions/download-artifact@v2 65 | - run: npx vsce publish --packagePath $(find . -iname *.vsix) 66 | env: 67 | VSCE_PAT: ${{ secrets.VSCE_PAT }} 68 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | out 2 | dist 3 | node_modules 4 | .vscode-test/ 5 | *.vsix 6 | server 7 | /package-lock.json 8 | /temp 9 | /cli -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 3 | // for the documentation about the extensions.json format 4 | "recommendations": [ 5 | "dbaeumer.vscode-eslint" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that compiles the extension and then opens it inside a new window 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | { 6 | "version": "0.2.0", 7 | "configurations": [ 8 | 9 | { 10 | "name": "Run Extension", 11 | "type": "extensionHost", 12 | "request": "launch", 13 | "args": [ 14 | "--extensionDevelopmentPath=${workspaceFolder}" 15 | ], 16 | "outFiles": [ 17 | "${workspaceFolder}/out/**/*.js" 18 | ], 19 | "env": { 20 | "EMMY_UNITY_DEV": "true", 21 | }, 22 | "preLaunchTask": "${defaultBuildTask}" 23 | }, 24 | { 25 | "name": "Extension Tests", 26 | "type": "extensionHost", 27 | "request": "launch", 28 | "args": [ 29 | "--extensionDevelopmentPath=${workspaceFolder}", 30 | "--extensionTestsPath=${workspaceFolder}/out/test/suite/index" 31 | ], 32 | "outFiles": [ 33 | "${workspaceFolder}/out/test/**/*.js" 34 | ], 35 | "preLaunchTask": "${defaultBuildTask}" 36 | } 37 | ] 38 | } 39 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | "files.exclude": { 4 | "out": false // set this to true to hide the "out" folder with the compiled JS files 5 | }, 6 | "search.exclude": { 7 | "out": true // set this to false to include "out" folder in search results 8 | }, 9 | // Turn off tsc task auto detection since we have the necessary tasks as npm scripts 10 | "typescript.tsc.autoDetect": "off" 11 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // See https://go.microsoft.com/fwlink/?LinkId=733558 2 | // for the documentation about the tasks.json format 3 | { 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "type": "npm", 8 | "script": "watch", 9 | "problemMatcher": "$tsc-watch", 10 | "isBackground": true, 11 | "presentation": { 12 | "reveal": "never" 13 | }, 14 | "group": { 15 | "kind": "build", 16 | "isDefault": true 17 | } 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | src/** 4 | .gitignore 5 | .yarnrc 6 | vsc-extension-quickstart.md 7 | **/tsconfig.json 8 | **/.eslintrc.json 9 | **/*.map 10 | **/*.ts 11 | temp 12 | tsconfig.json 13 | vsc-extension-quickstart.md 14 | tslint.json 15 | build.sh 16 | prepare-version.js -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | ## 2.0.1 4 | 5 | `FIX` 修复没有导出属性的BUG 6 | 7 | ## 2.0.0 8 | 9 | `NEW` 重写该插件, 支持最新的vscode-emmylua 10 | 11 | ## 1.3.1 12 | 13 | `NEW` 清理错误的补全项``, 重写导出的部分代码 14 | 15 | `NEW` 如果有什么Feature Request可以去 https://github.com/CppCXY/EmmyLua-Unity-LS 提交 16 | 17 | ## 1.2.5 18 | 19 | `FIX` 修复描述关于msbuild的需求描述, 要求最低dotnet sdk7 20 | 21 | `NEW` 提升命令行的可用性 22 | 23 | 24 | ## 1.2.4 25 | 26 | `FIX` 修复插件过多报错的问题 27 | 28 | `FIX` 修复内部类, 内部枚举被错误的提升到全局命名空间下 29 | 30 | ## 1.2.3 31 | 32 | `FIX` 降低msbuild.locator版本 33 | 34 | ## 1.2.2 35 | 36 | `FIX` 修复插件不可用的问题 37 | 38 | ## 1.2.0 39 | 40 | `NEW` 支持填写msbuild参数 41 | 42 | `NEW` 更完善的支持命名空间过滤 43 | 44 | `NEW` 将会加载解决方案内的所有项目文件 45 | 46 | `NEW` sln支持填写相对路径或者采用`${workspaceFolder}`参数 47 | 48 | `NEW` 注明仅仅支持`dotnet sdk`下的`msbuild` 49 | 50 | `NEW` 升级为`.net 7` 51 | 52 | ## 1.0.6 53 | 54 | `NEW` 支持扩展方法 55 | 56 | `NEW` 支持sumneko_lua 57 | 58 | ## 1.0.5 59 | 60 | `NEW` 支持设定sln目录 61 | 62 | `NEW` 版本号提高到1.0.5这样覆盖掉老版本的emmylua-unity 63 | 64 | `NEW` 支持选择框架 xlua / tolua 65 | 66 | `NEW` 支持选择注入插件 emmylua / sumneko_lua(但并未实现) 67 | 68 | ## 1.0.1 69 | 70 | 更新readme 71 | 72 | ## 1.0.0 73 | 74 | 首次发布 75 | 76 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # EmmyLuaUnity 2 | 3 | [English Doc Here](README_EN.md) 4 | 5 | ## 介绍 6 | 7 | 该插件是通过分析unity工程导出API获取的C#代码提示。 8 | 9 | 目前支持的框架: 10 | - xlua 11 | 12 | ## 使用方式 13 | 14 | 以unity工程为根目录打开工作区,或者打开任意工作区, 通过用户配置指定unity工程所在目录, 然后写好输出目录. 15 | 16 | 在左侧工作区面板上单击右键会出现`pull unity api`, 点击之后等待一段时间api就导出完了。 17 | 18 | ## 依赖 19 | 20 | 该插件并非是`self-contain`编译, 而且必须依赖目标电脑上和本插件编译时一样版本的MSBUILD, 所以请确保电脑上拥有`dotnet sdk 8` 21 | 22 | ## 问题 23 | 24 | 如果有任何问题可以去 [vscode-emmylua-unity](https://github.com/CppCXY/VSCode-EmmyLua-Unity) 25 | 26 | ## 支持的lua插件 27 | 28 | vscode-emmylua 支持 29 | 30 | 由于其他插件对相关语法支持不到位, 所以不支持其他插件 31 | 32 | [TODO] intellij-emmylua 支持 (https://github.com/CppCXY/EmmyLua-Unity2) 33 | -------------------------------------------------------------------------------- /README_EN.md: -------------------------------------------------------------------------------- 1 | # EmmyLuaUnity 2 | 3 | ## Introduction 4 | 5 | This plugin provides C# code suggestions by analyzing exported APIs from Unity projects. 6 | 7 | Currently supported frameworks: 8 | - xlua 9 | 10 | ## Usage 11 | 12 | Open the workspace with the Unity project as the root directory or open any workspace and specify the directory of the Unity project through user configuration. Then, specify the output directory. 13 | 14 | Right-click on the workspace panel on the left side and select "pull unity api". Wait for a while and the API will be exported. 15 | 16 | ## Dependencies 17 | 18 | This plugin is not self-contained and requires the same version of MSBUILD as the one used during compilation. Make sure you have `dotnet sdk 8` installed on your computer. 19 | 20 | ## Issues 21 | 22 | If you have any issues, please visit [vscode-emmylua-unity](https://github.com/CppCXY/VSCode-EmmyLua-Unity). 23 | 24 | ## Supported Lua plugins 25 | 26 | Supported by vscode-emmylua. 27 | 28 | Due to inadequate support for related syntax by other plugins, they are not supported. 29 | 30 | [TODO] Supported by intellij-emmylua (https://github.com/CppCXY/EmmyLua-Unity2) 31 | -------------------------------------------------------------------------------- /build/config.js: -------------------------------------------------------------------------------- 1 | exports.default = { 2 | lanServerVersion: "2.0.1", 3 | lanServerUrl: 'https://github.com/CppCXY/EmmyLua-Unity-LS/releases/download' 4 | } 5 | 6 | -------------------------------------------------------------------------------- /build/prepare.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const download = require('download'); 3 | const decompress = require('decompress') 4 | const config = require('./config').default; 5 | const args = process.argv 6 | 7 | async function downloadTo(url, path) { 8 | return new Promise((r, e) => { 9 | const d = download(url); 10 | d.then(r).catch(err => e(err)); 11 | d.pipe(fs.createWriteStream(path)); 12 | }); 13 | } 14 | 15 | async function downloadDepends() { 16 | await Promise.all([ 17 | downloadTo(`${config.lanServerUrl}/${config.lanServerVersion}/${args[2]}.zip`, 'temp/unity.zip'), 18 | ]); 19 | } 20 | 21 | async function build() { 22 | if (!fs.existsSync('temp')) { 23 | fs.mkdirSync('temp'); 24 | } 25 | 26 | await downloadDepends(); 27 | 28 | await decompress('temp/unity.zip', 'cli'); 29 | } 30 | 31 | build().catch(console.error); 32 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "emmylua-unity", 3 | "displayName": "EmmyLuaUnity", 4 | "description": "make emmylua get unity api", 5 | "keywords": [ 6 | "lua", 7 | "emmylua", 8 | "unity" 9 | ], 10 | "version": "2.0.2", 11 | "author": "CppCXY", 12 | "publisher": "CppCXY", 13 | "engines": { 14 | "vscode": "^1.89.0" 15 | }, 16 | "repository": "https://github.com/CppCXY/VSCode-EmmyLua-Unity", 17 | "categories": [ 18 | "Programming Languages" 19 | ], 20 | "activationEvents": [ 21 | "onLanguage:lua" 22 | ], 23 | "main": "./out/extension.js", 24 | "contributes": { 25 | "commands": [ 26 | { 27 | "command": "emmylua.unity.pull", 28 | "title": "pull unity api" 29 | } 30 | ], 31 | "menus": { 32 | "explorer/context": [ 33 | { 34 | "command": "emmylua.unity.pull" 35 | } 36 | ] 37 | }, 38 | "configuration": { 39 | "title": "EmmyLuaUnity", 40 | "properties": { 41 | "emmylua.unity.framework": { 42 | "type": "string", 43 | "enum": [ 44 | "XLua" 45 | ], 46 | "default": "XLua", 47 | "description": "宿主lua框架", 48 | "enumDescriptions": [ 49 | "XLua" 50 | ] 51 | }, 52 | "emmylua.unity.project_sln": { 53 | "type": "string", 54 | "default": "", 55 | "description": "当配置该选项时,插件一定会导出unity api, 所以" 56 | }, 57 | "emmylua.unity.output_dir": { 58 | "type": "string", 59 | "default": "", 60 | "description": "导出的文件路径" 61 | }, 62 | "emmylua.unity.msbuild_properties": { 63 | "type": "object", 64 | "default": {}, 65 | "description": "设置给msbuild的参数" 66 | } 67 | } 68 | } 69 | }, 70 | "scripts": { 71 | "vscode:prepublish": "yarn run compile", 72 | "compile": "tsc -p ./", 73 | "watch": "tsc -watch -p ./", 74 | "pretest": "yarn run compile && yarn run lint", 75 | "lint": "eslint src --ext ts", 76 | "test": "node ./out/test/runTest.js" 77 | }, 78 | "devDependencies": { 79 | "@types/glob": "^7.1.4", 80 | "@types/mocha": "^9.0.0", 81 | "@types/node": "14.x", 82 | "@types/vscode": "^1.89.0", 83 | "@typescript-eslint/eslint-plugin": "^5.1.0", 84 | "@typescript-eslint/parser": "^5.1.0", 85 | "@vscode/test-electron": "^1.6.2", 86 | "eslint": "^8.1.0", 87 | "glob": "^7.1.7", 88 | "mocha": "^9.1.3", 89 | "typescript": "^4.4.4", 90 | "download": "^8.0.0" 91 | }, 92 | "dependencies": { 93 | } 94 | } -------------------------------------------------------------------------------- /src/extension.ts: -------------------------------------------------------------------------------- 1 | // The module 'vscode' contains the VS Code extensibility API 2 | // Import the module and reference it with the alias vscode in your code below 3 | import * as path from "path"; 4 | import * as vscode from 'vscode'; 5 | import * as os from "os"; 6 | import * as fs from "fs" 7 | 8 | const LANGUAGE_ID = 'lua'; 9 | let DEBUG_MODE = true; 10 | let saveContext: vscode.ExtensionContext; 11 | 12 | // this method is called when your extension is activated 13 | // your extension is activated the very first time the command is executed 14 | export function activate(context: vscode.ExtensionContext) { 15 | DEBUG_MODE = process.env['EMMY_UNITY_DEV'] === "true"; 16 | saveContext = context; 17 | context.subscriptions.push(vscode.commands.registerCommand('emmylua.unity.pull', () => { 18 | pullUnityApi() 19 | })); 20 | } 21 | 22 | // this method is called when your extension is deactivated 23 | export function deactivate() { 24 | } 25 | 26 | async function pullUnityApi() { 27 | const config = vscode.workspace.getConfiguration(); 28 | const slnPath = await findSlnProject(); 29 | if (!slnPath) { 30 | vscode.window.showErrorMessage("Can't find unity project"); 31 | return; 32 | } 33 | let framework = config.get("emmylua.unity.framework"); 34 | if (!framework) { 35 | framework = "XLua"; 36 | } 37 | 38 | const properties = config.get("emmylua.unity.msbuild_properties"); 39 | let outputDir = config.get("emmylua.unity.output_dir"); 40 | if (!outputDir) { 41 | outputDir = ".EmmyLuaUnity" 42 | } 43 | 44 | let exePath = await getCliExePath(); 45 | let args = ["-s", `"${slnPath}"`, "-o", `${outputDir}`, "-b", framework, "-n", "UnityEngine"]; 46 | if (properties) { 47 | let first = true; 48 | for (let key in properties) { 49 | if (first) { 50 | args.push("-p"); 51 | first = false; 52 | } 53 | args.push(`${key}=${properties[key]}`); 54 | } 55 | } 56 | 57 | const terminalName = "EmmyLua.Unity"; 58 | let cli = vscode.window.terminals.find(t => t.name === terminalName); 59 | 60 | if (!cli) { 61 | cli = vscode.window.createTerminal(terminalName); 62 | } 63 | 64 | cli.show(); 65 | cli.sendText(`${exePath} ${args.join(" ")}`); 66 | 67 | vscode.window.showInformationMessage("Pulling unity api, please wait..."); 68 | } 69 | 70 | async function findSlnProject() { 71 | if (!vscode.workspace.workspaceFolders) { 72 | return null; 73 | } 74 | 75 | const workspacePath = vscode.workspace.workspaceFolders[0].uri.fsPath; 76 | let configSln = vscode.workspace.getConfiguration().get("emmylua.unity.project_sln"); 77 | if (configSln && configSln.length !== 0 && configSln.endsWith(".sln")) { 78 | if (!path.isAbsolute(configSln)) { 79 | if (configSln.startsWith(".")) { 80 | configSln = path.join(workspacePath, configSln); 81 | } 82 | else if (configSln.includes("${workspaceFolder}")) { 83 | configSln = configSln.replace("${workspaceFolder}", workspacePath); 84 | } 85 | } 86 | let absPath = path.resolve(configSln); 87 | if (fs.existsSync(absPath)) { 88 | return absPath; 89 | } 90 | } 91 | 92 | const cshapSln = await vscode.workspace.findFiles("*.sln"); 93 | if (cshapSln.length === 0) { 94 | return null; 95 | } 96 | return cshapSln[0]?.fsPath; 97 | } 98 | 99 | async function getCliExePath() { 100 | const cliPath = path.join(saveContext.extensionPath, "cli"); 101 | let platform = os.platform(); 102 | let cliExe = ""; 103 | if (platform === "win32") { 104 | return path.join(cliPath, "win32-x64/EmmyLua.Unity.Cli.exe"); 105 | } 106 | else if (platform === "darwin") { 107 | if (os.arch() === "arm64") { 108 | cliExe = path.join(cliPath, "darwin-arm64/EmmyLua.Unity.Cli"); 109 | } 110 | else { 111 | cliExe = path.join(cliPath, "darwin-x64/EmmyLua.Unity.Cli"); 112 | } 113 | } 114 | else if (platform === "linux") { 115 | cliExe = path.join(cliPath, "linux-x64/EmmyLua.Unity.Cli"); 116 | } 117 | 118 | fs.chmodSync(cliExe, '777'); 119 | return cliExe; 120 | } -------------------------------------------------------------------------------- /src/test/runTest.ts: -------------------------------------------------------------------------------- 1 | import * as path from 'path'; 2 | 3 | import { runTests } from '@vscode/test-electron'; 4 | 5 | async function main() { 6 | try { 7 | // The folder containing the Extension Manifest package.json 8 | // Passed to `--extensionDevelopmentPath` 9 | const extensionDevelopmentPath = path.resolve(__dirname, '../../'); 10 | 11 | // The path to test runner 12 | // Passed to --extensionTestsPath 13 | const extensionTestsPath = path.resolve(__dirname, './suite/index'); 14 | 15 | // Download VS Code, unzip it and run the integration test 16 | await runTests({ extensionDevelopmentPath, extensionTestsPath }); 17 | } catch (err) { 18 | console.error('Failed to run tests'); 19 | process.exit(1); 20 | } 21 | } 22 | 23 | main(); 24 | -------------------------------------------------------------------------------- /src/test/suite/extension.test.ts: -------------------------------------------------------------------------------- 1 | import * as assert from 'assert'; 2 | 3 | // You can import and use all API from the 'vscode' module 4 | // as well as import your extension to test it 5 | import * as vscode from 'vscode'; 6 | // import * as myExtension from '../../extension'; 7 | 8 | suite('Extension Test Suite', () => { 9 | vscode.window.showInformationMessage('Start all tests.'); 10 | 11 | test('Sample test', () => { 12 | assert.strictEqual(-1, [1, 2, 3].indexOf(5)); 13 | assert.strictEqual(-1, [1, 2, 3].indexOf(0)); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /src/test/suite/index.ts: -------------------------------------------------------------------------------- 1 | import * as path from 'path'; 2 | import * as Mocha from 'mocha'; 3 | import * as glob from 'glob'; 4 | 5 | export function run(): Promise { 6 | // Create the mocha test 7 | const mocha = new Mocha({ 8 | ui: 'tdd', 9 | color: true 10 | }); 11 | 12 | const testsRoot = path.resolve(__dirname, '..'); 13 | 14 | return new Promise((c, e) => { 15 | glob('**/**.test.js', { cwd: testsRoot }, (err, files) => { 16 | if (err) { 17 | return e(err); 18 | } 19 | 20 | // Add files to the test suite 21 | files.forEach(f => mocha.addFile(path.resolve(testsRoot, f))); 22 | 23 | try { 24 | // Run the mocha test 25 | mocha.run(failures => { 26 | if (failures > 0) { 27 | e(new Error(`${failures} tests failed.`)); 28 | } else { 29 | c(); 30 | } 31 | }); 32 | } catch (err) { 33 | console.error(err); 34 | e(err); 35 | } 36 | }); 37 | }); 38 | } 39 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "ES2020", 5 | "outDir": "out", 6 | "lib": [ 7 | "ES2020" 8 | ], 9 | "sourceMap": true, 10 | "rootDir": "src", 11 | "strict": true /* enable all strict type-checking options */ 12 | /* Additional Checks */ 13 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 14 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 15 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 16 | }, 17 | "exclude": [ 18 | "node_modules", 19 | ".vscode-test" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /vsc-extension-quickstart.md: -------------------------------------------------------------------------------- 1 | # Welcome to your VS Code Extension 2 | 3 | ## What's in the folder 4 | 5 | * This folder contains all of the files necessary for your extension. 6 | * `package.json` - this is the manifest file in which you declare your extension and command. 7 | * The sample plugin registers a command and defines its title and command name. With this information VS Code can show the command in the command palette. It doesn’t yet need to load the plugin. 8 | * `src/extension.ts` - this is the main file where you will provide the implementation of your command. 9 | * The file exports one function, `activate`, which is called the very first time your extension is activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`. 10 | * We pass the function containing the implementation of the command as the second parameter to `registerCommand`. 11 | 12 | ## Get up and running straight away 13 | 14 | * Press `F5` to open a new window with your extension loaded. 15 | * Run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World`. 16 | * Set breakpoints in your code inside `src/extension.ts` to debug your extension. 17 | * Find output from your extension in the debug console. 18 | 19 | ## Make changes 20 | 21 | * You can relaunch the extension from the debug toolbar after changing code in `src/extension.ts`. 22 | * You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes. 23 | 24 | 25 | ## Explore the API 26 | 27 | * You can open the full set of our API when you open the file `node_modules/@types/vscode/index.d.ts`. 28 | 29 | ## Run tests 30 | 31 | * Open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration dropdown pick `Extension Tests`. 32 | * Press `F5` to run the tests in a new window with your extension loaded. 33 | * See the output of the test result in the debug console. 34 | * Make changes to `src/test/suite/extension.test.ts` or create new test files inside the `test/suite` folder. 35 | * The provided test runner will only consider files matching the name pattern `**.test.ts`. 36 | * You can create folders inside the `test` folder to structure your tests any way you want. 37 | 38 | ## Go further 39 | 40 | * Reduce the extension size and improve the startup time by [bundling your extension](https://code.visualstudio.com/api/working-with-extensions/bundling-extension). 41 | * [Publish your extension](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) on the VSCode extension marketplace. 42 | * Automate builds by setting up [Continuous Integration](https://code.visualstudio.com/api/working-with-extensions/continuous-integration). 43 | --------------------------------------------------------------------------------