update to lsp for TCL

This commit is contained in:
Christoph Brandau
2025-07-15 16:37:40 +02:00
parent 80f3019932
commit 12ed7ff2bc
12 changed files with 423 additions and 141 deletions
+43 -1
View File
@@ -3,7 +3,7 @@ import {
LanguageClient,
LanguageClientOptions,
ServerOptions,
Executable
TransportKind
} from "vscode-languageclient/node"
import {
formatCdlFile,
@@ -14,10 +14,45 @@ import {
diagnosticHandler,
tclDocumentSymbolProvider
} from "./common/handlers"
import * as path from "path"
let client: LanguageClient
export function activate(context: vscode.ExtensionContext) {
// The server is implemented in node
const serverModule = context.asAbsolutePath(path.join("out", "server", "src", "server.js"))
console.log(context.asAbsolutePath(path.join("server", "src", "server.js")))
// 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: { module: serverModule, transport: TransportKind.ipc },
debug: {
module: serverModule,
transport: TransportKind.ipc
}
}
// Options to control the language client
const clientOptions: LanguageClientOptions = {
// Register the server for plain text documents
documentSelector: [{ scheme: "file", language: "tcl" }],
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.
client = new LanguageClient(
"languageServerExample",
"Language Server Example",
serverOptions,
clientOptions
)
// Start the client. This will also launch the server
client.start()
//
const formatCdlProvider = vscode.languages.registerDocumentFormattingEditProvider(
{ scheme: "file", language: "cdl" },
{
@@ -115,3 +150,10 @@ export function activate(context: vscode.ExtensionContext) {
}
})
}
export function deactivate(): Thenable<void> | undefined {
if (!client) {
return undefined
}
return client.stop()
}
+1 -1
View File
@@ -3,7 +3,7 @@
"module": "commonjs",
"target": "es2019",
"lib": ["ES2019"],
"outDir": "./dist",
"outDir": "./out",
"rootDir": "src",
"sourceMap": true
},