Skip to content
Merged
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
83 changes: 83 additions & 0 deletions editors/vscode/extension.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
const vscode = require('vscode');
const { LanguageClient, TransportKind } = require('vscode-languageclient/node');

let client;

function activate(context) {
const config = vscode.workspace.getConfiguration('wokelang');
const serverPath = config.get('serverPath', 'woke-lsp');

// Server options
const serverOptions = {
run: { command: serverPath, transport: TransportKind.stdio },
debug: { command: serverPath, transport: TransportKind.stdio }
};

// Client options
const clientOptions = {
documentSelector: [{ scheme: 'file', language: 'wokelang' }],
synchronize: {
configurationSection: 'wokelang'
},
initializationOptions: {
enableDiagnostics: config.get('enableDiagnostics', true),
enableCompletion: config.get('enableCompletion', true),
enableHover: config.get('enableHover', true),
enableFormatting: config.get('enableFormatting', true)
}
};

// Create the language client
client = new LanguageClient(
'wokelangLsp',
'WokeLang Language Server',
serverOptions,
clientOptions
);

// Register commands
context.subscriptions.push(
vscode.commands.registerCommand('wokelang.restartServer', async () => {
if (client) {
await client.stop();
client.start();
vscode.window.showInformationMessage('WokeLang LSP restarted.');
}
}),
vscode.commands.registerCommand('wokelang.showInfo', () => {
if (client) {
vscode.window.showInformationMessage(\WokeLang LSP running at: \);
}
}),
vscode.commands.registerCommand('wokelang.checkConsent', async () => {
if (client) {
const editor = vscode.window.activeTextEditor;
if (editor) {
await vscode.commands.executeCommand('wokelang.internal.checkConsent', editor.document.uri.toString());
vscode.window.showInformationMessage('Consent check triggered.');
}
}
}),
vscode.commands.registerCommand('wokelang.formatDocument', async () => {
const editor = vscode.window.activeTextEditor;
if (editor) {
await vscode.commands.executeCommand('editor.action.formatDocument');
}
})
);

// Start the client
client.start();
}

function deactivate() {
if (!client) {
return undefined;
}
return client.stop();
}

module.exports = {
activate,
deactivate
};
103 changes: 100 additions & 3 deletions editors/vscode/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "wokelang",
"displayName": "WokeLang",
"description": "Syntax highlighting and language configuration for WokeLang (.woke). The LSP client is temporarily removed pending reimplementation in AffineScript — see the repository issues.",
"description": "WokeLang VS Code extension providing syntax highlighting and LSP integration.",
"version": "0.1.0",
"publisher": "hyperpolymath",
"license": "MPL-2.0",
Expand Down Expand Up @@ -42,6 +42,103 @@
"scopeName": "source.wokelang",
"path": "./syntaxes/wokelang.tmLanguage.json"
}
]
],
"commands": [
{
"command": "wokelang.restartServer",
"title": "WokeLang: Restart Language Server"
},
{
"command": "wokelang.showInfo",
"title": "WokeLang: Show Server Info"
},
{
"command": "wokelang.checkConsent",
"title": "WokeLang: Check Consent"
},
{
"command": "wokelang.formatDocument",
"title": "WokeLang: Format Document"
}
],
"menus": {
"editor/context": [
{
"command": "wokelang.checkConsent",
"when": "editorLangId == wokelang",
"group": "navigation"
},
{
"command": "wokelang.formatDocument",
"when": "editorLangId == wokelang",
"group": "1_modification"
}
]
},
"keybindings": [
{
"command": "wokelang.formatDocument",
"key": "ctrl+shift+f",
"mac": "cmd+shift+f",
"when": "editorLangId == wokelang"
},
{
"command": "wokelang.checkConsent",
"key": "ctrl+shift+c",
"mac": "cmd+shift+c",
"when": "editorLangId == wokelang"
}
],
"configuration": {
"type": "object",
"title": "WokeLang",
"properties": {
"wokelang.serverPath": {
"type": "string",
"default": "woke-lsp",
"description": "Path to the woke-lsp executable."
},
"wokelang.enableDiagnostics": {
"type": "boolean",
"default": true,
"description": "Enable LSP diagnostics."
},
"wokelang.enableCompletion": {
"type": "boolean",
"default": true,
"description": "Enable LSP autocompletion."
},
"wokelang.enableHover": {
"type": "boolean",
"default": true,
"description": "Enable LSP hover information."
},
"wokelang.enableFormatting": {
"type": "boolean",
"default": true,
"description": "Enable LSP document formatting."
},
"wokelang.trace.server": {
"type": "string",
"enum": [
"off",
"messages",
"verbose"
],
"default": "off",
"description": "Trace level for the language server."
}
}
}
},
"main": "./extension.js",
"activationEvents": [
"onLanguage:wokelang"
],
"dependencies": {
"vscode-languageclient": "^9.0.1"
},
"devDependencies": {
"@types/vscode": "^1.60.0"
}
}
}
Loading