Skip to content

Commit 2924d9b

Browse files
authored
Merge pull request #5 from bitloops/lsp-intergration
v0.1.0 - LSP integration
2 parents db757b7 + b9f6fd9 commit 2924d9b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+42340
-958
lines changed

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ npm-debug.log*
55
yarn-debug.log*
66
yarn-error.log*
77
lerna-debug.log*
8+
/server/out
9+
/client/out
810

911
# Diagnostic reports (https://nodejs.org/api/report.html)
1012
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
@@ -104,3 +106,12 @@ dist
104106
.tern-port
105107
bitloops-language-*.vsix
106108
*/.DS_Store
109+
110+
src/parser/grammar/BitloopsLexer.d.ts
111+
src/parser/grammar/BitloopsLexer.js
112+
src/parser/grammar/BitloopsParser.d.ts
113+
src/parser/grammar/BitloopsParser.js
114+
src/parser/grammar/BitloopsParserListener.d.ts
115+
src/parser/grammar/BitloopsParserListener.js
116+
src/parser/grammar/BitloopsParserVisitor.d.ts
117+
src/parser/grammar/BitloopsParserVisitor.js

.vscode/launch.json

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,39 @@
33
// Hover to view descriptions of existing attributes.
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
{
6-
"version": "0.2.0",
7-
"configurations": [
8-
{
9-
"name": "Extension",
10-
"type": "extensionHost",
11-
"request": "launch",
12-
"args": [
13-
"--extensionDevelopmentPath=${workspaceFolder}"
14-
]
15-
}
16-
]
17-
}
6+
"version": "0.2.0",
7+
"configurations": [
8+
{
9+
"name": "Extension",
10+
"type": "extensionHost",
11+
"request": "launch",
12+
"args": ["--extensionDevelopmentPath=${workspaceFolder}"]
13+
},
14+
{
15+
"type": "extensionHost",
16+
"request": "launch",
17+
"name": "Launch Client",
18+
"runtimeExecutable": "${execPath}",
19+
"args": ["--extensionDevelopmentPath=${workspaceRoot}"],
20+
"outFiles": ["${workspaceRoot}/client/out/**/*.js"],
21+
"preLaunchTask": {
22+
"type": "npm",
23+
"script": "watch"
24+
}
25+
},
26+
{
27+
"type": "node",
28+
"request": "attach",
29+
"name": "Attach to Server",
30+
"port": 6009,
31+
"restart": true,
32+
"outFiles": ["${workspaceRoot}/server/out/**/*.js"]
33+
}
34+
],
35+
"compounds": [
36+
{
37+
"name": "Client + Server",
38+
"configurations": ["Launch Client", "Attach to Server"]
39+
}
40+
]
41+
}

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"cSpell.words": ["ANTLR"]
3+
}

.vscode/tasks.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"version": "0.2.0",
3+
"tasks": [
4+
{
5+
"type": "npm",
6+
"script": "compile",
7+
"group": "build",
8+
"presentation": {
9+
"panel": "dedicated",
10+
"reveal": "never"
11+
},
12+
"problemMatcher": ["$tsc"]
13+
},
14+
{
15+
"type": "npm",
16+
"script": "watch",
17+
"isBackground": true,
18+
"group": {
19+
"kind": "build",
20+
"isDefault": true
21+
},
22+
"presentation": {
23+
"panel": "dedicated",
24+
"reveal": "never"
25+
},
26+
"problemMatcher": ["$tsc-watch"]
27+
}
28+
]
29+
}

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ This extension contributes the following settings:
1818

1919
* `bitloops.enable`: Enable/disable this extension.
2020

21+
## Running the application
22+
23+
- Run `yarn` in this folder. This installs all necessary yarn modules in both the client and server folder
24+
- Open VS Code on this folder.
25+
- Press `Ctrl+Shift+B` to start compiling the client and server in [watch mode](https://code.visualstudio.com/docs/editor/tasks#:~:text=The%20first%20entry%20executes,the%20HelloWorld.js%20file.).
26+
- Switch to the Run and Debug View in the Sidebar (Ctrl+Shift+D).
27+
- Select `Launch Client` from the drop down (if it is not already).
28+
- Press ▷ to run the launch config (F5).
29+
2130
## Known Issues
2231

2332
No known issues.

client/package.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "bitloops-server-client",
3+
"description": "BitLoops Server Client",
4+
"license": "MIT",
5+
"version": "0.0.1",
6+
"publisher": "Bitloops",
7+
"engines": {
8+
"vscode": "^1.63.0"
9+
},
10+
"dependencies": {
11+
"vscode-languageclient": "^7.0.0"
12+
},
13+
"devDependencies": {
14+
"@types/vscode": "^1.63.0",
15+
"@vscode/test-electron": "^2.1.2"
16+
}
17+
}

client/src/extension.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/* --------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
* ------------------------------------------------------------------------------------------ */
5+
6+
import * as path from 'path';
7+
import { workspace, ExtensionContext } from 'vscode';
8+
9+
import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind } from 'vscode-languageclient/node';
10+
11+
let client: LanguageClient;
12+
13+
export function activate(context: ExtensionContext) {
14+
console.log('init');
15+
// The server is implemented in node
16+
const serverModule = context.asAbsolutePath(path.join('server', 'out', 'index.js'));
17+
// The debug options for the server
18+
// --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging
19+
const debugOptions = { execArgv: ['--nolazy', '--inspect=6009'] };
20+
21+
// If the extension is launched in debug mode then the debug server options are used
22+
// Otherwise the run options are used
23+
const serverOptions: ServerOptions = {
24+
run: { module: serverModule, transport: TransportKind.ipc },
25+
debug: {
26+
module: serverModule,
27+
transport: TransportKind.ipc,
28+
options: debugOptions,
29+
},
30+
};
31+
32+
// Options to control the language client
33+
const clientOptions: LanguageClientOptions = {
34+
// Register the server for plain text documents
35+
documentSelector: [{ scheme: 'file', language: 'bitloops' }],
36+
synchronize: {
37+
// Notify the server about file changes to '.clientrc files contained in the workspace
38+
fileEvents: workspace.createFileSystemWatcher('**/.clientrc'),
39+
},
40+
};
41+
42+
// Create the language client and start the client.
43+
client = new LanguageClient('Bitloops LSP', 'Bitloops LSP', serverOptions, clientOptions);
44+
// console.log(client);
45+
46+
// Start the client. This will also launch the server
47+
client.start();
48+
}
49+
50+
export function deactivate(): Thenable<void> | undefined {
51+
if (!client) {
52+
return undefined;
53+
}
54+
return client.stop();
55+
}

client/testFixture/completion.txt

Whitespace-only changes.

client/testFixture/diagnostics.bl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ANY browsers, ANY OS.

client/testFixture/diagnostics.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ANY browsers, ANY OS.

0 commit comments

Comments
 (0)