ChimeHQ / LanguageClient

Language Server Protocol (LSP) client for Swift
BSD 3-Clause "New" or "Revised" License
93 stars 10 forks source link

Allow RestartingServer behavior to be configured #15

Open jbromberg opened 5 months ago

jbromberg commented 5 months ago

Would be nice to support behavior for how the RestartingServer restarts.

Currently, there's a 5 second cooldown hardcoded in: https://github.com/ChimeHQ/LanguageClient/blob/253b8a0d2ea2a8c84cbd51dd6931ae0936b1f1f9/Sources/LanguageClient/RestartingServer.swift#L232

Possible idea:

enum RestartBehavior {
    case nextRequest
    case afterCooldown(seconds: Int)
}
jbromberg commented 5 months ago

This might be worthy of a separate issue, but it may also be helpful to allow a closure to be executed when the server restarts. you may want to send the server a didOpen notification or do some other work.

mattmassicotte commented 5 months ago

Can you elaborate on what you want to send the server? Its state should be transparently restored when it is started back up. For example, any open documents are automatically re-opened.

jbromberg commented 5 months ago

It seems like open docs are re-opened only when the server state is set to restartNeeded but I don't see anywhere that it would reach this state. When calling connectionInvalidated() the server state gets set to notStarted after 5 seconds which doesn't reopen docs upon reconnecting.