Skip to content

Commit

Permalink
fix: resolve #129
Browse files Browse the repository at this point in the history
  • Loading branch information
Feel-ix-343 committed Jun 24, 2024
1 parent bd44db3 commit b2b171b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub struct Settings {
pub references_in_codeblocks: bool,
pub include_md_extension_md_link: bool,
pub include_md_extension_wikilink: bool,
pub hover: bool,
}

impl Settings {
Expand Down Expand Up @@ -61,6 +62,7 @@ impl Settings {
.set_default("references_in_codeblocks", true)?
.set_default("include_md_extension_md_link", false)?
.set_default("include_md_extension_wikilink", false)?
.set_default("hover", true)?
.set_override_option(
"semantic_tokens",
capabilities.text_document.as_ref().and_then(|it| {
Expand Down
12 changes: 11 additions & 1 deletion src/hover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@ use std::path::Path;
use tower_lsp::lsp_types::{Hover, HoverContents, HoverParams};

use crate::{
config::Settings,
ui::{preview_reference, preview_referenceable},
vault::Vault,
};

pub fn hover(vault: &Vault, params: &HoverParams, path: &Path) -> Option<Hover> {
pub fn hover(
vault: &Vault,
params: &HoverParams,
path: &Path,
settings: &Settings,
) -> Option<Hover> {
if settings.hover == false {
return None;
}

let cursor_position = params.text_document_position_params.position;

match (
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,9 +602,10 @@ impl LanguageServer for Backend {
}

async fn hover(&self, params: HoverParams) -> Result<Option<Hover>> {
let settings = self.bind_settings(|settings| Ok(settings.clone())).await?;
self.bind_vault(|vault| {
let path = params_path!(params.text_document_position_params)?;
Ok(hover::hover(vault, &params, &path))
Ok(hover::hover(vault, &params, &path, &settings))
})
.await
}
Expand Down

0 comments on commit b2b171b

Please sign in to comment.