Skip to content

Commit 249b55a

Browse files
ok
1 parent dc1f1c6 commit 249b55a

File tree

13 files changed

+4068
-5
lines changed

13 files changed

+4068
-5
lines changed

lsp-bin/linux/arm64

4.11 MB
Binary file not shown.

lsp-bin/linux/x64

4.11 MB
Binary file not shown.

lsp-bin/linux/x86

4.11 MB
Binary file not shown.

lsp-bin/macos/arm64

3.91 MB
Binary file not shown.

lsp-bin/macos/x64

3.91 MB
Binary file not shown.

lsp-bin/macos/x86

3.91 MB
Binary file not shown.

lsp-bin/windows/arm64.exe

3.16 MB
Binary file not shown.

lsp-bin/windows/x64.exe

3.16 MB
Binary file not shown.

lsp-bin/windows/x86.exe

3.16 MB
Binary file not shown.

package-lock.json

Lines changed: 3989 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,20 @@
108108
"test": "vscode-test"
109109
},
110110
"devDependencies": {
111-
"@types/vscode": "^1.70.0",
112111
"@types/mocha": "^10.0.6",
113112
"@types/node": "20.x",
113+
"@types/vscode": "^1.70.0",
114114
"@typescript-eslint/eslint-plugin": "^7.11.0",
115115
"@typescript-eslint/parser": "^7.11.0",
116+
"@vscode/test-cli": "^0.0.9",
117+
"@vscode/test-electron": "^2.4.0",
116118
"eslint": "^8.57.0",
117-
"typescript": "^5.4.5",
118119
"ts-loader": "^9.5.1",
120+
"typescript": "^5.4.5",
119121
"webpack": "^5.92.0",
120-
"webpack-cli": "^5.1.4",
121-
"@vscode/test-cli": "^0.0.9",
122-
"@vscode/test-electron": "^2.4.0"
122+
"webpack-cli": "^5.1.4"
123+
},
124+
"dependencies": {
125+
"vscode-languageclient": "^9.0.1"
123126
}
124127
}

src/extension.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@ import formatCurrentDocument from "./codeFormatter";
44
import fileRunners from "./fileRunners";
55
import installBend from "./installBend";
66
import BendTreeDataProvider from "./bendTreeDataProvider";
7+
import { LanguageClient, LanguageClientOptions, ServerOptions } from 'vscode-languageclient/node';
8+
import runLSP from "./lsp";
9+
10+
11+
let client: LanguageClient;
712

813
function main(context: { subscriptions: vscode.Disposable[] }): void {
914
const bendTreeDataProvider: BendTreeDataProvider = new BendTreeDataProvider();
1015

16+
runLSP();
17+
1118
context.subscriptions.push(
1219
vscode.languages.registerDocumentFormattingEditProvider("bend", {
1320
provideDocumentFormattingEdits(): vscode.ProviderResult<any> {

src/lsp.ts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import vscode from "vscode";
2+
import { LanguageClient, LanguageClientOptions, ServerOptions } from "vscode-languageclient/node";
3+
import os from "os"
4+
import path from "path";
5+
import fs from "fs"
6+
7+
export default function runLSP() {
8+
let executablePath: string = '';
9+
const platform: string = os.platform();
10+
const arch: string = os.arch();
11+
12+
if (platform === "win32") {
13+
if (arch === "x64") {
14+
executablePath = path.join(__dirname, '..', 'lsp-bin', 'windows', 'x64.exe');
15+
} else if (os.arch() === "ia32") {
16+
executablePath = path.join(__dirname, '..', 'lsp-bin', 'windows', 'x86.exe');
17+
}
18+
else {
19+
executablePath = path.join(__dirname, '..', 'lsp-bin', 'windows', 'arm64.exe');
20+
}
21+
} else if (platform == "darwin") {
22+
if (arch === "x64") {
23+
executablePath = path.join(__dirname, '..', 'lsp-bin', 'macos', 'x64');
24+
} else if (os.arch() === "ia32") {
25+
executablePath = path.join(__dirname, '..', 'lsp-bin', 'macos', 'x86');
26+
}
27+
else {
28+
executablePath = path.join(__dirname, '..', 'lsp-bin', 'macos', 'arm64');
29+
}
30+
} else {
31+
if (arch === "x64") {
32+
executablePath = path.join(__dirname, '..', 'lsp-bin', 'linux', 'x64');
33+
} else if (os.arch() === "ia32") {
34+
executablePath = path.join(__dirname, '..', 'lsp-bin', 'linux', 'x86');
35+
}
36+
else {
37+
executablePath = path.join(__dirname, '..', 'lsp-bin', 'linux', 'arm64');
38+
}
39+
}
40+
fs.chmod(executablePath, 0o775, (err) => {
41+
if (err) throw err;
42+
console.log('The permissions for file "my_file.txt" have been changed!');
43+
});
44+
45+
let serverOptions: ServerOptions = {
46+
run: { command: executablePath },
47+
debug: { command: executablePath }
48+
};
49+
50+
let clientOptions: LanguageClientOptions = {
51+
documentSelector: [{ scheme: 'file', language: 'bend' }],
52+
};
53+
54+
// Create the language client and start the client.
55+
const client = new LanguageClient(
56+
'bendlang',
57+
'bendlangserver',
58+
serverOptions,
59+
clientOptions
60+
);
61+
62+
// Start the client. This will also launch the server
63+
client.start();
64+
}

0 commit comments

Comments
 (0)