highlight: Remove stale fallback code
6c3731c1f7a256bb599bd1f7c008aff9d37ad78a
Drops unused fallback grammar and theme paths now that local assets are loaded explicitly.
1 parent
a2172f91
crates/diff/src/highlight.rs
+0 -15
| 9 | 9 | use rustik_tui as tui; |
|
| 10 | 10 | use rustik_tui::{Color, Label, Line, Style}; |
|
| 11 | 11 | ||
| 12 | 12 | use crate::{FileId, HunkId, RowId}; |
|
| 13 | 13 | ||
| 14 | - | /// Built-in fallback theme name. |
|
| 15 | - | const BUILTIN_THEME_NAME: &str = "rustik"; |
|
| 16 | - | /// Built-in syntax theme JSON. |
|
| 17 | - | const BUILTIN_THEME: &str = include_str!("rustik.json"); |
|
| 18 | - | ||
| 19 | 14 | /// Side of the diff used as syntax-highlighting source context. |
|
| 20 | 15 | #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] |
|
| 21 | 16 | pub enum DiffSide { |
|
| 22 | 17 | /// Old side of a deleted or context line. |
|
| 23 | 18 | Old, |
| 251 | 246 | }) |
|
| 252 | 247 | .collect() |
|
| 253 | 248 | } |
|
| 254 | 249 | } |
|
| 255 | 250 | ||
| 256 | - | impl Default for BuiltinHighlighter { |
|
| 257 | - | fn default() -> Self { |
|
| 258 | - | let mut registry = syntax::Registry::default(); |
|
| 259 | - | if let Ok(theme) = BUILTIN_THEME.parse::<syntax::Theme>() { |
|
| 260 | - | registry.add_theme(theme); |
|
| 261 | - | } |
|
| 262 | - | Self::new(registry, BUILTIN_THEME_NAME) |
|
| 263 | - | } |
|
| 264 | - | } |
|
| 265 | - | ||
| 266 | 251 | impl HighlightRequest { |
|
| 267 | 252 | /// Returns the unhighlighted source row for this request. |
|
| 268 | 253 | fn plain_line(&self) -> Line { |
|
| 269 | 254 | self.source |
|
| 270 | 255 | .line(self.key.source_line) |
crates/diff/src/rustik.json
deleted
+0 -28
| 1 | - | { |
|
| 2 | - | "name": "rustik", |
|
| 3 | - | "settings": [ |
|
| 4 | - | { |
|
| 5 | - | "settings": { |
|
| 6 | - | "foreground": "#c9d1d9" |
|
| 7 | - | } |
|
| 8 | - | }, |
|
| 9 | - | { |
|
| 10 | - | "scope": "string", |
|
| 11 | - | "settings": { |
|
| 12 | - | "foreground": "#a5d6ff" |
|
| 13 | - | } |
|
| 14 | - | }, |
|
| 15 | - | { |
|
| 16 | - | "scope": "constant", |
|
| 17 | - | "settings": { |
|
| 18 | - | "foreground": "#79c0ff" |
|
| 19 | - | } |
|
| 20 | - | }, |
|
| 21 | - | { |
|
| 22 | - | "scope": "punctuation", |
|
| 23 | - | "settings": { |
|
| 24 | - | "foreground": "#8b949e" |
|
| 25 | - | } |
|
| 26 | - | } |
|
| 27 | - | ] |
|
| 28 | - | } |
crates/highlight/src/registry.rs
+2 -2
| 1 | 1 | //! Grammar and theme registry. |
|
| 2 | 2 | //! |
|
| 3 | - | //! A registry is the lookup layer between user-facing names, file paths, first |
|
| 4 | - | //! head lines, and the compiled grammars/themes used by the highlighter. It keeps |
|
| 3 | + | //! A registry is the lookup layer between user-facing names, file paths, head |
|
| 4 | + | //! lines, and the compiled grammars/themes used by the highlighter. It keeps |
|
| 5 | 5 | //! inference policy out of tokenization so callers can load syntaxes once and |
|
| 6 | 6 | //! cheaply select the right one for each buffer. |
|
| 7 | 7 | ||
| 8 | 8 | use std::path::Path; |
|
| 9 | 9 |
crates/highlight/src/theme.rs
+1 -21
| 189 | 189 | return; |
|
| 190 | 190 | } |
|
| 191 | 191 | scratch.collect_boundaries(line, scopes); |
|
| 192 | 192 | ||
| 193 | 193 | for segment in scratch.segments() { |
|
| 194 | - | output.push(self.style_segment(grammar, scopes, segment)); |
|
| 194 | + | output.push(self.style_stack_segment(grammar, scopes, segment)); |
|
| 195 | 195 | } |
|
| 196 | 196 | } |
|
| 197 | 197 | ||
| 198 | - | /// Resolves a single styled segment from its covering scope spans. |
|
| 199 | - | fn style_segment( |
|
| 200 | - | &self, |
|
| 201 | - | grammar: &Grammar, |
|
| 202 | - | scopes: &[ScopeSpan], |
|
| 203 | - | segment: Segment, |
|
| 204 | - | ) -> StyleSpan { |
|
| 205 | - | self.style_stack_segment(grammar, scopes, segment) |
|
| 206 | - | } |
|
| 207 | - | ||
| 208 | 198 | /// Resolves one segment using TextMate-style scope stack matching. |
|
| 209 | 199 | fn style_stack_segment( |
|
| 210 | 200 | &self, |
|
| 211 | 201 | grammar: &Grammar, |
|
| 212 | 202 | scopes: &[ScopeSpan], |
| 499 | 489 | pub const NONE: Self = Self { |
|
| 500 | 490 | foreground: None, |
|
| 501 | 491 | font_style: FontStyle::empty(), |
|
| 502 | 492 | }; |
|
| 503 | 493 | ||
| 504 | - | /// Returns `self` overlaid on `base`. |
|
| 505 | - | pub fn merge(self, base: Self) -> Self { |
|
| 506 | - | let mut font_style = base.font_style; |
|
| 507 | - | font_style.insert(self.font_style); |
|
| 508 | - | Self { |
|
| 509 | - | foreground: self.foreground.or(base.foreground), |
|
| 510 | - | font_style, |
|
| 511 | - | } |
|
| 512 | - | } |
|
| 513 | - | ||
| 514 | 494 | /// Returns this style with a foreground color. |
|
| 515 | 495 | pub const fn fg(mut self, color: Rgb) -> Self { |
|
| 516 | 496 | self.foreground = Some(color); |
|
| 517 | 497 | self |
|
| 518 | 498 | } |