-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatic configuration reloading for
ruff server
(#10404)
## Summary Fixes #10366. `ruff server` now registers a file watcher on the client side using the LSP protocol, and listen for events on configuration files. On such an event, it reloads the configuration in the 'nearest' workspace to the file that was changed. ## Test Plan N/A
- Loading branch information
1 parent
5062572
commit 4f06d59
Showing
5 changed files
with
131 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
crates/ruff_server/src/server/api/notifications/did_change_watched_files.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use crate::server::api::LSPResult; | ||
use crate::server::client::Notifier; | ||
use crate::server::Result; | ||
use crate::session::Session; | ||
use lsp_types as types; | ||
use lsp_types::notification as notif; | ||
|
||
pub(crate) struct DidChangeWatchedFiles; | ||
|
||
impl super::NotificationHandler for DidChangeWatchedFiles { | ||
type NotificationType = notif::DidChangeWatchedFiles; | ||
} | ||
|
||
impl super::SyncNotificationHandler for DidChangeWatchedFiles { | ||
fn run( | ||
session: &mut Session, | ||
_notifier: Notifier, | ||
params: types::DidChangeWatchedFilesParams, | ||
) -> Result<()> { | ||
for change in params.changes { | ||
session | ||
.reload_configuration(&change.uri) | ||
.with_failure_code(lsp_server::ErrorCode::InternalError)?; | ||
} | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters