@@ -1,6 +1,8 @@
1use crate::{regex::Regex, Change, Rope, RopeSlice, Transaction};
1use crate::{regex::Regex, Change, Rope, RopeSlice, Transaction};
2pub use helix_syntax::{get_language, get_language_name, Lang};
2pub use helix_syntax::{get_language, get_language_name, Lang};
4+#[cfg(feature = "debug")]
5 borrow::Cow,
7 borrow::Cow,
6 cell::RefCell,
8 cell::RefCell,
@@ -12,12 +14,14 @@ use std::{
12use once_cell::sync::{Lazy, OnceCell};
14use once_cell::sync::{Lazy, OnceCell};
13use serde::{Deserialize, Serialize};
15use serde::{Deserialize, Serialize};
17+#[cfg_attr(feature = "debug", derive(Debug))]
15#[derive(Serialize, Deserialize)]
18#[derive(Serialize, Deserialize)]
16pub struct Configuration {
19pub struct Configuration {
17 pub language: Vec<LanguageConfiguration>,
20 pub language: Vec<LanguageConfiguration>,
20// largely based on tree-sitter/cli/src/loader.rs
23// largely based on tree-sitter/cli/src/loader.rs
24+#[cfg_attr(feature = "debug", derive(Debug))]
21#[derive(Serialize, Deserialize)]
25#[derive(Serialize, Deserialize)]
22#[serde(rename_all = "kebab-case")]
26#[serde(rename_all = "kebab-case")]
23pub struct LanguageConfiguration {
27pub struct LanguageConfiguration {
@@ -46,6 +50,7 @@ pub struct LanguageConfiguration {
46 pub(crate) indent_query: OnceCell<Option<IndentQuery>>,
50 pub(crate) indent_query: OnceCell<Option<IndentQuery>>,
53+#[cfg_attr(feature = "debug", derive(Debug))]
49#[derive(Serialize, Deserialize)]
54#[derive(Serialize, Deserialize)]
50#[serde(rename_all = "kebab-case")]
55#[serde(rename_all = "kebab-case")]
51pub struct LanguageServerConfiguration {
56pub struct LanguageServerConfiguration {
@@ -55,6 +60,7 @@ pub struct LanguageServerConfiguration {
55 pub args: Vec<String>,
60 pub args: Vec<String>,
63+#[cfg_attr(feature = "debug", derive(Debug))]
58#[derive(Serialize, Deserialize)]
64#[derive(Serialize, Deserialize)]
59#[serde(rename_all = "kebab-case")]
65#[serde(rename_all = "kebab-case")]
60pub struct IndentationConfiguration {
66pub struct IndentationConfiguration {
@@ -62,6 +68,7 @@ pub struct IndentationConfiguration {
62 pub unit: String,
68 pub unit: String,
71+#[cfg_attr(feature = "debug", derive(Debug))]
65#[derive(Serialize, Deserialize)]
72#[derive(Serialize, Deserialize)]
66#[serde(rename_all = "kebab-case")]
73#[serde(rename_all = "kebab-case")]
67pub struct IndentQuery {
74pub struct IndentQuery {
@@ -189,6 +196,7 @@ impl LanguageConfiguration {
190pub static LOADER: OnceCell<Loader> = OnceCell::new();
197pub static LOADER: OnceCell<Loader> = OnceCell::new();
199+#[cfg_attr(feature = "debug", derive(Debug))]
192pub struct Loader {
200pub struct Loader {
193 // highlight_names ?
201 // highlight_names ?
194 language_configs: Vec<Arc<LanguageConfiguration>>,
202 language_configs: Vec<Arc<LanguageConfiguration>>,
@@ -256,6 +264,13 @@ pub struct TsParser {
256 cursors: Vec<QueryCursor>,
264 cursors: Vec<QueryCursor>,
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()
259// could also just use a pool, or a single instance?
274// could also just use a pool, or a single instance?
260thread_local! {
275thread_local! {
261 pub static PARSER: RefCell<TsParser> = RefCell::new(TsParser {
276 pub static PARSER: RefCell<TsParser> = RefCell::new(TsParser {
@@ -264,6 +279,7 @@ thread_local! {
282+#[cfg_attr(feature = "debug", derive(Debug))]
267pub struct Syntax {
283pub struct Syntax {
268 config: Arc<HighlightConfiguration>,
284 config: Arc<HighlightConfiguration>,
@@ -444,6 +460,7 @@ impl Syntax {
444 // buffer_range_for_scope_at_pos
460 // buffer_range_for_scope_at_pos
463+#[cfg_attr(feature = "debug", derive(Debug))]
447pub struct LanguageLayer {
464pub struct LanguageLayer {
449 // grammar
466 // grammar
@@ -752,6 +769,7 @@ pub enum HighlightEvent {
752/// Contains the data neeeded to higlight code written in a particular language.
769/// Contains the data neeeded to higlight code written in a particular language.
754/// This struct is immutable and can be shared between threads.
771/// This struct is immutable and can be shared between threads.
772+#[cfg_attr(feature = "debug", derive(Debug))]
755pub struct HighlightConfiguration {
773pub struct HighlightConfiguration {
756 pub language: Grammar,
774 pub language: Grammar,
757 pub query: Query,
775 pub query: Query,
@@ -782,6 +800,7 @@ struct LocalScope<'a> {
782 local_defs: Vec<LocalDef<'a>>,
800 local_defs: Vec<LocalDef<'a>>,
803+#[cfg_attr(feature = "debug", derive(Debug))]
785struct HighlightIter<'a, 'tree: 'a, F>
804struct HighlightIter<'a, 'tree: 'a, F>
787 F: FnMut(&str) -> Option<&'a HighlightConfiguration> + 'a,
806 F: FnMut(&str) -> Option<&'a HighlightConfiguration> + 'a,
@@ -807,6 +826,13 @@ struct HighlightIterLayer<'a, 'tree: 'a> {
807 depth: usize,
826 depth: usize,
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()
810impl HighlightConfiguration {
836impl HighlightConfiguration {
811 /// Creates a `HighlightConfiguration` for a given `Grammar` and set of highlighting
837 /// Creates a `HighlightConfiguration` for a given `Grammar` and set of highlighting
812 /// queries.
838 /// queries.