diff --git a/editor/vscode/client/.gitignore b/editor/vscode/client/.gitignore new file mode 100644 index 0000000..4648531 --- /dev/null +++ b/editor/vscode/client/.gitignore @@ -0,0 +1,4 @@ +node_modules/ +package-lock.json +yarn.lock +out/ diff --git a/editor/vscode/client/package.json b/editor/vscode/client/package.json new file mode 100644 index 0000000..d3c59f2 --- /dev/null +++ b/editor/vscode/client/package.json @@ -0,0 +1,29 @@ +{ + "name": "tsls", + "description": "Tree-sitter based language server", + "author": "Keyv Chan", + "license": "Apatcha 2", + "version": "0.0.1", + "publisher": "vscode", + "repository": { + "type": "git", + "url": "https://github.com/Microsoft/vscode-extension-samples" + }, + "engines": { + "vscode": "^1.63.0" + }, + "dependencies": { + "@types/node": "^17.0.21", + "typescript": "^4.6.2", + "vsce": "^2.6.7", + "vscode-languageclient": "^7.0.0" + }, + "main": "./out/extension.js", + "activationEvents": [ + "onLanguage:c" + ], + "devDependencies": { + "@types/vscode": "^1.63.0", + "@vscode/test-electron": "^2.1.2" + } +} diff --git a/editor/vscode/client/src/extension.ts b/editor/vscode/client/src/extension.ts new file mode 100644 index 0000000..de6ba42 --- /dev/null +++ b/editor/vscode/client/src/extension.ts @@ -0,0 +1,54 @@ +/* -------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + * ------------------------------------------------------------------------------------------ */ + +import { workspace, ExtensionContext } from 'vscode'; +import * as vscode from 'vscode'; + +import { + LanguageClient, + LanguageClientOptions, + ServerOptions, +} from 'vscode-languageclient/node'; + +let client: LanguageClient; + +export function activate(context: ExtensionContext) { + + // If the extension is launched in debug mode then the debug server options are used + // Otherwise the run options are used + const serverOptions: ServerOptions = { + run: {command: "/Users/keyv/Codebases/ClionProjects/tsls/target/debug/tsls"}, + debug: {command:"/Users/keyv/Codebases/ClionProjects/tsls/target/debug/tsls"} + }; + + // Options to control the language client + const clientOptions: LanguageClientOptions = { + // Register the server for plain text documents + documentSelector: [{ scheme: 'file', language: 'c' }], + synchronize: { + // Notify the server about file changes to '.clientrc files contained in the workspace + fileEvents: workspace.createFileSystemWatcher('**/.clientrc') + }, + traceOutputChannel: vscode.window.createOutputChannel('tsls') + }; + + // Create the language client and start the client. + client = new LanguageClient( + 'tsls', + 'TSLS', + serverOptions, + clientOptions + ); + + // Start the client. This will also launch the server + client.start(); +} + +export function deactivate(): Thenable | undefined { + if (!client) { + return undefined; + } + return client.stop(); +} diff --git a/editor/vscode/client/tsconfig.json b/editor/vscode/client/tsconfig.json new file mode 100644 index 0000000..bc08aa2 --- /dev/null +++ b/editor/vscode/client/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es2020", + "lib": ["es2020"], + "outDir": "out", + "rootDir": "src", + "sourceMap": true + }, + "include": ["src"], + "exclude": ["node_modules", ".vscode-test"] +} diff --git a/parsers/tree-sitter-query b/parsers/tree-sitter-query index e689610..c38cc9a 160000 --- a/parsers/tree-sitter-query +++ b/parsers/tree-sitter-query @@ -1 +1 @@ -Subproject commit e68961080c86a83d3cf0da239a8a81f7e1aa37cd +Subproject commit c38cc9a016a595f56ef7f7bda9018a854db3d9ea