@@ -33,7 +33,9 @@ use triomphe::Arc;
3333use  vfs:: { AbsPath ,  AbsPathBuf ,  FileId ,  VfsPath } ; 
3434
3535use  crate :: { 
36-     config:: { Config ,  RustfmtConfig ,  WorkspaceSymbolConfig } , 
36+     config:: { 
37+         ClientCommandsConfig ,  Config ,  HoverActionsConfig ,  RustfmtConfig ,  WorkspaceSymbolConfig , 
38+     } , 
3739    diagnostics:: convert_diagnostic, 
3840    global_state:: { FetchWorkspaceRequest ,  GlobalState ,  GlobalStateSnapshot } , 
3941    line_index:: LineEndings , 
@@ -1463,13 +1465,14 @@ pub(crate) fn handle_code_action(
14631465        resolve, 
14641466        frange, 
14651467    ) ?; 
1468+     let  client_commands = snap. config . client_commands ( ) ; 
14661469    for  ( index,  assist)  in  assists. into_iter ( ) . enumerate ( )  { 
14671470        let  resolve_data = if  code_action_resolve_cap { 
14681471            Some ( ( index,  params. clone ( ) ,  snap. file_version ( file_id) ) ) 
14691472        }  else  { 
14701473            None 
14711474        } ; 
1472-         let  code_action = to_proto:: code_action ( & snap,  assist,  resolve_data) ?; 
1475+         let  code_action = to_proto:: code_action ( & snap,  & client_commands ,   assist,  resolve_data) ?; 
14731476
14741477        // Check if the client supports the necessary `ResourceOperation`s. 
14751478        let  changes = code_action. edit . as_ref ( ) . and_then ( |it| it. document_changes . as_ref ( ) ) ; 
@@ -1570,7 +1573,7 @@ pub(crate) fn handle_code_action_resolve(
15701573        ) ) 
15711574        . into ( ) ) ; 
15721575    } 
1573-     let  ca = to_proto:: code_action ( & snap,  assist. clone ( ) ,  None ) ?; 
1576+     let  ca = to_proto:: code_action ( & snap,  & snap . config . client_commands ( ) ,   assist. clone ( ) ,  None ) ?; 
15741577    code_action. edit  = ca. edit ; 
15751578    code_action. command  = ca. command ; 
15761579
@@ -2134,9 +2137,11 @@ fn to_command_link(command: lsp_types::Command, tooltip: String) -> lsp_ext::Com
21342137fn  show_impl_command_link ( 
21352138    snap :  & GlobalStateSnapshot , 
21362139    position :  & FilePosition , 
2140+     implementations :  bool , 
2141+     show_references :  bool , 
21372142)  -> Option < lsp_ext:: CommandLinkGroup >  { 
2138-     if  snap . config . hover_actions ( ) . implementations 
2139-         && snap . config . client_commands ( ) . show_reference 
2143+     if  implementations
2144+         && show_references 
21402145        && let  Some ( nav_data)  = snap. analysis . goto_implementation ( * position) . unwrap_or ( None ) 
21412146    { 
21422147        let  uri = to_proto:: url ( snap,  position. file_id ) ; 
@@ -2161,9 +2166,11 @@ fn show_impl_command_link(
21612166fn  show_ref_command_link ( 
21622167    snap :  & GlobalStateSnapshot , 
21632168    position :  & FilePosition , 
2169+     references :  bool , 
2170+     show_reference :  bool , 
21642171)  -> Option < lsp_ext:: CommandLinkGroup >  { 
2165-     if  snap . config . hover_actions ( ) . references 
2166-         && snap . config . client_commands ( ) . show_reference 
2172+     if  references
2173+         && show_reference
21672174        && let  Some ( ref_search_res)  = snap
21682175            . analysis 
21692176            . find_all_refs ( 
@@ -2198,8 +2205,9 @@ fn show_ref_command_link(
21982205fn  runnable_action_links ( 
21992206    snap :  & GlobalStateSnapshot , 
22002207    runnable :  Runnable , 
2208+     hover_actions_config :  & HoverActionsConfig , 
2209+     client_commands_config :  & ClientCommandsConfig , 
22012210)  -> Option < lsp_ext:: CommandLinkGroup >  { 
2202-     let  hover_actions_config = snap. config . hover_actions ( ) ; 
22032211    if  !hover_actions_config. runnable ( )  { 
22042212        return  None ; 
22052213    } 
@@ -2209,7 +2217,6 @@ fn runnable_action_links(
22092217        return  None ; 
22102218    } 
22112219
2212-     let  client_commands_config = snap. config . client_commands ( ) ; 
22132220    if  !( client_commands_config. run_single  || client_commands_config. debug_single )  { 
22142221        return  None ; 
22152222    } 
@@ -2244,11 +2251,10 @@ fn runnable_action_links(
22442251fn  goto_type_action_links ( 
22452252    snap :  & GlobalStateSnapshot , 
22462253    nav_targets :  & [ HoverGotoTypeData ] , 
2254+     hover_actions :  & HoverActionsConfig , 
2255+     client_commands :  & ClientCommandsConfig , 
22472256)  -> Option < lsp_ext:: CommandLinkGroup >  { 
2248-     if  !snap. config . hover_actions ( ) . goto_type_def 
2249-         || nav_targets. is_empty ( ) 
2250-         || !snap. config . client_commands ( ) . goto_location 
2251-     { 
2257+     if  !hover_actions. goto_type_def  || nav_targets. is_empty ( )  || !client_commands. goto_location  { 
22522258        return  None ; 
22532259    } 
22542260
@@ -2268,13 +2274,29 @@ fn prepare_hover_actions(
22682274    snap :  & GlobalStateSnapshot , 
22692275    actions :  & [ HoverAction ] , 
22702276)  -> Vec < lsp_ext:: CommandLinkGroup >  { 
2277+     let  hover_actions = snap. config . hover_actions ( ) ; 
2278+     let  client_commands = snap. config . client_commands ( ) ; 
22712279    actions
22722280        . iter ( ) 
22732281        . filter_map ( |it| match  it { 
2274-             HoverAction :: Implementation ( position)  => show_impl_command_link ( snap,  position) , 
2275-             HoverAction :: Reference ( position)  => show_ref_command_link ( snap,  position) , 
2276-             HoverAction :: Runnable ( r)  => runnable_action_links ( snap,  r. clone ( ) ) , 
2277-             HoverAction :: GoToType ( targets)  => goto_type_action_links ( snap,  targets) , 
2282+             HoverAction :: Implementation ( position)  => show_impl_command_link ( 
2283+                 snap, 
2284+                 position, 
2285+                 hover_actions. implementations , 
2286+                 client_commands. show_reference , 
2287+             ) , 
2288+             HoverAction :: Reference ( position)  => show_ref_command_link ( 
2289+                 snap, 
2290+                 position, 
2291+                 hover_actions. references , 
2292+                 client_commands. show_reference , 
2293+             ) , 
2294+             HoverAction :: Runnable ( r)  => { 
2295+                 runnable_action_links ( snap,  r. clone ( ) ,  & hover_actions,  & client_commands) 
2296+             } 
2297+             HoverAction :: GoToType ( targets)  => { 
2298+                 goto_type_action_links ( snap,  targets,  & hover_actions,  & client_commands) 
2299+             } 
22782300        } ) 
22792301        . collect ( ) 
22802302} 
0 commit comments