Use COSMIC syntax theme by default, derived from OneHalf
This commit is contained in:
parent
542df32172
commit
d289670def
4 changed files with 98 additions and 4 deletions
76
Cargo.lock
generated
76
Cargo.lock
generated
|
|
@ -1016,6 +1016,7 @@ dependencies = [
|
|||
name = "cosmic-edit"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cosmic-syntax-theme",
|
||||
"cosmic-text",
|
||||
"env_logger",
|
||||
"fork",
|
||||
|
|
@ -1037,6 +1038,16 @@ dependencies = [
|
|||
"two-face",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cosmic-syntax-theme"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/cosmic-syntax-theme#ba0370a56a189e43acb20c38bb450ca8e3099c7d"
|
||||
dependencies = [
|
||||
"handlebars",
|
||||
"serde",
|
||||
"toml 0.8.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cosmic-text"
|
||||
version = "0.10.0"
|
||||
|
|
@ -2428,6 +2439,20 @@ dependencies = [
|
|||
"crunchy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "handlebars"
|
||||
version = "4.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "faa67bab9ff362228eb3d00bd024a4965d8231bbb7921167f0cfa66c6626b225"
|
||||
dependencies = [
|
||||
"log",
|
||||
"pest",
|
||||
"pest_derive",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.12.3"
|
||||
|
|
@ -4132,6 +4157,51 @@ version = "2.3.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
|
||||
|
||||
[[package]]
|
||||
name = "pest"
|
||||
version = "2.7.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"thiserror",
|
||||
"ucd-trie",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest_derive"
|
||||
version = "2.7.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "81d78524685f5ef2a3b3bd1cafbc9fcabb036253d9b1463e726a91cd16e2dfc2"
|
||||
dependencies = [
|
||||
"pest",
|
||||
"pest_generator",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest_generator"
|
||||
version = "2.7.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68bd1206e71118b5356dae5ddc61c8b11e28b09ef6a31acbd15ea48a28e0c227"
|
||||
dependencies = [
|
||||
"pest",
|
||||
"pest_meta",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.41",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest_meta"
|
||||
version = "2.7.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7c747191d4ad9e4a4ab9c8798f1e82a39affe7ef9648390b7e5548d18e099de6"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"pest",
|
||||
"sha2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf"
|
||||
version = "0.11.2"
|
||||
|
|
@ -5578,6 +5648,12 @@ version = "1.17.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
|
||||
|
||||
[[package]]
|
||||
name = "ucd-trie"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9"
|
||||
|
||||
[[package]]
|
||||
name = "uds_windows"
|
||||
version = "1.1.0"
|
||||
|
|
|
|||
|
|
@ -25,6 +25,9 @@ i18n-embed = { version = "0.13.4", features = ["fluent-system", "desktop-request
|
|||
i18n-embed-fl = "0.6.4"
|
||||
rust-embed = "6.3.0"
|
||||
|
||||
[dependencies.cosmic-syntax-theme]
|
||||
git = "https://github.com/pop-os/cosmic-syntax-theme"
|
||||
|
||||
[dependencies.cosmic-text]
|
||||
git = "https://github.com/pop-os/cosmic-text"
|
||||
branch = "refactor"
|
||||
|
|
|
|||
|
|
@ -170,8 +170,8 @@ impl Default for Config {
|
|||
font_name: "Fira Mono".to_string(),
|
||||
font_size: 14,
|
||||
line_numbers: true,
|
||||
syntax_theme_dark: "gruvbox-dark".to_string(),
|
||||
syntax_theme_light: "gruvbox-light".to_string(),
|
||||
syntax_theme_dark: "COSMIC Dark".to_string(),
|
||||
syntax_theme_light: "COSMIC Light".to_string(),
|
||||
tab_width: 4,
|
||||
vim_bindings: false,
|
||||
word_wrap: false,
|
||||
|
|
|
|||
19
src/main.rs
19
src/main.rs
|
|
@ -19,7 +19,7 @@ use cosmic::{
|
|||
use cosmic_text::{Cursor, Edit, Family, FontSystem, Selection, SwashCache, SyntaxSystem, ViMode};
|
||||
use std::{
|
||||
any::TypeId,
|
||||
env, fs,
|
||||
env, fs, io,
|
||||
path::{Path, PathBuf},
|
||||
process,
|
||||
sync::Mutex,
|
||||
|
|
@ -66,10 +66,25 @@ lazy_static::lazy_static! {
|
|||
static ref SWASH_CACHE: Mutex<SwashCache> = Mutex::new(SwashCache::new());
|
||||
static ref SYNTAX_SYSTEM: SyntaxSystem = {
|
||||
let lazy_theme_set = two_face::theme::LazyThemeSet::from(two_face::theme::extra());
|
||||
let mut theme_set = syntect::highlighting::ThemeSet::from(&lazy_theme_set);
|
||||
for (theme_name, theme_data) in &[
|
||||
("COSMIC Dark", cosmic_syntax_theme::COSMIC_DARK_TM_THEME),
|
||||
("COSMIC Light", cosmic_syntax_theme::COSMIC_LIGHT_TM_THEME)
|
||||
] {
|
||||
let mut cursor = io::Cursor::new(theme_data);
|
||||
match syntect::highlighting::ThemeSet::load_from_reader(&mut cursor) {
|
||||
Ok(theme) => {
|
||||
theme_set.themes.insert(theme_name.to_string(), theme);
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("failed to load {:?} syntax theme: {}", theme_name, err);
|
||||
}
|
||||
}
|
||||
}
|
||||
SyntaxSystem {
|
||||
//TODO: store newlines in buffer
|
||||
syntax_set: two_face::syntax::extra_no_newlines(),
|
||||
theme_set: syntect::highlighting::ThemeSet::from(&lazy_theme_set),
|
||||
theme_set,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue