Skip to content

Commit 71084d3

Browse files
committed
Lua integration
1 parent 700cb47 commit 71084d3

File tree

6 files changed

+59
-2
lines changed

6 files changed

+59
-2
lines changed

.github/workflows/build-test.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ jobs:
3131
steps:
3232
- name: Checkout repository
3333
uses: actions/checkout@v3
34+
with:
35+
submodules: true
3436

3537
- name: Install Node.js
3638
uses: actions/setup-node@v3

.github/workflows/markets-publish.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ jobs:
2323
steps:
2424
- name: Checkout repository
2525
uses: actions/checkout@v2
26+
with:
27+
submodules: true
2628

2729
- name: Install Node.js
2830
uses: actions/setup-node@v1

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "EmmyLua"]
2+
path = EmmyLua
3+
url = https://github.com/davidxuang/EmmyMediawiki.git

EmmyLua

Submodule EmmyLua added at bb893db

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@
273273
"scripts": {
274274
"vscode:prepublish": "yarn run compile",
275275
"compile": "yarn run convert && webpack --config webpack.config.js --mode production",
276-
"compile-debug" : "yarn run convert && webpack --config webpack.config.js --mode development",
276+
"compile-debug": "yarn run convert && webpack --config webpack.config.js --mode development",
277277
"lint": "eslint -c .eslintrc.yml --ext .ts ./src",
278278
"watch": "yarn run convert && webpack --config webpack.config.js --mode development --watch",
279279
"pretest": "yarn run compile-debug && yarn run lint",
@@ -283,6 +283,9 @@
283283
"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 &",
284284
"package": "vsce package --yarn"
285285
},
286+
"extensionDependencies": [
287+
"sumneko.lua"
288+
],
286289
"devDependencies": {
287290
"@types/bluebird": "^3.5.33",
288291
"@types/cheerio": "^0.22.28",

src/extension-node.ts

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as vscode from 'vscode';
7+
import path from 'path';
8+
79
import { getPreview, getPageView } from './export_command/wikimedia_function/view';
810
import { login, logout } from './export_command/wikimedia_function/bot';
911
import { postPage, pullPage, closeEditor } from './export_command/wikimedia_function/page';
@@ -29,8 +31,52 @@ export function activate(context: vscode.ExtensionContext): void {
2931
context.subscriptions.push(vscode.commands.registerCommand("wikitext.viewPage", getPageView));
3032
// Cite
3133
context.subscriptions.push(vscode.commands.registerCommand("wikitext.citeWeb", addWebCite));
34+
35+
configureLuaLibrary("Scribunto", true);
3236
}
3337

3438
export function deactivate(): void {
35-
console.log("Extension is deactivate.");
39+
console.log("Extension is inactive.");
40+
configureLuaLibrary("Scribunto", false);
41+
}
42+
43+
export function configureLuaLibrary(folder: string, enable: boolean) {
44+
const extensionId = "rowewilsonfrederiskholme.wikitext";
45+
const extensionPath = vscode.extensions.getExtension(extensionId)?.extensionPath;
46+
if (extensionPath === undefined) {
47+
return;
48+
}
49+
50+
// Use path.join to ensure the proper path seperators are used.
51+
const folderPath = path.join(extensionPath, "EmmyLua", folder);
52+
const config = vscode.workspace.getConfiguration("Lua");
53+
const library: string[] | undefined = config.get("workspace.library");
54+
if (library === undefined) {
55+
return;
56+
}
57+
58+
if (library && extensionPath) {
59+
// remove any older versions of our path
60+
for (let i = library.length-1; i >= 0; i--) {
61+
const item = library[i];
62+
const isSelfExtension = item.indexOf(extensionId) > -1;
63+
const isCurrentVersion = item.indexOf(extensionPath) > -1;
64+
if (isSelfExtension && !isCurrentVersion) {
65+
library.splice(i, 1);
66+
}
67+
}
68+
69+
const index = library.indexOf(folderPath);
70+
if (enable) {
71+
if (index === -1) {
72+
library.push(folderPath);
73+
}
74+
}
75+
else {
76+
if (index > -1) {
77+
library.splice(index, 1);
78+
}
79+
}
80+
config.update("workspace.library", library, true);
81+
}
3682
}

0 commit comments

Comments
 (0)