Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable lsp shutdown timeout #5266

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change could probably be reset - we don't see this file checked in very often

Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ target
helix-term/rustfmt.toml
result
runtime/grammars
.DS_Store
1 change: 1 addition & 0 deletions book/src/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ The following statusline elements can be configured:
| `display-messages` | Display LSP progress messages below statusline[^1] | `false` |
| `auto-signature-help` | Enable automatic popup of signature help (parameter hints) | `true` |
| `display-signature-help-docs` | Display docs under signature help popup | `true` |
| `shutdown-timeout` | Time in milliseconds to wait for lsp to shutdown before closing editor, set to 0 to close instantly. | `3000` |

[^1]: By default, a progress spinner is shown in the statusline beside the file path.

Expand Down
3 changes: 2 additions & 1 deletion helix-term/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,8 @@ impl Application {
errs.push(err);
}

if self.editor.close_language_servers(None).await.is_err() {
let timeout = self.editor.config().lsp.shutdown_timeout;
if self.editor.close_language_servers(timeout).await.is_err() && !timeout.is_zero() {
log::error!("Timed out waiting for language servers to shutdown");
errs.push(anyhow::format_err!(
"Timed out waiting for language servers to shutdown"
Expand Down
15 changes: 11 additions & 4 deletions helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ pub struct LspConfig {
pub auto_signature_help: bool,
/// Display docs under signature help popup
pub display_signature_help_docs: bool,
/// Time in milliseconds that the editor will wait for the lsp to shutdown before exiting
/// Set to 0 for instant. Defaults to 3000.
#[serde(
serialize_with = "serialize_duration_millis",
deserialize_with = "deserialize_duration_millis"
)]
pub shutdown_timeout: Duration,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a config option per-language-server (here: https://docs.helix-editor.com/languages.html#language-server-configuration) rather than editor-wide

}

impl Default for LspConfig {
Expand All @@ -250,6 +257,7 @@ impl Default for LspConfig {
display_messages: false,
auto_signature_help: true,
display_signature_help_docs: true,
shutdown_timeout: Duration::from_millis(3000),
}
}
}
Expand Down Expand Up @@ -1356,14 +1364,13 @@ impl Editor {
}
}

/// Closes language servers with timeout. The default timeout is 10000 ms, use
/// `timeout` parameter to override this.
/// Closes language servers with timeout, set to 0 to instantly shutdown without waiting for lsp
pub async fn close_language_servers(
&self,
timeout: Option<u64>,
timeout: Duration,
) -> Result<(), tokio::time::error::Elapsed> {
tokio::time::timeout(
Duration::from_millis(timeout.unwrap_or(3000)),
timeout,
future::join_all(
self.language_servers
.iter_clients()
Expand Down