I created an Xtext grammar and Language server in eclipse, this was built and added to a vscode extension. I have implemented the below code to start up the language server.
import * as path from 'path';
import { workspace, ExtensionContext } from 'vscode';
import {
LanguageClient,
LanguageClientOptions,
ServerOptions,
Trace,
TransportKind
} from 'vscode-languageclient/node'; // Use this dependency for version >= 7.0.0
export function activate(context: ExtensionContext) {
const executable = 'prototype.dsl.ide.bat';
const languageServerPath = path.join('server', 'bin', executable);
const serverLauncher = context.asAbsolutePath(languageServerPath);
const serverOptions: ServerOptions = {
run: {
command: serverLauncher,
args: ['-trace', '-log', 'debug'],
transport: TransportKind.ipc
},
debug: {
command: serverLauncher,
args: ['-trace', '-log', 'debug'],
transport: TransportKind.ipc
}
};
const config = workspace.getConfiguration();
const clientOptions: LanguageClientOptions = {
documentSelector: [{ scheme: 'file', language: 'tst' }],
synchronize: {
fileEvents: workspace.createFileSystemWatcher('**/*.*,**/*.tst')
},
initializationOptions: {
config
}
};
const languageClient = new LanguageClient('lspLanguageClient', 'Language Server', serverOptions, clientOptions);
languageClient.start();
languageClient.trace = Trace.Verbose;
let disposable = languageClient.start();
context.subscriptions.push(disposable);
}
Testing the implementation in vscode works and the grammar rules are detected.
The issue I am having is that in vscode on save the changes to the document only reflect in the language server the first time, all subsequent modifications and saves are not reflected in the language server.