Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Feel-ix-343 committed Apr 3, 2024
1 parent cca1254 commit 0a658a4
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 20 deletions.
9 changes: 4 additions & 5 deletions src/completion/callout_completer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::iter;

use once_cell::sync::Lazy;
use regex::Regex;
Expand Down Expand Up @@ -31,7 +30,7 @@ impl<'a> Completer<'a> for CalloutCompleter {

let (full, preceding) = (captures.get(0)?, captures.name("preceding")?);

Check warning on line 31 in src/completion/callout_completer.rs

View workflow job for this annotation

GitHub Actions / Build and Upload (linux, ubuntu-latest, aarch64-unknown-linux-gnu, true)

unused variable: `full`

Check warning on line 31 in src/completion/callout_completer.rs

View workflow job for this annotation

GitHub Actions / Build and Upload (linux, ubuntu-latest, x86_64-unknown-linux-gnu, true)

unused variable: `full`

Check warning on line 31 in src/completion/callout_completer.rs

View workflow job for this annotation

GitHub Actions / Build and Upload (windows-gnu, windows-latest, x86_64-pc-windows-gnu, false)

unused variable: `full`

Check warning on line 31 in src/completion/callout_completer.rs

View workflow job for this annotation

GitHub Actions / Build and Upload (macos, macos-latest, aarch64-apple-darwin, true)

unused variable: `full`

Check warning on line 31 in src/completion/callout_completer.rs

View workflow job for this annotation

GitHub Actions / Build and Upload (macos, macos-latest, x86_64-apple-darwin, true)

unused variable: `full`

let nested_level = preceding.as_str().matches(">").into_iter().count();
let nested_level = preceding.as_str().matches('>').count();

return Some(Self {
nested_level,
Expand All @@ -45,7 +44,7 @@ impl<'a> Completer<'a> for CalloutCompleter {
where
Self: Sized,
{
return vec![
vec![
CalloutCompletion::Note,
CalloutCompletion::Abstract,
CalloutCompletion::Summary,
Expand Down Expand Up @@ -73,7 +72,7 @@ impl<'a> Completer<'a> for CalloutCompleter {
CalloutCompletion::Example,
CalloutCompletion::Quote,
CalloutCompletion::Cite,
];
]
}

// TODO: get rid of this in the API
Expand Down Expand Up @@ -189,6 +188,6 @@ impl Completable<'_, CalloutCompleter> for CalloutCompletion {
..Default::default()
};

return Some(completion_item);
Some(completion_item)
}
}
19 changes: 9 additions & 10 deletions src/completion/link_completer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ pub trait LinkCompleter<'a>: Completer<'a> {
.into_par_iter()
.filter(|referenceable| Some(referenceable) != single_unresolved_under_cursor.as_ref())
.filter(|referenceable| {
(heading_completions
heading_completions
|| !matches!(
referenceable,
Referenceable::Heading(..) | Referenceable::UnresolvedHeading(..)
))
)
})
.flat_map(|referenceable| {
LinkCompletion::new(referenceable.clone(), self)
Expand Down Expand Up @@ -351,8 +351,8 @@ impl<'a> LinkCompleter<'a> for WikiLinkCompleter<'a> {
character: self.index + 1_u32, // index is right at the '[' in [[link]]; we want one more than that
},
end: Position {
line: self.line as u32,
character: (self.chars_in_line - 1).min(self.character + 2 as u32),
line: self.line,
character: (self.chars_in_line - 1).min(self.character + 2_u32),
},
},
new_text: format!(
Expand Down Expand Up @@ -439,12 +439,12 @@ impl<'a> Completer<'a> for WikiLinkCompleter<'a> {
.select_referenceable_nodes(Some(path))
.into_iter()
.filter(|referenceable| {
(self.settings().heading_completions
self.settings().heading_completions
|| !matches!(
referenceable,
Referenceable::Heading(..)
| Referenceable::UnresolvedHeading(..)
))
)
})
.collect::<Vec<_>>();

Expand All @@ -458,7 +458,7 @@ impl<'a> Completer<'a> for WikiLinkCompleter<'a> {
referenceables
.into_iter()
.flat_map(move |referenceable| {
Some(LinkCompletion::new(referenceable, self)?)
LinkCompletion::new(referenceable, self)
})
.flatten()
.flat_map(move |completion| {
Expand Down Expand Up @@ -542,8 +542,7 @@ impl LinkCompletion<'_> {
mdfile
.metadata
.iter()
.map(|it| it.aliases())
.flatten()
.flat_map(|it| it.aliases())
.flat_map(|alias| {
Some(Alias {
filename: mdfile.file_name()?,
Expand Down Expand Up @@ -656,7 +655,7 @@ impl LinkCompletion<'_> {
Self::DailyNote(daily) => {
daily.relative_name(completer) == Some(completer.entered_refname())
}
link_completion @ _ => link_completion.refname() == completer.entered_refname(),
link_completion => link_completion.refname() == completer.entered_refname(),
}),
filter_text: Some(filter_text.to_string()),
documentation: preview_referenceable(vault, &referenceable)
Expand Down
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::collections::btree_set::Intersection;
use std::collections::HashSet;
use std::ops::{Deref, DerefMut};
use std::path::{Path, PathBuf};
Expand Down
2 changes: 1 addition & 1 deletion src/tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use tower_lsp::lsp_types::{SemanticToken, SemanticTokensParams, SemanticTokensRe
use crate::{
config::Settings,
diagnostics::path_unresolved_references,
vault::{Referenceable, Vault},
vault::{Vault},
};

pub fn semantic_tokens_full(
Expand Down
4 changes: 2 additions & 2 deletions src/vault/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use once_cell::sync::Lazy;
use regex::Regex;
use serde::{Deserialize, Serialize};
use serde::{Deserialize};

#[derive(Deserialize, Debug, Clone, Hash, PartialEq, Eq)]
pub struct MDMetadata {
Expand All @@ -24,7 +24,7 @@ impl MDMetadata {

println!("md_metadata: {:?}", md_metadata);

return md_metadata.ok();
md_metadata.ok()
}

pub fn aliases(&self) -> &[String] {
Expand Down
2 changes: 1 addition & 1 deletion src/vault/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ impl MDFile {
}

pub fn file_name(&self) -> Option<&str> {
Some(self.path.file_stem()?.to_str()?)
self.path.file_stem()?.to_str()
}
}

Expand Down

0 comments on commit 0a658a4

Please sign in to comment.