Skip to content

Commit

Permalink
Use COSMIC syntax theme by default, derived from OneHalf
Browse files Browse the repository at this point in the history
  • Loading branch information
jackpot51 committed Dec 22, 2023
1 parent 542df32 commit d289670
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 4 deletions.
76 changes: 76 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
19 changes: 17 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
}
};
}
Expand Down

0 comments on commit d289670

Please sign in to comment.