Skip to content

Commit dc92d4a

Browse files
committed
Lua integration
1 parent 02e2025 commit dc92d4a

File tree

6 files changed

+57
-1
lines changed

6 files changed

+57
-1
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@v3
26+
with:
27+
submodules: true
2628

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

.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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,9 @@
271271
"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",
272272
"package": "vsce package --yarn"
273273
},
274+
"extensionDependencies": [
275+
"sumneko.lua"
276+
],
274277
"devDependencies": {
275278
"@types/cheerio": "^0.22.28",
276279
"@types/glob": "^7.2.0",

src/extension-node.ts

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

66
import * as vscode from 'vscode';
7+
import path from 'path';
78
import { getPageViewFactory, getPreviewFactory } from './export_command/wikimedia_function/view';
89
import { loginFactory, logoutFactory } from './export_command/wikimedia_function/bot';
910
import { closeEditorFactory, postPageFactory, pullPageFactory } from './export_command/wikimedia_function/page';
@@ -30,8 +31,52 @@ export function activate(context: vscode.ExtensionContext): void {
3031
commandRegistrar.register('viewPage', getPageViewFactory);
3132
// Cite
3233
commandRegistrar.register('citeWeb', addWebCiteFactory);
34+
35+
configureLuaLibrary("Scribunto", true);
3336
}
3437

3538
export function deactivate(): void {
36-
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+
}
3782
}

0 commit comments

Comments
 (0)