Skip to content

Commit

Permalink
Merge pull request #511 from dtolnay-contrib/derive
Browse files Browse the repository at this point in the history
Eliminate syntect library's dependency on serde's "derive" feature
  • Loading branch information
Enselic authored Dec 28, 2023
2 parents 77b548b + 5dc2a0d commit fbabe18
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ jobs:
- name: Run cargo check
run: |
cargo check --all-features --all-targets
# Check that if some other crate in the downstream dependency tree
# enables serde's "derive" feature, syntect still builds.
cargo check --all-features --features serde/derive
documentation:
name: Documentation checks
Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ plist = { version = "1.3", optional = true }
bincode = { version = "1.0", optional = true }
flate2 = { version = "1.0", optional = true }
fnv = { version = "1.0", optional = true }
serde = { version = "1.0", features = ["derive"] }
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
once_cell = "1.8"
thiserror = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion src/dumps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use flate2::bufread::ZlibDecoder;
#[cfg(feature = "dump-create")]
use flate2::Compression;
#[cfg(feature = "dump-create")]
use serde::Serialize;
use serde::ser::Serialize;
#[cfg(feature = "dump-load")]
use serde::de::DeserializeOwned;

Expand Down
2 changes: 1 addition & 1 deletion src/highlighting/selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/// released under the MIT license by @defuz
use crate::parsing::{Scope, ScopeStack, MatchPower, ParseScopeError};
use std::str::FromStr;
use serde::{Deserialize, Serialize};
use serde_derive::{Deserialize, Serialize};

/// A single selector consisting of a stack to match and a possible stack to
/// exclude from being matched.
Expand Down
2 changes: 1 addition & 1 deletion src/highlighting/style.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Code based on [https://github.com/defuz/sublimate/blob/master/src/core/syntax/scope.rs](https://github.com/defuz/sublimate/blob/master/src/core/syntax/scope.rs)
// released under the MIT license by @defuz
use bitflags::bitflags;
use serde::{Deserialize, Serialize};
use serde_derive::{Deserialize, Serialize};

/// Foreground and background colors, with font style
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/highlighting/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// released under the MIT license by @defuz
use super::style::*;
use super::selector::*;
use serde::{Deserialize, Serialize};
use serde_derive::{Deserialize, Serialize};

/// A theme parsed from a `.tmTheme` file.
///
Expand Down
2 changes: 1 addition & 1 deletion src/highlighting/theme_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::super::LoadingError;
#[cfg(feature = "plist-load")]
use super::settings::*;
use super::theme::Theme;
use serde::{Deserialize, Serialize};
use serde_derive::{Deserialize, Serialize};
use std::collections::BTreeMap;
use std::path::{Path, PathBuf};

Expand Down
5 changes: 3 additions & 2 deletions src/parsing/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ use std::fs::File;
use std::io::BufReader;
use std::str::FromStr;

use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde_json;
use serde::de::{Deserialize, Deserializer};
use serde::ser::{Serialize, Serializer};
use serde_derive::{Deserialize, Serialize};

use super::regex::Regex;
use super::scope::{MatchPower, Scope};
Expand Down
3 changes: 2 additions & 1 deletion src/parsing/regex.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use once_cell::sync::OnceCell;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde::de::{Deserialize, Deserializer};
use serde::ser::{Serialize, Serializer};
use std::error::Error;

/// An abstraction for regex patterns.
Expand Down
5 changes: 3 additions & 2 deletions src/parsing/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ use std::cmp::{Ordering, min};
use std::mem;

use once_cell::sync::Lazy;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde::de::{Error, Visitor};
use serde::de::{Deserialize, Deserializer, Error, Visitor};
use serde::ser::{Serialize, Serializer};
use serde_derive::{Deserialize, Serialize};

/// Scope related errors
#[derive(Debug, thiserror::Error)]
Expand Down
3 changes: 2 additions & 1 deletion src/parsing/syntax_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ use std::hash::Hash;
use super::{scope::*, ParsingError};
use super::regex::{Regex, Region};
use regex_syntax::escape;
use serde::{Deserialize, Serialize, Serializer};
use serde::ser::{Serialize, Serializer};
use serde_derive::{Deserialize, Serialize};
use crate::parsing::syntax_set::SyntaxSet;

pub type CaptureMapping = Vec<(usize, Vec<Scope>)>;
Expand Down
2 changes: 1 addition & 1 deletion src/parsing/syntax_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::mem;
use super::regex::Regex;
use crate::parsing::syntax_definition::ContextId;
use once_cell::sync::OnceCell;
use serde::{Deserialize, Serialize};
use serde_derive::{Deserialize, Serialize};

/// A syntax set holds multiple syntaxes that have been linked together.
///
Expand Down

0 comments on commit fbabe18

Please sign in to comment.