From 98329311ad068a9e0e3c8d7c78b95e794671ac5e Mon Sep 17 00:00:00 2001 From: pml68 Date: Tue, 7 Jan 2025 00:26:21 +0100 Subject: chore: remove once_cell dep, disable default features for syntect --- Cargo.toml | 26 ++++++++++++++++++++++++-- src/lib.rs | 26 ++++++++++++-------------- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ff99632..90adfe1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,9 +12,31 @@ rust-version = "1.80" [dependencies] iced_widget = "0.13.4" -once_cell = "1.0" -syntect = "5.1" +syntect = { version = "5.1", default-features = false, features = ["default-syntaxes", "regex-onig"] } [package.metadata.docs.rs] rustdoc-args = ["--cfg", "docsrs"] all-features = true + +[lints.rust] +missing_debug_implementations = "deny" +unsafe_code = "deny" +unused_results = "deny" + +[lints.clippy] +type-complexity = "allow" +semicolon_if_nothing_returned = "deny" +trivially-copy-pass-by-ref = "deny" +default_trait_access = "deny" +match-wildcard-for-single-variants = "deny" +redundant-closure-for-method-calls = "deny" +filter_map_next = "deny" +manual_let_else = "deny" +unused_async = "deny" +from_over_into = "deny" +needless_borrow = "deny" +new_without_default = "deny" +useless_conversion = "deny" + +[lints.rustdoc] +broken_intra_doc_links = "forbid" diff --git a/src/lib.rs b/src/lib.rs index 960cdfa..d6b28b9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,15 +6,15 @@ use iced_widget::core::text::highlighter::{self, Format}; use iced_widget::text_editor::Catalog; use iced_widget::Theme; -use once_cell::sync::Lazy; use std::collections::HashSet; use std::ops::Range; use std::str::FromStr; +use std::sync::LazyLock; use syntect::highlighting; use syntect::parsing; -static SYNTAXES: Lazy = - Lazy::new(parsing::SyntaxSet::load_defaults_nonewlines); +static SYNTAXES: LazyLock = + LazyLock::new(parsing::SyntaxSet::load_defaults_nonewlines); const LINES_PER_SNAPSHOT: usize = 50; @@ -50,7 +50,7 @@ impl highlighter::Highlighter .find_syntax_by_token(&settings.token) .unwrap_or_else(|| SYNTAXES.find_syntax_plain_text()); - let style = settings.style.clone(); + let style = settings.style; let custom_scopes = settings.custom_scopes.clone(); let parser = parsing::ParseState::new(syntax); @@ -72,7 +72,7 @@ impl highlighter::Highlighter self.custom_scopes = new_settings.custom_scopes.clone(); - self.style = new_settings.style.clone(); + self.style = new_settings.style; // Restart the highlighter self.change_line(0); @@ -138,7 +138,7 @@ impl highlighter::Highlighter stack.clone(), custom_scopes.clone(), ), - style: style.clone(), + style: *style, }, )) } @@ -403,7 +403,7 @@ impl Scope { Self::Parantheses => "meta.brace.round, punctuation.definition.parameters.begin, punctuation.definition.parameters.end", Self::Braces => "meta.brace.curly", Self::Other => "", - Self::Custom {scope_string,..} => &scope_string + Self::Custom {scope_string,..} => scope_string } } @@ -411,16 +411,14 @@ impl Scope { stack: parsing::ScopeStack, custom_scopes: Vec, ) -> Self { - let scopes: Vec; - - if custom_scopes.len() > 0 { + let scopes = if !custom_scopes.is_empty() { let mut hashset: HashSet = - (*Self::ALL).to_vec().into_iter().collect(); + (*Self::ALL).iter().cloned().collect(); hashset.extend(custom_scopes); - scopes = hashset.into_iter().collect(); + hashset.into_iter().collect() } else { - scopes = Self::ALL.to_vec(); - } + Self::ALL.to_vec() + }; let selectors: Vec<(Self, highlighting::ScopeSelectors)> = scopes .iter() -- cgit v1.2.3