Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

integrate with racket-langserver #10

Merged
merged 9 commits into from
Apr 29, 2020
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.vscode-test
out/
.DS_Store
node_modules
node_modules
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "racket-langserver"]
path = racket-langserver
url = https://github.com/JJPro/racket-langserver.git
40 changes: 37 additions & 3 deletions package-lock.json

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

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
"name": "magic-racket",
"displayName": "Magic Racket",
"description": "Language support for Racket: top notch syntax highlighting and REPL integration.",
"version": "0.4.5",
"version": "0.4.6",
"activationEvents": [
"onCommand:magic-racket.loadFileIntoNewRepl",
"onCommand:magic-racket.loadFileIntoRepl",
"onCommand:magic-racket.runFile",
"onCommand:magic-racket.executeSelectionInRepl",
"onCommand:magic-racket.openRepl"
"onCommand:magic-racket.openRepl",
"onLanguage:racket"
],
"main": "./out/extension.js",
"galleryBanner": {
Expand Down Expand Up @@ -182,6 +183,7 @@
"vscode-test": "^1.3.0"
},
"dependencies": {
"@types/vscode": "^1.39.0"
"@types/vscode": "^1.39.0",
"vscode-languageclient": "^6.1.3"
}
}
1 change: 1 addition & 0 deletions racket-langserver
Submodule racket-langserver added at f16fc9
48 changes: 47 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import * as vscode from "vscode";
import { LanguageClient } from "vscode-languageclient";

let langClient: LanguageClient;

function getRacketExecutable() {
let racket: string | undefined = vscode.workspace
Expand Down Expand Up @@ -76,9 +79,52 @@ function loadFileInRepl(repl: vscode.Terminal, filePath: string) {
repl.sendText(`(enter! (file "${normalizeFilePath(filePath)}"))`);
}

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

export function activate(context: vscode.ExtensionContext) {
/* ****** Language Client ******* */
const executable = {
command: "racket",
// args: ['--lib', 'racket-langserver'],
args: [context.asAbsolutePath("racket-langserver/main.rkt")],
// args: [context.asAbsolutePath('racket-language-server/main.rkt')],
};

// If the extension is launched in debug mode then the debug server options are used
// Otherwise the run options are used
const serverOptions = {
run: executable,
debug: executable,
};

// Options to control the language client
const clientOptions = {
// Register the server for racket documents
documentSelector: [{ scheme: "file", language: "racket" }],
synchronize: {
// Notify the server about file changes to '.clientrc files contained in the workspace
fileEvents: vscode.workspace.createFileSystemWatcher("**/.clientrc"),
},
};

// Create the language client and start the client.
langClient = new LanguageClient(
"magic-racket",
"Racket Language Client",
serverOptions,
clientOptions,
);

// Start the client. This will also launch the server
langClient.start();

/* ****** Language Client END ******* */

const loadFileIntoCurrent = vscode.commands.registerCommand(
"magic-racket.loadFileIntoRepl",
() => {
Expand Down