3
3
use std:: num:: NonZeroUsize ;
4
4
use std:: panic:: PanicInfo ;
5
5
6
- use lsp_server as lsp;
7
- use lsp_types as types;
6
+ use lsp_server:: Message ;
8
7
use lsp_types:: {
9
- ClientCapabilities , DiagnosticOptions , NotebookCellSelector , NotebookDocumentSyncOptions ,
10
- NotebookSelector , TextDocumentSyncCapability , TextDocumentSyncOptions ,
8
+ ClientCapabilities , DiagnosticOptions , DiagnosticServerCapabilities , MessageType ,
9
+ ServerCapabilities , TextDocumentSyncCapability , TextDocumentSyncOptions , Url ,
11
10
} ;
12
11
13
12
use self :: connection:: { Connection , ConnectionInitializer } ;
@@ -74,7 +73,7 @@ impl Server {
74
73
init_params. client_info . as_ref ( ) ,
75
74
) ;
76
75
77
- let mut workspace_for_url = |url : lsp_types :: Url | {
76
+ let mut workspace_for_url = |url : Url | {
78
77
let Some ( workspace_settings) = workspace_settings. as_mut ( ) else {
79
78
return ( url, ClientSettings :: default ( ) ) ;
80
79
} ;
@@ -93,7 +92,7 @@ impl Server {
93
92
} ) . collect ( ) )
94
93
. or_else ( || {
95
94
tracing:: warn!( "No workspace(s) were provided during initialization. Using the current working directory as a default workspace..." ) ;
96
- let uri = types :: Url :: from_file_path ( std:: env:: current_dir ( ) . ok ( ) ?) . ok ( ) ?;
95
+ let uri = Url :: from_file_path ( std:: env:: current_dir ( ) . ok ( ) ?) . ok ( ) ?;
97
96
Some ( vec ! [ workspace_for_url( uri) ] )
98
97
} )
99
98
. ok_or_else ( || {
@@ -149,7 +148,7 @@ impl Server {
149
148
try_show_message (
150
149
"The Ruff language server exited with a panic. See the logs for more details."
151
150
. to_string ( ) ,
152
- lsp_types :: MessageType :: ERROR ,
151
+ MessageType :: ERROR ,
153
152
)
154
153
. ok ( ) ;
155
154
} ) ) ;
@@ -182,9 +181,9 @@ impl Server {
182
181
break ;
183
182
}
184
183
let task = match msg {
185
- lsp :: Message :: Request ( req) => api:: request ( req) ,
186
- lsp :: Message :: Notification ( notification) => api:: notification ( notification) ,
187
- lsp :: Message :: Response ( response) => scheduler. response ( response) ,
184
+ Message :: Request ( req) => api:: request ( req) ,
185
+ Message :: Notification ( notification) => api:: notification ( notification) ,
186
+ Message :: Response ( response) => scheduler. response ( response) ,
188
187
} ;
189
188
scheduler. dispatch ( task) ;
190
189
}
@@ -206,24 +205,12 @@ impl Server {
206
205
. unwrap_or_default ( )
207
206
}
208
207
209
- fn server_capabilities ( position_encoding : PositionEncoding ) -> types :: ServerCapabilities {
210
- types :: ServerCapabilities {
208
+ fn server_capabilities ( position_encoding : PositionEncoding ) -> ServerCapabilities {
209
+ ServerCapabilities {
211
210
position_encoding : Some ( position_encoding. into ( ) ) ,
212
- diagnostic_provider : Some ( types:: DiagnosticServerCapabilities :: Options (
213
- DiagnosticOptions {
214
- identifier : Some ( crate :: DIAGNOSTIC_NAME . into ( ) ) ,
215
- ..Default :: default ( )
216
- } ,
217
- ) ) ,
218
- notebook_document_sync : Some ( types:: OneOf :: Left ( NotebookDocumentSyncOptions {
219
- save : Some ( false ) ,
220
- notebook_selector : [ NotebookSelector :: ByCells {
221
- notebook : None ,
222
- cells : vec ! [ NotebookCellSelector {
223
- language: "python" . to_string( ) ,
224
- } ] ,
225
- } ]
226
- . to_vec ( ) ,
211
+ diagnostic_provider : Some ( DiagnosticServerCapabilities :: Options ( DiagnosticOptions {
212
+ identifier : Some ( crate :: DIAGNOSTIC_NAME . into ( ) ) ,
213
+ ..Default :: default ( )
227
214
} ) ) ,
228
215
text_document_sync : Some ( TextDocumentSyncCapability :: Options (
229
216
TextDocumentSyncOptions {
0 commit comments