Skip to content

Commit

Permalink
resolve: #115
Browse files Browse the repository at this point in the history
  • Loading branch information
Feel-ix-343 committed Jul 2, 2024
1 parent e2ec551 commit 22a4e2e
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![feature(async_closure)]

use std::collections::HashSet;
use std::ops::{Deref, DerefMut};
use std::path::PathBuf;
Expand Down Expand Up @@ -373,7 +375,27 @@ impl LanguageServer for Backend {
resolve_provider: None,
}),
execute_command_provider: Some(ExecuteCommandOptions {
commands: vec!["apply_edits".into(), "jump".into()],
commands: vec![
"apply_edits".into(),
"jump".into(),
"tomorrow".into(),
"today".into(),
"yesterday".into(),
"last friday".into(),
"last saturday".into(),
"last sunday".into(),
"last monday".into(),
"last tuesday".into(),
"last wednesday".into(),
"last thursday".into(),
"next friday".into(),
"next saturday".into(),
"next sunday".into(),
"next monday".into(),
"next tuesday".into(),
"next wednesday".into(),
"next thursday".into(),
],
..Default::default()
}),
semantic_tokens_provider: Some(
Expand Down Expand Up @@ -573,6 +595,15 @@ impl LanguageServer for Backend {
}

async fn execute_command(&self, params: ExecuteCommandParams) -> Result<Option<Value>> {
let jump_to_specific = async |day| {
let settings = self
.bind_settings(|settings| Ok(settings.to_owned()))
.await?;
let root_dir = self
.bind_vault(|vault| Ok(vault.root_dir().to_owned()))
.await?;
commands::jump(&self.client, &root_dir, &settings, Some(day)).await
};
match params {
ExecuteCommandParams { command, .. } if *command == *"apply_edits" => {
let edits = params
Expand All @@ -597,7 +628,8 @@ impl LanguageServer for Backend {
.await?;
commands::jump(&self.client, &root_dir, &settings, jump_to).await
}
_ => Ok(None),
ExecuteCommandParams { command, .. } => jump_to_specific(&command).await,
// _ => Ok(None),
}
}

Expand Down

0 comments on commit 22a4e2e

Please sign in to comment.