@@ -7,15 +7,16 @@ use std::sync::Arc;
7
7
8
8
use anyhow:: anyhow;
9
9
use lsp_types:: { ClientCapabilities , TextDocumentContentChangeEvent , Url } ;
10
+ use options:: GlobalOptions ;
10
11
use ruff_db:: Db ;
11
12
use ruff_db:: files:: { File , system_path_to_file} ;
12
13
use ruff_db:: system:: SystemPath ;
13
14
use ty_project:: { ProjectDatabase , ProjectMetadata } ;
14
15
15
16
pub ( crate ) use self :: capabilities:: ResolvedClientCapabilities ;
16
17
pub use self :: index:: DocumentQuery ;
17
- pub ( crate ) use self :: settings :: AllSettings ;
18
- pub use self :: settings:: ClientSettings ;
18
+ pub ( crate ) use self :: options :: { AllOptions , ClientOptions } ;
19
+ use self :: settings:: ClientSettings ;
19
20
use crate :: document:: { DocumentKey , DocumentVersion , NotebookDocument } ;
20
21
use crate :: session:: request_queue:: RequestQueue ;
21
22
use crate :: system:: { AnySystemPath , LSPSystem } ;
@@ -24,6 +25,7 @@ use crate::{PositionEncoding, TextDocument};
24
25
mod capabilities;
25
26
pub ( crate ) mod client;
26
27
pub ( crate ) mod index;
28
+ mod options;
27
29
mod request_queue;
28
30
mod settings;
29
31
@@ -58,12 +60,13 @@ impl Session {
58
60
pub ( crate ) fn new (
59
61
client_capabilities : & ClientCapabilities ,
60
62
position_encoding : PositionEncoding ,
61
- global_settings : ClientSettings ,
62
- workspace_folders : & [ ( Url , ClientSettings ) ] ,
63
+ global_options : GlobalOptions ,
64
+ workspace_folders : & [ ( Url , ClientOptions ) ] ,
63
65
) -> crate :: Result < Self > {
64
66
let mut workspaces = BTreeMap :: new ( ) ;
65
- let index = Arc :: new ( index:: Index :: new ( global_settings ) ) ;
67
+ let index = Arc :: new ( index:: Index :: new ( global_options . into_settings ( ) ) ) ;
66
68
69
+ // TODO: Consider workspace settings
67
70
for ( url, _) in workspace_folders {
68
71
let path = url
69
72
. to_file_path ( )
@@ -168,6 +171,7 @@ impl Session {
168
171
let key = self . key_from_url ( url) . ok ( ) ?;
169
172
Some ( DocumentSnapshot {
170
173
resolved_client_capabilities : self . resolved_client_capabilities . clone ( ) ,
174
+ client_settings : self . index ( ) . global_settings ( ) ,
171
175
document_ref : self . index ( ) . make_document_ref ( & key) ?,
172
176
position_encoding : self . position_encoding ,
173
177
} )
@@ -303,6 +307,7 @@ impl Drop for MutIndexGuard<'_> {
303
307
#[ derive( Debug ) ]
304
308
pub struct DocumentSnapshot {
305
309
resolved_client_capabilities : Arc < ResolvedClientCapabilities > ,
310
+ client_settings : Arc < ClientSettings > ,
306
311
document_ref : index:: DocumentQuery ,
307
312
position_encoding : PositionEncoding ,
308
313
}
@@ -312,14 +317,18 @@ impl DocumentSnapshot {
312
317
& self . resolved_client_capabilities
313
318
}
314
319
315
- pub fn query ( & self ) -> & index:: DocumentQuery {
320
+ pub ( crate ) fn query ( & self ) -> & index:: DocumentQuery {
316
321
& self . document_ref
317
322
}
318
323
319
324
pub ( crate ) fn encoding ( & self ) -> PositionEncoding {
320
325
self . position_encoding
321
326
}
322
327
328
+ pub ( crate ) fn client_settings ( & self ) -> & ClientSettings {
329
+ & self . client_settings
330
+ }
331
+
323
332
pub ( crate ) fn file ( & self , db : & dyn Db ) -> Option < File > {
324
333
match AnySystemPath :: try_from_url ( self . document_ref . file_url ( ) ) . ok ( ) ? {
325
334
AnySystemPath :: System ( path) => system_path_to_file ( db, path) . ok ( ) ,
0 commit comments