@@ -1,6 +1,8 @@
11use crate::{regex::Regex, Change, Rope, RopeSlice, Transaction};
22pub use helix_syntax::{get_language, get_language_name, Lang};
33
4+#[cfg(feature = "debug")]
5+use std::fmt;
46use std::{
57 borrow::Cow,
68 cell::RefCell,
@@ -12,12 +14,14 @@ use std::{
1214use once_cell::sync::{Lazy, OnceCell};
1315use serde::{Deserialize, Serialize};
1416
17+#[cfg_attr(feature = "debug", derive(Debug))]
1518#[derive(Serialize, Deserialize)]
1619pub struct Configuration {
1720 pub language: Vec<LanguageConfiguration>,
1821}
1922
2023// largely based on tree-sitter/cli/src/loader.rs
24+#[cfg_attr(feature = "debug", derive(Debug))]
2125#[derive(Serialize, Deserialize)]
2226#[serde(rename_all = "kebab-case")]
2327pub struct LanguageConfiguration {
@@ -46,6 +50,7 @@ pub struct LanguageConfiguration {
4650 pub(crate) indent_query: OnceCell<Option<IndentQuery>>,
4751}
4852
53+#[cfg_attr(feature = "debug", derive(Debug))]
4954#[derive(Serialize, Deserialize)]
5055#[serde(rename_all = "kebab-case")]
5156pub struct LanguageServerConfiguration {
@@ -55,6 +60,7 @@ pub struct LanguageServerConfiguration {
5560 pub args: Vec<String>,
5661}
5762
63+#[cfg_attr(feature = "debug", derive(Debug))]
5864#[derive(Serialize, Deserialize)]
5965#[serde(rename_all = "kebab-case")]
6066pub struct IndentationConfiguration {
@@ -62,6 +68,7 @@ pub struct IndentationConfiguration {
6268 pub unit: String,
6369}
6470
71+#[cfg_attr(feature = "debug", derive(Debug))]
6572#[derive(Serialize, Deserialize)]
6673#[serde(rename_all = "kebab-case")]
6774pub struct IndentQuery {
@@ -189,6 +196,7 @@ impl LanguageConfiguration {
189196
190197pub static LOADER: OnceCell<Loader> = OnceCell::new();
191198
199+#[cfg_attr(feature = "debug", derive(Debug))]
192200pub struct Loader {
193201 // highlight_names ?
194202 language_configs: Vec<Arc<LanguageConfiguration>>,
@@ -256,6 +264,13 @@ pub struct TsParser {
256264 cursors: Vec<QueryCursor>,
257265}
258266
267+#[cfg(feature = "debug")]
268+impl fmt::Debug for TsParser {
269+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
270+ f.debug_struct("TsParser").finish_non_exhaustive()
271+ }
272+}
273+
259274// could also just use a pool, or a single instance?
260275thread_local! {
261276 pub static PARSER: RefCell<TsParser> = RefCell::new(TsParser {
@@ -264,6 +279,7 @@ thread_local! {
264279 })
265280}
266281
282+#[cfg_attr(feature = "debug", derive(Debug))]
267283pub struct Syntax {
268284 config: Arc<HighlightConfiguration>,
269285
@@ -444,6 +460,7 @@ impl Syntax {
444460 // buffer_range_for_scope_at_pos
445461}
446462
463+#[cfg_attr(feature = "debug", derive(Debug))]
447464pub struct LanguageLayer {
448465 // mode
449466 // grammar
@@ -752,6 +769,7 @@ pub enum HighlightEvent {
752769/// Contains the data neeeded to higlight code written in a particular language.
753770///
754771/// This struct is immutable and can be shared between threads.
772+#[cfg_attr(feature = "debug", derive(Debug))]
755773pub struct HighlightConfiguration {
756774 pub language: Grammar,
757775 pub query: Query,
@@ -782,6 +800,7 @@ struct LocalScope<'a> {
782800 local_defs: Vec<LocalDef<'a>>,
783801}
784802
803+#[cfg_attr(feature = "debug", derive(Debug))]
785804struct HighlightIter<'a, 'tree: 'a, F>
786805where
787806 F: FnMut(&str) -> Option<&'a HighlightConfiguration> + 'a,
@@ -807,6 +826,13 @@ struct HighlightIterLayer<'a, 'tree: 'a> {
807826 depth: usize,
808827}
809828
829+#[cfg(feature = "debug")]
830+impl<'a, 'tree: 'a> fmt::Debug for HighlightIterLayer<'a, 'tree> {
831+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
832+ f.debug_struct("HighlightIterLayer").finish_non_exhaustive()
833+ }
834+}
835+
810836impl HighlightConfiguration {
811837 /// Creates a `HighlightConfiguration` for a given `Grammar` and set of highlighting
812838 /// queries.