Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
RohanVashisht1234 committed Jun 19, 2024
1 parent dc1f1c6 commit 249b55a
Show file tree
Hide file tree
Showing 13 changed files with 4,068 additions and 5 deletions.
Binary file added lsp-bin/linux/arm64
Binary file not shown.
Binary file added lsp-bin/linux/x64
Binary file not shown.
Binary file added lsp-bin/linux/x86
Binary file not shown.
Binary file added lsp-bin/macos/arm64
Binary file not shown.
Binary file added lsp-bin/macos/x64
Binary file not shown.
Binary file added lsp-bin/macos/x86
Binary file not shown.
Binary file added lsp-bin/windows/arm64.exe
Binary file not shown.
Binary file added lsp-bin/windows/x64.exe
Binary file not shown.
Binary file added lsp-bin/windows/x86.exe
Binary file not shown.
3,989 changes: 3,989 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,20 @@
"test": "vscode-test"
},
"devDependencies": {
"@types/vscode": "^1.70.0",
"@types/mocha": "^10.0.6",
"@types/node": "20.x",
"@types/vscode": "^1.70.0",
"@typescript-eslint/eslint-plugin": "^7.11.0",
"@typescript-eslint/parser": "^7.11.0",
"@vscode/test-cli": "^0.0.9",
"@vscode/test-electron": "^2.4.0",
"eslint": "^8.57.0",
"typescript": "^5.4.5",
"ts-loader": "^9.5.1",
"typescript": "^5.4.5",
"webpack": "^5.92.0",
"webpack-cli": "^5.1.4",
"@vscode/test-cli": "^0.0.9",
"@vscode/test-electron": "^2.4.0"
"webpack-cli": "^5.1.4"
},
"dependencies": {
"vscode-languageclient": "^9.0.1"
}
}
7 changes: 7 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@ import formatCurrentDocument from "./codeFormatter";
import fileRunners from "./fileRunners";
import installBend from "./installBend";
import BendTreeDataProvider from "./bendTreeDataProvider";
import { LanguageClient, LanguageClientOptions, ServerOptions } from 'vscode-languageclient/node';
import runLSP from "./lsp";


let client: LanguageClient;

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

runLSP();

context.subscriptions.push(
vscode.languages.registerDocumentFormattingEditProvider("bend", {
provideDocumentFormattingEdits(): vscode.ProviderResult<any> {
Expand Down
64 changes: 64 additions & 0 deletions src/lsp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import vscode from "vscode";
import { LanguageClient, LanguageClientOptions, ServerOptions } from "vscode-languageclient/node";
import os from "os"
import path from "path";
import fs from "fs"

export default function runLSP() {
let executablePath: string = '';
const platform: string = os.platform();
const arch: string = os.arch();

if (platform === "win32") {
if (arch === "x64") {
executablePath = path.join(__dirname, '..', 'lsp-bin', 'windows', 'x64.exe');
} else if (os.arch() === "ia32") {
executablePath = path.join(__dirname, '..', 'lsp-bin', 'windows', 'x86.exe');
}
else {
executablePath = path.join(__dirname, '..', 'lsp-bin', 'windows', 'arm64.exe');
}
} else if (platform == "darwin") {
if (arch === "x64") {
executablePath = path.join(__dirname, '..', 'lsp-bin', 'macos', 'x64');
} else if (os.arch() === "ia32") {
executablePath = path.join(__dirname, '..', 'lsp-bin', 'macos', 'x86');
}
else {
executablePath = path.join(__dirname, '..', 'lsp-bin', 'macos', 'arm64');
}
} else {
if (arch === "x64") {
executablePath = path.join(__dirname, '..', 'lsp-bin', 'linux', 'x64');
} else if (os.arch() === "ia32") {
executablePath = path.join(__dirname, '..', 'lsp-bin', 'linux', 'x86');
}
else {
executablePath = path.join(__dirname, '..', 'lsp-bin', 'linux', 'arm64');
}
}
fs.chmod(executablePath, 0o775, (err) => {
if (err) throw err;
console.log('The permissions for file "my_file.txt" have been changed!');
});

let serverOptions: ServerOptions = {
run: { command: executablePath },
debug: { command: executablePath }
};

let clientOptions: LanguageClientOptions = {
documentSelector: [{ scheme: 'file', language: 'bend' }],
};

// Create the language client and start the client.
const client = new LanguageClient(
'bendlang',
'bendlangserver',
serverOptions,
clientOptions
);

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

0 comments on commit 249b55a

Please sign in to comment.