stop method

Future<void> stop()

Stop the server.

Implementation

Future<void> stop() async {
  state = LspServerState.stopping;
  try {
    // Send shutdown request
    await sendRequest('shutdown', {}).timeout(
      const Duration(seconds: 5),
      onTimeout: () => <String, dynamic>{},
    );
    // Send exit notification
    sendNotification('exit', {});
    await Future.delayed(const Duration(milliseconds: 200));
  } catch (_) {}

  _process.kill(ProcessSignal.sigterm);
  await _stdoutSub.cancel();
  state = LspServerState.stopped;
}