wip
This commit is contained in:
Vendored
+5
-1
@@ -9,5 +9,9 @@
|
|||||||
"dist": true // set this to false to include "dist" folder in search results
|
"dist": true // set this to false to include "dist" folder in search results
|
||||||
},
|
},
|
||||||
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
|
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
|
||||||
"typescript.tsc.autoDetect": "off"
|
"typescript.tsc.autoDetect": "off",
|
||||||
|
"cSpell.words": [
|
||||||
|
"dutchie",
|
||||||
|
"dutchies"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "dcs-mission-scripting-tools-compiler",
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "25.5.2"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "tsc -p . --outDir dist",
|
||||||
|
"watch": "tsc -p . --outDir dist --watch"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"dist/**/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -64,6 +64,8 @@ export class ScriptCompiler {
|
|||||||
const readStart = Date.now();
|
const readStart = Date.now();
|
||||||
for (const entry of entries) {
|
for (const entry of entries) {
|
||||||
if (entry.isFile() && entry.name.endsWith('.lua')) {
|
if (entry.isFile() && entry.name.endsWith('.lua')) {
|
||||||
|
|
||||||
|
|
||||||
const fullPath = path.join(entry.parentPath ?? entry.path, entry.name);
|
const fullPath = path.join(entry.parentPath ?? entry.path, entry.name);
|
||||||
const relativePath = path.relative(this.options.sourcePath, fullPath);
|
const relativePath = path.relative(this.options.sourcePath, fullPath);
|
||||||
const content = fs.readFileSync(fullPath, 'utf-8');
|
const content = fs.readFileSync(fullPath, 'utf-8');
|
||||||
|
|||||||
@@ -19,18 +19,38 @@
|
|||||||
"categories": [
|
"categories": [
|
||||||
"Other"
|
"Other"
|
||||||
],
|
],
|
||||||
"activationEvents": [],
|
"activationEvents": [
|
||||||
|
"onLanguage:lua",
|
||||||
|
"workspaceContains:**/*.lua"
|
||||||
|
],
|
||||||
"main": "./dist/extension.js",
|
"main": "./dist/extension.js",
|
||||||
"contributes": {
|
"contributes": {
|
||||||
"configuration": {
|
"configuration": {
|
||||||
"title": "Dutchies DCS Scripting Tools Settings",
|
"title": "Dutchies DCS Tools",
|
||||||
|
"type" : "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"dutchies-dcs-scripting-tools.dcsTypes": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": true,
|
||||||
|
"description": "Enable or disable DCS Types (adds types for DCS functions and objects)"
|
||||||
|
},
|
||||||
|
"dutchies-dcs-scripting-tools.spearheadTypes": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "(Coming Soon) Enable or disable Spearhead Types (requires DCS Types to be enabled)"
|
||||||
|
},
|
||||||
"dutchies-dcs-scripting-tools.compileAt" : {
|
"dutchies-dcs-scripting-tools.compileAt" : {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["onSave", "onCompileCommand"],
|
"enum": ["onSave", "onCompileCommand"],
|
||||||
"default": "onCompileCommand",
|
"default": "onCompileCommand",
|
||||||
"description": "When to compile the Lua scripts"
|
"description": "When to compile the Lua script"
|
||||||
|
},
|
||||||
|
"dutchies-dcs-scripting-tools.includeDevelopmentScript": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Adds an additional script. This can be referenced from DCS through doScriptFile. This will then execute the compiles script. This way you don't have to reinsert the script on each change, but can just hit 'restart'."
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"grammars": [
|
"grammars": [
|
||||||
@@ -41,6 +61,11 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"commands": [
|
"commands": [
|
||||||
|
{
|
||||||
|
"command": "dutchies-dcs-scripting-tools.openSettings",
|
||||||
|
"title": "Open Settings",
|
||||||
|
"category": "Dutchies DCS Tools"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "dutchies-dcs-scripting-tools.enable",
|
"command": "dutchies-dcs-scripting-tools.enable",
|
||||||
"title": "Enable",
|
"title": "Enable",
|
||||||
|
|||||||
@@ -13,46 +13,75 @@ let pluginPath : string | undefined;
|
|||||||
const logger = new Logger();
|
const logger = new Logger();
|
||||||
|
|
||||||
const extensionName = 'dutchies-dcs-scripting-tools';
|
const extensionName = 'dutchies-dcs-scripting-tools';
|
||||||
|
const publisherName = 'dutchie031';
|
||||||
|
const extensionSettingsFilter = `@ext:${publisherName}.${extensionName}`;
|
||||||
|
|
||||||
|
//TODO:
|
||||||
|
// - ENABLE/DISABLE with settings instead of commands (or both)
|
||||||
|
|
||||||
// This method is called when your extension is activated
|
// This method is called when your extension is activated
|
||||||
// Your extension is activated the very first time the command is executed
|
// Your extension is activated the very first time the command is executed
|
||||||
export function activate(context: vscode.ExtensionContext) {
|
export function activate(context: vscode.ExtensionContext) {
|
||||||
|
|
||||||
|
|
||||||
pluginPath = context.asAbsolutePath('lua-addons');
|
pluginPath = context.asAbsolutePath('lua-addons');
|
||||||
|
|
||||||
vscode.commands.registerCommand('dutchies-dcs-scripting-tools.enable', () => {
|
|
||||||
addPluginPathToSettings();
|
|
||||||
vscode.commands.executeCommand(
|
|
||||||
"lua.startServer"
|
|
||||||
);
|
|
||||||
vscode.window.showInformationMessage('Dutchies DCS Scripting Tools enabled.');
|
|
||||||
});
|
|
||||||
|
|
||||||
vscode.commands.registerCommand('dutchies-dcs-scripting-tools.disable', () => {
|
context.subscriptions.push(
|
||||||
removePluginPathFromSettings();
|
vscode.commands.registerCommand('dutchies-dcs-scripting-tools.enable', () => {
|
||||||
vscode.commands.executeCommand(
|
addPluginPathToSettings();
|
||||||
"lua.startServer"
|
vscode.commands.executeCommand(
|
||||||
);
|
"lua.startServer"
|
||||||
vscode.window.showInformationMessage('Dutchies DCS Scripting Tools disabled.');
|
);
|
||||||
});
|
vscode.window.showInformationMessage('Dutchies DCS Scripting Tools enabled.');
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
vscode.commands.registerCommand('dutchies-dcs-scripting-tools.compileLuaScripts', async () => {
|
context.subscriptions.push(
|
||||||
try{
|
vscode.commands.registerCommand('dutchies-dcs-scripting-tools.disable', () => {
|
||||||
const start = Date.now();
|
removePluginPathFromSettings();
|
||||||
await compileLuaScripts();
|
vscode.commands.executeCommand(
|
||||||
const end = Date.now();
|
"lua.startServer"
|
||||||
vscode.window.showInformationMessage(`Lua scripts compiled successfully in ${(end - start) / 1000} seconds.`);
|
);
|
||||||
}catch(err){
|
vscode.window.showInformationMessage('Dutchies DCS Scripting Tools disabled.');
|
||||||
vscode.window.showErrorMessage('Error compiling Lua scripts: ' + (err as Error).message);
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
context.subscriptions.push(
|
||||||
|
vscode.commands.registerCommand('dutchies-dcs-scripting-tools.openSettings', () => {
|
||||||
|
vscode.commands.executeCommand("workbench.action.openSettings", `@ext:${extensionSettingsFilter}`);
|
||||||
|
}));
|
||||||
|
|
||||||
|
context.subscriptions.push(
|
||||||
|
vscode.commands.registerCommand('dutchies-dcs-scripting-tools.compileLuaScripts', async () => {
|
||||||
|
try{
|
||||||
|
const start = Date.now();
|
||||||
|
await compileLuaScripts();
|
||||||
|
const end = Date.now();
|
||||||
|
vscode.window.showInformationMessage(`Lua scripts compiled successfully in ${(end - start) / 1000} seconds.`);
|
||||||
|
}catch(err){
|
||||||
|
vscode.window.showErrorMessage('Error compiling Lua scripts: ' + (err as Error).message);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
vscode.workspace.onDidSaveTextDocument(async(document) => {
|
||||||
|
logger.info(`Document saved: ${document.uri.fsPath} | Language: ${document.languageId}`);
|
||||||
|
if (document.languageId === 'lua') {
|
||||||
|
const config = vscode.workspace.getConfiguration(extensionName);
|
||||||
|
const compileAt = config.get<string>('compileAt') || "undefined";
|
||||||
|
if (compileAt === 'onSave') {
|
||||||
|
await compileLuaScripts();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
logger.info('Dutchies DCS Scripting Tools extension activated');
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method is called when your extension is deactivated
|
// This method is called when your extension is deactivated
|
||||||
export function deactivate()
|
export function deactivate()
|
||||||
{
|
{
|
||||||
removePluginPathFromSettings();
|
removePluginPathFromSettings();
|
||||||
|
logger.info('Dutchies DCS Scripting Tools extension deactivated');
|
||||||
}
|
}
|
||||||
|
|
||||||
class CompilationLogger implements ICompilationLogger {
|
class CompilationLogger implements ICompilationLogger {
|
||||||
@@ -72,6 +101,8 @@ class CompilationLogger implements ICompilationLogger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function compileLuaScripts() {
|
async function compileLuaScripts() {
|
||||||
|
logger.clear();
|
||||||
|
logger.info("Compiling...");
|
||||||
|
|
||||||
const config = vscode.workspace.getConfiguration('dcsScriptingTools');
|
const config = vscode.workspace.getConfiguration('dcsScriptingTools');
|
||||||
const sourcePath = config.get<string>('luaSourcePath') || '${workspaceFolder}/src';
|
const sourcePath = config.get<string>('luaSourcePath') || '${workspaceFolder}/src';
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ export class Logger {
|
|||||||
this.outputChannel.appendLine(`[${new Date().toISOString()}][ERROR] ${message}`);
|
this.outputChannel.appendLine(`[${new Date().toISOString()}][ERROR] ${message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clear() {
|
||||||
|
this.outputChannel.clear();
|
||||||
|
}
|
||||||
|
|
||||||
dispose() {
|
dispose() {
|
||||||
this.outputChannel.dispose();
|
this.outputChannel.dispose();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user