Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/markets-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "EmmyLua"]
path = EmmyLua
url = https://github.com/davidxuang/EmmyMediawiki.git
1 change: 1 addition & 0 deletions EmmyLua
Submodule EmmyLua added at a65460
12 changes: 12 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
}
}
Expand All @@ -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",
Expand Down
45 changes: 44 additions & 1 deletion src/extension-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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<string>('scopedLuaIntegration') !== 'disabled'
);
}

export function deactivate(): void {
console.log("Extension is deactivate.");
console.log("Extension is inactive.");

if (vscode.workspace.getConfiguration('wikitext').get<string>('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);
}
}