diff options
author | Lukas Wirth <[email protected]> | 2021-06-21 20:41:06 +0100 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-06-21 20:47:54 +0100 |
commit | 99c95b8fa15f2d9239625c19463f552c84ad99a2 (patch) | |
tree | 1ce5b6d19086eefba3585306bf794f4ddc86a858 /crates/rust-analyzer/src/handlers.rs | |
parent | 8b3d93ee29619c090878679d06477fe9d32bc14d (diff) |
Split hover actions config into its own config struct
Diffstat (limited to 'crates/rust-analyzer/src/handlers.rs')
-rw-r--r-- | crates/rust-analyzer/src/handlers.rs | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index eff1e6c93..dcead5f5c 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs | |||
@@ -861,13 +861,7 @@ pub(crate) fn handle_hover( | |||
861 | ) -> Result<Option<lsp_ext::Hover>> { | 861 | ) -> Result<Option<lsp_ext::Hover>> { |
862 | let _p = profile::span("handle_hover"); | 862 | let _p = profile::span("handle_hover"); |
863 | let position = from_proto::file_position(&snap, params.text_document_position_params)?; | 863 | let position = from_proto::file_position(&snap, params.text_document_position_params)?; |
864 | let hover_config = snap.config.hover(); | 864 | let info = match snap.analysis.hover(position, &snap.config.hover())? { |
865 | let info = match snap.analysis.hover( | ||
866 | position, | ||
867 | hover_config.links_in_hover, | ||
868 | hover_config.documentation, | ||
869 | hover_config.markdown, | ||
870 | )? { | ||
871 | None => return Ok(None), | 865 | None => return Ok(None), |
872 | Some(info) => info, | 866 | Some(info) => info, |
873 | }; | 867 | }; |
@@ -1487,7 +1481,7 @@ fn show_impl_command_link( | |||
1487 | snap: &GlobalStateSnapshot, | 1481 | snap: &GlobalStateSnapshot, |
1488 | position: &FilePosition, | 1482 | position: &FilePosition, |
1489 | ) -> Option<lsp_ext::CommandLinkGroup> { | 1483 | ) -> Option<lsp_ext::CommandLinkGroup> { |
1490 | if snap.config.hover().implementations { | 1484 | if snap.config.hover_actions().implementations { |
1491 | if let Some(nav_data) = snap.analysis.goto_implementation(*position).unwrap_or(None) { | 1485 | if let Some(nav_data) = snap.analysis.goto_implementation(*position).unwrap_or(None) { |
1492 | let uri = to_proto::url(snap, position.file_id); | 1486 | let uri = to_proto::url(snap, position.file_id); |
1493 | let line_index = snap.file_line_index(position.file_id).ok()?; | 1487 | let line_index = snap.file_line_index(position.file_id).ok()?; |
@@ -1513,7 +1507,7 @@ fn show_ref_command_link( | |||
1513 | snap: &GlobalStateSnapshot, | 1507 | snap: &GlobalStateSnapshot, |
1514 | position: &FilePosition, | 1508 | position: &FilePosition, |
1515 | ) -> Option<lsp_ext::CommandLinkGroup> { | 1509 | ) -> Option<lsp_ext::CommandLinkGroup> { |
1516 | if snap.config.hover().references { | 1510 | if snap.config.hover_actions().references { |
1517 | if let Some(ref_search_res) = snap.analysis.find_all_refs(*position, None).unwrap_or(None) { | 1511 | if let Some(ref_search_res) = snap.analysis.find_all_refs(*position, None).unwrap_or(None) { |
1518 | let uri = to_proto::url(snap, position.file_id); | 1512 | let uri = to_proto::url(snap, position.file_id); |
1519 | let line_index = snap.file_line_index(position.file_id).ok()?; | 1513 | let line_index = snap.file_line_index(position.file_id).ok()?; |
@@ -1544,8 +1538,8 @@ fn runnable_action_links( | |||
1544 | runnable: Runnable, | 1538 | runnable: Runnable, |
1545 | ) -> Option<lsp_ext::CommandLinkGroup> { | 1539 | ) -> Option<lsp_ext::CommandLinkGroup> { |
1546 | let cargo_spec = CargoTargetSpec::for_file(snap, runnable.nav.file_id).ok()?; | 1540 | let cargo_spec = CargoTargetSpec::for_file(snap, runnable.nav.file_id).ok()?; |
1547 | let hover_config = snap.config.hover(); | 1541 | let hover_actions_config = snap.config.hover_actions(); |
1548 | if !hover_config.runnable() || should_skip_target(&runnable, cargo_spec.as_ref()) { | 1542 | if !hover_actions_config.runnable() || should_skip_target(&runnable, cargo_spec.as_ref()) { |
1549 | return None; | 1543 | return None; |
1550 | } | 1544 | } |
1551 | 1545 | ||
@@ -1553,12 +1547,12 @@ fn runnable_action_links( | |||
1553 | to_proto::runnable(snap, runnable).ok().map(|r| { | 1547 | to_proto::runnable(snap, runnable).ok().map(|r| { |
1554 | let mut group = lsp_ext::CommandLinkGroup::default(); | 1548 | let mut group = lsp_ext::CommandLinkGroup::default(); |
1555 | 1549 | ||
1556 | if hover_config.run { | 1550 | if hover_actions_config.run { |
1557 | let run_command = to_proto::command::run_single(&r, action.run_title); | 1551 | let run_command = to_proto::command::run_single(&r, action.run_title); |
1558 | group.commands.push(to_command_link(run_command, r.label.clone())); | 1552 | group.commands.push(to_command_link(run_command, r.label.clone())); |
1559 | } | 1553 | } |
1560 | 1554 | ||
1561 | if hover_config.debug { | 1555 | if hover_actions_config.debug { |
1562 | let dbg_command = to_proto::command::debug_single(&r); | 1556 | let dbg_command = to_proto::command::debug_single(&r); |
1563 | group.commands.push(to_command_link(dbg_command, r.label)); | 1557 | group.commands.push(to_command_link(dbg_command, r.label)); |
1564 | } | 1558 | } |
@@ -1571,7 +1565,7 @@ fn goto_type_action_links( | |||
1571 | snap: &GlobalStateSnapshot, | 1565 | snap: &GlobalStateSnapshot, |
1572 | nav_targets: &[HoverGotoTypeData], | 1566 | nav_targets: &[HoverGotoTypeData], |
1573 | ) -> Option<lsp_ext::CommandLinkGroup> { | 1567 | ) -> Option<lsp_ext::CommandLinkGroup> { |
1574 | if !snap.config.hover().goto_type_def || nav_targets.is_empty() { | 1568 | if !snap.config.hover_actions().goto_type_def || nav_targets.is_empty() { |
1575 | return None; | 1569 | return None; |
1576 | } | 1570 | } |
1577 | 1571 | ||
@@ -1591,7 +1585,7 @@ fn prepare_hover_actions( | |||
1591 | snap: &GlobalStateSnapshot, | 1585 | snap: &GlobalStateSnapshot, |
1592 | actions: &[HoverAction], | 1586 | actions: &[HoverAction], |
1593 | ) -> Vec<lsp_ext::CommandLinkGroup> { | 1587 | ) -> Vec<lsp_ext::CommandLinkGroup> { |
1594 | if snap.config.hover().no_actions() || !snap.config.hover_actions() { | 1588 | if snap.config.hover_actions().none() || !snap.config.experimental_hover_actions() { |
1595 | return Vec::new(); | 1589 | return Vec::new(); |
1596 | } | 1590 | } |
1597 | 1591 | ||