Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate syntect library's dependency on serde's "derive" feature #511

Merged
merged 1 commit into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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