diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml index dbb73f2..a951dba 100644 --- a/.github/workflows/build-test.yaml +++ b/.github/workflows/build-test.yaml @@ -31,6 +31,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 + with: + submodules: true - name: Install Node.js uses: actions/setup-node@v3 diff --git a/.github/workflows/markets-publish.yml b/.github/workflows/markets-publish.yml index 8aebe97..d837c9b 100644 --- a/.github/workflows/markets-publish.yml +++ b/.github/workflows/markets-publish.yml @@ -23,6 +23,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 + with: + submodules: true - name: Install Node.js uses: actions/setup-node@v3 diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..988a86b --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "EmmyLua"] + path = EmmyLua + url = https://github.com/davidxuang/EmmyMediawiki.git diff --git a/EmmyLua b/EmmyLua new file mode 160000 index 0000000..a654602 --- /dev/null +++ b/EmmyLua @@ -0,0 +1 @@ +Subproject commit a65460249703d87e256cc041a8999476da296ea9 diff --git a/package.json b/package.json index 89f9354..5abf704 100644 --- a/package.json +++ b/package.json @@ -254,6 +254,15 @@ "type": "boolean", "default": false, "markdownDescription": "If `PageTitle` is filled in `PAGE_INFO`, skip entering the title when posting." + }, + "wikitext.scopedLuaIntegration": { + "type": "string", + "default": "auto", + "enum": [ + "enabled", + "auto", + "disabled" + ] } } } @@ -271,6 +280,9 @@ "convert": "js-yaml snippets/snippets.yaml > snippets/snippets.json && js-yaml syntaxes/wikitext.tmLanguage.yaml > syntaxes/wikitext.tmLanguage.json && js-yaml language-configuration.yaml > language-configuration.json", "package": "vsce package --yarn" }, + "extensionDependencies": [ + "sumneko.lua" + ], "devDependencies": { "@types/cheerio": "^0.22.28", "@types/glob": "^7.2.0", diff --git a/src/extension-node.ts b/src/extension-node.ts index 2d6e71b..d595f7b 100644 --- a/src/extension-node.ts +++ b/src/extension-node.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as vscode from 'vscode'; +import path from 'path'; import { getPageViewFactory, getPreviewFactory } from './export_command/wikimedia_function/view'; import { loginFactory, logoutFactory } from './export_command/wikimedia_function/bot'; import { closeEditorFactory, postPageFactory, pullPageFactory } from './export_command/wikimedia_function/page'; @@ -30,8 +31,50 @@ export function activate(context: vscode.ExtensionContext): void { commandRegistrar.register('viewPage', getPageViewFactory); // Cite commandRegistrar.register('citeWeb', addWebCiteFactory); + + configureLuaLibrary( + 'Scribunto', + vscode.workspace.getConfiguration('wikitext').get('scopedLuaIntegration') !== 'disabled' + ); } export function deactivate(): void { - console.log("Extension is deactivate."); + console.log("Extension is inactive."); + + if (vscode.workspace.getConfiguration('wikitext').get('scopedLuaIntegration') !== 'enabled') { + configureLuaLibrary('Scribunto', false); + } +} + +export function configureLuaLibrary(folder: string, enable: boolean) { + const extensionId = 'rowewilsonfrederiskholme.wikitext'; + const extensionPath = vscode.extensions.getExtension(extensionId)?.extensionPath; + if (extensionPath === undefined) { + return; + } + + const folderPath = path.join(extensionPath, 'EmmyLua', folder); + const config = vscode.workspace.getConfiguration('Lua'); + let library: string[] | undefined = config.get('workspace.library'); + if (library === undefined) { + return; + } + + if (library && extensionPath) { + // remove any older versions of our path + library = library.filter(path => + !path.includes(extensionId) || + path.includes(extensionPath)); + + const index = library.indexOf(folderPath); + if (enable) { + if (index < 0) { + library.push(folderPath); + } + } + else if (index >= 0) { + library.splice(index, 1); + } + config.update('workspace.library', library, false); + } }