File tree Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ impl Client {
49
49
root_markers : & [ String ] ,
50
50
id : usize ,
51
51
req_timeout : u64 ,
52
+ doc_path : Option < & std:: path:: PathBuf > ,
52
53
) -> Result < ( Self , UnboundedReceiver < ( usize , Call ) > , Arc < Notify > ) > {
53
54
// Resolve path to the binary
54
55
let cmd = which:: which ( cmd) . map_err ( |err| anyhow:: anyhow!( err) ) ?;
@@ -72,7 +73,10 @@ impl Client {
72
73
let ( server_rx, server_tx, initialize_notify) =
73
74
Transport :: start ( reader, writer, stderr, id) ;
74
75
75
- let root_path = find_root ( None , root_markers) ;
76
+ let root_path = find_root (
77
+ doc_path. and_then ( |x| x. parent ( ) . and_then ( |x| x. to_str ( ) ) ) ,
78
+ root_markers,
79
+ ) ;
76
80
77
81
let root_uri = root_path
78
82
. clone ( )
Original file line number Diff line number Diff line change @@ -320,7 +320,11 @@ impl Registry {
320
320
. map ( |( _, client) | client. as_ref ( ) )
321
321
}
322
322
323
- pub fn get ( & mut self , language_config : & LanguageConfiguration ) -> Result < Arc < Client > > {
323
+ pub fn get (
324
+ & mut self ,
325
+ language_config : & LanguageConfiguration ,
326
+ doc_path : Option < & std:: path:: PathBuf > ,
327
+ ) -> Result < Arc < Client > > {
324
328
let config = match & language_config. language_server {
325
329
Some ( config) => config,
326
330
None => return Err ( Error :: LspNotDefined ) ,
@@ -338,6 +342,7 @@ impl Registry {
338
342
& language_config. roots ,
339
343
id,
340
344
config. timeout ,
345
+ doc_path,
341
346
) ?;
342
347
self . incoming . push ( UnboundedReceiverStream :: new ( incoming) ) ;
343
348
let client = Arc :: new ( client) ;
Original file line number Diff line number Diff line change @@ -808,7 +808,7 @@ impl Editor {
808
808
809
809
// try to find a language server based on the language name
810
810
let language_server = doc. language . as_ref ( ) . and_then ( |language| {
811
- ls. get ( language)
811
+ ls. get ( language, doc . path ( ) )
812
812
. map_err ( |e| {
813
813
log:: error!(
814
814
"Failed to initialize the LSP for `{}` {{ {} }}" ,
You can’t perform that action at this time.
0 commit comments