Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Langauge Server Support #20

Merged
merged 4 commits into from
Jan 20, 2021
Merged
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
3 changes: 2 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -12,5 +12,6 @@
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceFolder}"]
}
]
],
"log": true
}
35 changes: 34 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -17,6 +17,9 @@
"onCommand:mint.init"
],
"main": "./out/src/extension",
"dependencies": {
"vscode-languageclient": "^6.1.3"
s0kil marked this conversation as resolved.
Show resolved Hide resolved
},
"devDependencies": {
"@types/node": "^14.11.2",
"@types/vscode": "^1.49.0",
@@ -35,6 +38,16 @@
"Programming Languages"
],
"contributes": {
"configuration": {
"type": "object",
"title": "Mint Language Server",
"properties": {
"mint.languageServer.location": {
"type": "string",
"description": "Provide a custom location for the language server binary"
}
}
},
"languages": [
{
"id": "mint",
40 changes: 38 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import * as cmd from "./commands";
import * as vscode from "vscode";
import * as fs from "fs";

import { LanguageClient } from 'vscode-languageclient';
import { MintFormattingProvider } from "./formatter";
import * as cmd from "./commands";

let client: LanguageClient

export async function activate(
context: vscode.ExtensionContext,
@@ -26,9 +31,40 @@ export async function activate(
vscode.commands.registerCommand("mint.start", cmd.mintStartCommand);
vscode.commands.registerCommand("mint.test", cmd.mintTestCommand);
vscode.commands.registerCommand("mint.version", cmd.mintVersionCommand);

const binaryLocation : string = vscode.workspace.getConfiguration('mint.languageServer').get('location')

if (binaryLocation) {
if (fs.existsSync(binaryLocation)) {
// Create the language client
client = new LanguageClient(
'mint_Language_Server',
gdotdesign marked this conversation as resolved.
Show resolved Hide resolved
'Mint Language Server',
{
command: binaryLocation,
args: ['ls'],
},
{
documentSelector: [
{scheme: 'file', language: 'mint'},
]
}
);

// Start the client
context.subscriptions.push(client.start());
} else {
vscode.window.showErrorMessage('Mint binary not found! You specified ' + binaryLocation);
}
}
}

export async function deactivate(isRestart: boolean = false): Promise<void> {
/// Set context deactivated
// Set context deactivated
vscode.commands.executeCommand("setContext", "mint:isActivated", false);

// Stop the language server client.
if (client) {
client.stop()
}
}