2018-11-25 21:19:02 +00:00
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
// The module 'vscode' contains the VS Code extensibility API
|
|
|
|
// Import the module and reference it with the alias vscode in your code below
|
|
|
|
const vscode = require("vscode");
|
|
|
|
const languageClient = require("vscode-languageclient");
|
|
|
|
const path = require("path");
|
|
|
|
const fs = require("fs");
|
|
|
|
// Defines the search path of your language server DLL. (.NET Core)
|
|
|
|
const languageServerPaths = [
|
2019-01-19 13:13:35 +00:00
|
|
|
"../UpsilonLanguageServer/UpsilonLanguageServer/bin/Debug/netcoreapp2.1/UpsilonLanguageServer.dll",
|
|
|
|
"./server/UpsilonLanguageServer.dll"
|
2018-11-25 21:19:02 +00:00
|
|
|
];
|
|
|
|
function activateLanguageServer(context) {
|
|
|
|
// The server is implemented in an executable application.
|
|
|
|
let serverModule = null;
|
|
|
|
for (let p of languageServerPaths) {
|
|
|
|
p = context.asAbsolutePath(p);
|
|
|
|
// console.log(p);
|
|
|
|
if (fs.existsSync(p)) {
|
|
|
|
serverModule = p;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!serverModule)
|
|
|
|
throw new URIError("Cannot find the language server module.");
|
|
|
|
let workPath = path.dirname(serverModule);
|
|
|
|
console.log(`Use ${serverModule} as server module.`);
|
|
|
|
console.log(`Work path: ${workPath}.`);
|
|
|
|
// If the extension is launched in debug mode then the debug server options are used
|
|
|
|
// Otherwise the run options are used
|
|
|
|
let serverOptions = {
|
|
|
|
run: {
|
|
|
|
command: "dotnet",
|
|
|
|
args: [serverModule],
|
|
|
|
options: { cwd: workPath }
|
|
|
|
},
|
|
|
|
debug: {
|
|
|
|
command: "dotnet",
|
|
|
|
args: [serverModule, "--debug"],
|
|
|
|
options: { cwd: workPath }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
// Options to control the language client
|
|
|
|
let clientOptions = {
|
2018-12-14 17:49:59 +00:00
|
|
|
// Register the server for Upsilon documents
|
2018-11-25 21:19:02 +00:00
|
|
|
documentSelector: [
|
|
|
|
{
|
|
|
|
language: "upsilon",
|
|
|
|
scheme: "file"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
synchronize: {
|
|
|
|
configurationSection: "upsilonLanguageServer",
|
|
|
|
// Notify the server about file changes to '.clientrc files contain in the workspace
|
|
|
|
fileEvents: [
|
2018-12-12 21:29:47 +00:00
|
|
|
vscode.workspace.createFileSystemWatcher("**/*.clientrc"),
|
|
|
|
vscode.workspace.createFileSystemWatcher("**/*.yup"),
|
|
|
|
vscode.workspace.createFileSystemWatcher("**/*.lua"),
|
2018-11-29 17:13:45 +00:00
|
|
|
vscode.workspace.createFileSystemWatcher("**/.upsilon/*.json")
|
2018-11-25 21:19:02 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
};
|
|
|
|
// Create the language client and start the client.
|
|
|
|
let client = new languageClient.LanguageClient("upsilonLanguageServer", "Upsilon Language Server", serverOptions, clientOptions);
|
|
|
|
let disposable = client.start();
|
|
|
|
// Push the disposable to the context's subscriptions so that the
|
|
|
|
// client can be deactivated on extension deactivation
|
|
|
|
context.subscriptions.push(disposable);
|
|
|
|
}
|
|
|
|
// this method is called when your extension is activated
|
|
|
|
// your extension is activated the very first time the command is executed
|
|
|
|
function activate(context) {
|
|
|
|
console.log("Upsilon extension is now activated.");
|
|
|
|
activateLanguageServer(context);
|
|
|
|
}
|
|
|
|
exports.activate = activate;
|
|
|
|
// this method is called when your extension is deactivated
|
|
|
|
function deactivate() { }
|
|
|
|
exports.deactivate = deactivate;
|
|
|
|
//# sourceMappingURL=extension.js.map
|