@@ -887,28 +887,11 @@ impl State {
887887
888888 fn initialize ( & mut self , params : & Value ) -> Result < Value > {
889889 info ! ( "Begin {}" , lsp:: request:: Initialize :: METHOD ) ;
890- let ( languageId, filename) : ( String , String ) =
891- self . gather_args ( & [ VimVar :: LanguageId , VimVar :: Filename ] , params) ?;
892- let ( rootPath, has_snippet_support) : ( Option < String > , u64 ) = self . gather_args (
893- & [
894- ( "rootPath" , "v:null" ) ,
895- ( "hasSnippetSupport" , "s:hasSnippetSupport()" ) ,
896- ] ,
897- params,
898- ) ?;
899- let root = if let Some ( r) = rootPath {
900- r
901- } else {
902- let rootMarkers = self . get ( |state| Ok ( state. rootMarkers . clone ( ) ) ) ?;
903- let root = get_rootPath ( Path :: new ( & filename) , & languageId, & rootMarkers) ?
904- . to_string_lossy ( )
905- . into_owned ( ) ;
906- self . echomsg_ellipsis ( format ! ( "LanguageClient project root: {}" , root) ) ?;
907- root
908- } ;
909- info ! ( "Project root: {}" , root) ;
890+ let ( languageId, ) : ( String , ) = self . gather_args ( & [ VimVar :: LanguageId ] , params) ?;
891+ let ( has_snippet_support, ) : ( u64 , ) =
892+ self . gather_args ( & [ ( "hasSnippetSupport" , "s:hasSnippetSupport()" ) ] , params) ?;
910893 let has_snippet_support = has_snippet_support > 0 ;
911- self . update ( |state| Ok ( state . roots . insert ( languageId. clone ( ) , root . clone ( ) ) ) ) ? ;
894+ let root = self . roots . get ( & languageId) . cloned ( ) . unwrap_or_default ( ) ;
912895
913896 let initialization_options = self
914897 . get_workspace_settings ( & root)
@@ -2636,7 +2619,22 @@ impl State {
26362619 let ( cmdargs, ) : ( Vec < String > , ) = self . gather_args ( & [ ( "cmdargs" , "[]" ) ] , params) ?;
26372620 let cmdparams = vim_cmd_args_to_value ( & cmdargs) ?;
26382621 let params = params. combine ( & cmdparams) ;
2639- let ( languageId, ) : ( String , ) = self . gather_args ( & [ VimVar :: LanguageId ] , & params) ?;
2622+ let ( languageId, filename) : ( String , String ) =
2623+ self . gather_args ( & [ VimVar :: LanguageId , VimVar :: Filename ] , & params) ?;
2624+ let ( rootPath, ) : ( Option < String > , ) =
2625+ self . gather_args ( & [ ( "rootPath" , "v:null" ) ] , & params) ?;
2626+ let root = if let Some ( r) = rootPath {
2627+ r
2628+ } else {
2629+ let rootMarkers = self . get ( |state| Ok ( state. rootMarkers . clone ( ) ) ) ?;
2630+ let root = get_rootPath ( Path :: new ( & filename) , & languageId, & rootMarkers) ?
2631+ . to_string_lossy ( )
2632+ . into_owned ( ) ;
2633+ self . echomsg_ellipsis ( format ! ( "LanguageClient project root: {}" , root) ) ?;
2634+ root
2635+ } ;
2636+ info ! ( "Project root: {}" , root) ;
2637+ self . roots . insert ( languageId. clone ( ) , root. clone ( ) ) ;
26402638
26412639 if self . get ( |state| Ok ( state. writers . contains_key ( & languageId) ) ) ? {
26422640 bail ! (
@@ -2694,6 +2692,7 @@ impl State {
26942692 let process = std:: process:: Command :: new (
26952693 command. get ( 0 ) . ok_or_else ( || err_msg ( "Empty command!" ) ) ?,
26962694 ) . args ( & command[ 1 ..] )
2695+ . current_dir ( & root)
26972696 . stdin ( Stdio :: piped ( ) )
26982697 . stdout ( Stdio :: piped ( ) )
26992698 . stderr ( stderr)
0 commit comments