update to lsp for TCL
This commit is contained in:
+43
-1
@@ -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()
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"module": "commonjs",
|
||||
"target": "es2019",
|
||||
"lib": ["ES2019"],
|
||||
"outDir": "./dist",
|
||||
"outDir": "./out",
|
||||
"rootDir": "src",
|
||||
"sourceMap": true
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user