From 798fa1b576bcc69e1a7a244927b4fa3b7c3e7cee Mon Sep 17 00:00:00 2001 From: Jason Ji Date: Tue, 7 Apr 2020 03:27:55 -0400 Subject: [PATCH 1/9] integrate with racket-langserver --- .gitignore | 4 +++- package-lock.json | 40 +++++++++++++++++++++++++++++++++++--- package.json | 8 +++++--- src/extension.ts | 49 +++++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 92 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 5bb9688..db70333 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ .vscode-test out/ .DS_Store -node_modules \ No newline at end of file +node_modules +out/ +.vscode-test/ diff --git a/package-lock.json b/package-lock.json index 53de025..7378f9f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "magic-racket", - "version": "0.4.5", + "version": "0.4.6", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -86,8 +86,7 @@ "@types/vscode": { "version": "1.44.0", "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.44.0.tgz", - "integrity": "sha512-WJZtZlinE3meRdH+I7wTsIhpz/GLhqEQwmPGeh4s1irWLwMzCeTV8WZ+pgPTwrDXoafVUWwo1LiZ9HJVHFlJSQ==", - "dev": true + "integrity": "sha512-WJZtZlinE3meRdH+I7wTsIhpz/GLhqEQwmPGeh4s1irWLwMzCeTV8WZ+pgPTwrDXoafVUWwo1LiZ9HJVHFlJSQ==" }, "@typescript-eslint/eslint-plugin": { "version": "2.29.0", @@ -2305,6 +2304,41 @@ "spdx-expression-parse": "^3.0.0" } }, + "vscode-jsonrpc": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-5.0.1.tgz", + "integrity": "sha512-JvONPptw3GAQGXlVV2utDcHx0BiY34FupW/kI6mZ5x06ER5DdPG/tXWMVHjTNULF5uKPOUUD0SaXg5QaubJL0A==" + }, + "vscode-languageclient": { + "version": "6.1.3", + "resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-6.1.3.tgz", + "integrity": "sha512-YciJxk08iU5LmWu7j5dUt9/1OLjokKET6rME3cI4BRpiF6HZlusm2ZwPt0MYJ0lV5y43sZsQHhyon2xBg4ZJVA==", + "requires": { + "semver": "^6.3.0", + "vscode-languageserver-protocol": "^3.15.3" + }, + "dependencies": { + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" + } + } + }, + "vscode-languageserver-protocol": { + "version": "3.15.3", + "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.15.3.tgz", + "integrity": "sha512-zrMuwHOAQRhjDSnflWdJG+O2ztMWss8GqUUB8dXLR/FPenwkiBNkMIJJYfSN6sgskvsF0rHAoBowNQfbyZnnvw==", + "requires": { + "vscode-jsonrpc": "^5.0.1", + "vscode-languageserver-types": "3.15.1" + } + }, + "vscode-languageserver-types": { + "version": "3.15.1", + "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.15.1.tgz", + "integrity": "sha512-+a9MPUQrNGRrGU630OGbYVQ+11iOIovjCkqxajPa9w57Sd5ruK8WQNsslzpa0x/QJqC8kRc2DUxWjIFwoNm4ZQ==" + }, "vscode-test": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/vscode-test/-/vscode-test-1.3.0.tgz", diff --git a/package.json b/package.json index 26f6ad3..08cf7ef 100644 --- a/package.json +++ b/package.json @@ -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": { @@ -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" } } diff --git a/src/extension.ts b/src/extension.ts index 7d91c18..9a60fcd 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -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 @@ -76,10 +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) { - const loadFileIntoCurrent = vscode.commands.registerCommand( + //******* Language Client ******** + const executable = { + command: 'racket', + args: ['--lib', 'racket-langserver'], + }; + + // If the extension is launched in debug mode then the debug server options are used + // Otherwise the run options are used + let serverOptions = { + run: executable, + debug: executable + }; + + // Options to control the language client + let 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 ******** + + + let loadFileIntoCurrent = vscode.commands.registerCommand( "magic-racket.loadFileIntoRepl", () => { const editor = vscode.window.activeTextEditor; From 6ec961476676d7f27be6baba4fc09b2f307cba29 Mon Sep 17 00:00:00 2001 From: Jason Ji Date: Thu, 9 Apr 2020 20:51:50 -0400 Subject: [PATCH 2/9] fix symbol lookup --- racket-langserver | 1 + src/extension.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 160000 racket-langserver diff --git a/racket-langserver b/racket-langserver new file mode 160000 index 0000000..86b55b1 --- /dev/null +++ b/racket-langserver @@ -0,0 +1 @@ +Subproject commit 86b55b118973949ef591da8c80307d42f7df47de diff --git a/src/extension.ts b/src/extension.ts index 9a60fcd..7d378ab 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -90,7 +90,8 @@ export function activate(context: vscode.ExtensionContext) { //******* Language Client ******** const executable = { command: 'racket', - args: ['--lib', 'racket-langserver'], + // args: ['--lib', 'racket-langserver'], + args: [context.asAbsolutePath('racket-langserver/main.rkt')], }; // If the extension is launched in debug mode then the debug server options are used From 0420612077f4a79f6b12e9ae9e211804c2867d11 Mon Sep 17 00:00:00 2001 From: Jason Ji Date: Thu, 9 Apr 2020 23:37:38 -0400 Subject: [PATCH 3/9] switch to racket-language-server as Racket LSP implementation --- racket-language-server | 1 + src/extension.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 160000 racket-language-server diff --git a/racket-language-server b/racket-language-server new file mode 160000 index 0000000..aa8d03b --- /dev/null +++ b/racket-language-server @@ -0,0 +1 @@ +Subproject commit aa8d03b1f0cda1955a5716998085c52a57580285 diff --git a/src/extension.ts b/src/extension.ts index 7d378ab..1d81468 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -91,7 +91,8 @@ export function activate(context: vscode.ExtensionContext) { const executable = { command: 'racket', // args: ['--lib', 'racket-langserver'], - args: [context.asAbsolutePath('racket-langserver/main.rkt')], + // 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 From c2d56a53b77962df2849a0710959506185c14dea Mon Sep 17 00:00:00 2001 From: Jason Ji Date: Fri, 10 Apr 2020 02:23:45 -0400 Subject: [PATCH 4/9] switch back to racket-langserver as language server --- racket-langserver | 2 +- src/extension.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/racket-langserver b/racket-langserver index 86b55b1..4d5d822 160000 --- a/racket-langserver +++ b/racket-langserver @@ -1 +1 @@ -Subproject commit 86b55b118973949ef591da8c80307d42f7df47de +Subproject commit 4d5d822edd36e97aa4dcb7cebfaf65318979d4b9 diff --git a/src/extension.ts b/src/extension.ts index 1d81468..4815b01 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -91,8 +91,8 @@ export function activate(context: vscode.ExtensionContext) { const executable = { command: 'racket', // args: ['--lib', 'racket-langserver'], - // args: [context.asAbsolutePath('racket-langserver/main.rkt')], - args: [context.asAbsolutePath('racket-language-server/main.rkt')], + 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 From 7ce53616b3df37fd815c411aaedfab4b08cb2299 Mon Sep 17 00:00:00 2001 From: Jason Ji Date: Fri, 10 Apr 2020 04:49:28 -0400 Subject: [PATCH 5/9] update submodule racket-langserver --- racket-langserver | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/racket-langserver b/racket-langserver index 4d5d822..f16fc9e 160000 --- a/racket-langserver +++ b/racket-langserver @@ -1 +1 @@ -Subproject commit 4d5d822edd36e97aa4dcb7cebfaf65318979d4b9 +Subproject commit f16fc9e97f009062989ecc1f2e8a282ac1a3c524 From 91ef2aeeb9afcedd983ec037d31ad10aede876cd Mon Sep 17 00:00:00 2001 From: Jason Ji Date: Tue, 28 Apr 2020 22:41:34 -0400 Subject: [PATCH 6/9] resolve .gitignore file merge conflict --- .gitignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitignore b/.gitignore index db70333..18c6249 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,3 @@ out/ .DS_Store node_modules -out/ -.vscode-test/ From 4f75f26840b6215dac4c77df1710f8d56c43a623 Mon Sep 17 00:00:00 2001 From: Jason Ji Date: Tue, 28 Apr 2020 23:04:37 -0400 Subject: [PATCH 7/9] linting fix --- racket-language-server | 1 - src/extension.ts | 83 +++++++++++++++++++++--------------------- 2 files changed, 41 insertions(+), 43 deletions(-) delete mode 160000 racket-language-server diff --git a/racket-language-server b/racket-language-server deleted file mode 160000 index aa8d03b..0000000 --- a/racket-language-server +++ /dev/null @@ -1 +0,0 @@ -Subproject commit aa8d03b1f0cda1955a5716998085c52a57580285 diff --git a/src/extension.ts b/src/extension.ts index 4815b01..d9a56fb 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,5 +1,5 @@ import * as vscode from "vscode"; -import { LanguageClient } from 'vscode-languageclient'; +import { LanguageClient } from "vscode-languageclient"; let langClient: LanguageClient; @@ -81,52 +81,51 @@ function loadFileInRepl(repl: vscode.Terminal, filePath: string) { export function deactivate() { if (!langClient) { - return undefined; - } - return langClient.stop(); + return undefined; + } + return langClient.stop(); } export function activate(context: vscode.ExtensionContext) { - //******* Language Client ******** - const executable = { - command: 'racket', + /* ****** Language Client ******* */ + const executable = { + command: "racket", // args: ['--lib', 'racket-langserver'], - args: [context.asAbsolutePath('racket-langserver/main.rkt')], + 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 - let serverOptions = { - run: executable, - debug: executable - }; - - // Options to control the language client - let 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 ******** - - - let loadFileIntoCurrent = vscode.commands.registerCommand( + }; + + // 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", () => { const editor = vscode.window.activeTextEditor; From da698a22d10597f680ba0d9057c4a0165679f7fe Mon Sep 17 00:00:00 2001 From: Jason Ji Date: Wed, 29 Apr 2020 04:41:28 -0400 Subject: [PATCH 8/9] remove racket-langserver dir preparing for adopting of submodules --- racket-langserver | 1 - 1 file changed, 1 deletion(-) delete mode 160000 racket-langserver diff --git a/racket-langserver b/racket-langserver deleted file mode 160000 index f16fc9e..0000000 --- a/racket-langserver +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f16fc9e97f009062989ecc1f2e8a282ac1a3c524 From 28972ea564b30645314796eaec20a14229811168 Mon Sep 17 00:00:00 2001 From: Jason Ji Date: Wed, 29 Apr 2020 04:44:38 -0400 Subject: [PATCH 9/9] added racket-langserver submodule to project --- .gitmodules | 3 +++ racket-langserver | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 racket-langserver diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..9bff352 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "racket-langserver"] + path = racket-langserver + url = https://github.com/JJPro/racket-langserver.git diff --git a/racket-langserver b/racket-langserver new file mode 160000 index 0000000..f16fc9e --- /dev/null +++ b/racket-langserver @@ -0,0 +1 @@ +Subproject commit f16fc9e97f009062989ecc1f2e8a282ac1a3c524