on master help sign in
Derive debug without feature
7cc13feIvan Tham
helix-core/Cargo.toml−1
@@ -10,7 +10,6 @@ license = "MPL-2.0"
10
10
11[features]
11[features]
12embed_runtime = ["rust-embed"]
12embed_runtime = ["rust-embed"]
13−debug = []
14
13
15[dependencies]
14[dependencies]
16helix-syntax = { path = "../helix-syntax" }
15helix-syntax = { path = "../helix-syntax" }
helix-core/src/diagnostic.rs+3−4
@@ -1,5 +1,4 @@
1−#[cfg_attr(feature = "debug", derive(Debug))]
2−#[derive(Eq, PartialEq)]
1+#[derive(Debug, Eq, PartialEq)]
3pub enum Severity {
2pub enum Severity {
4 Error,
3 Error,
5 Warning,
4 Warning,
@@ -7,13 +6,13 @@ pub enum Severity {
7 Hint,
6 Hint,
8}
7}
9
8
10−#[cfg_attr(feature = "debug", derive(Debug))]
9+#[derive(Debug)]
11pub struct Range {
10pub struct Range {
12 pub start: usize,
11 pub start: usize,
13 pub end: usize,
12 pub end: usize,
14}
13}
15
14
16−#[cfg_attr(feature = "debug", derive(Debug))]
15+#[derive(Debug)]
17pub struct Diagnostic {
16pub struct Diagnostic {
18 pub range: Range,
17 pub range: Range,
19 pub line: usize,
18 pub line: usize,
helix-core/src/graphemes.rs+1−2
@@ -147,8 +147,7 @@ pub fn is_grapheme_boundary(slice: RopeSlice, char_idx: usize) -> bool {
147}
147}
148
148
149/// An iterator over the graphemes of a `RopeSlice`.
149/// An iterator over the graphemes of a `RopeSlice`.
150−#[cfg_attr(feature = "debug", derive(Debug))]
150+#[derive(Debug, Clone)]
151−#[derive(Clone)]
152pub struct RopeGraphemes<'a> {
151pub struct RopeGraphemes<'a> {
153 text: RopeSlice<'a>,
152 text: RopeSlice<'a>,
154 chunks: Chunks<'a>,
153 chunks: Chunks<'a>,
helix-core/src/history.rs+1−1
@@ -2,7 +2,7 @@ use crate::{ChangeSet, Rope, State, Transaction};
2use smallvec::{smallvec, SmallVec};
2use smallvec::{smallvec, SmallVec};
3
3
4/// Undo-tree style history store.
4/// Undo-tree style history store.
5−#[cfg_attr(feature = "debug", derive(Debug))]
5+#[derive(Debug)]
6pub struct History {
6pub struct History {
7 revisions: Vec<Revision>,
7 revisions: Vec<Revision>,
8 cursor: usize,
8 cursor: usize,
helix-core/src/movement.rs+1−2
@@ -1,8 +1,7 @@
1use crate::graphemes::{nth_next_grapheme_boundary, nth_prev_grapheme_boundary, RopeGraphemes};
1use crate::graphemes::{nth_next_grapheme_boundary, nth_prev_grapheme_boundary, RopeGraphemes};
2use crate::{coords_at_pos, pos_at_coords, ChangeSet, Position, Range, Rope, RopeSlice, Selection};
2use crate::{coords_at_pos, pos_at_coords, ChangeSet, Position, Range, Rope, RopeSlice, Selection};
3
3
4−#[cfg_attr(feature = "debug", derive(Debug))]
5−#[derive(Copy, Clone, PartialEq, Eq)]
4+#[derive(Debug, Copy, Clone, PartialEq, Eq)]
6pub enum Direction {
5pub enum Direction {
7 Forward,
6 Forward,
8 Backward,
7 Backward,
helix-core/src/state.rs+1−2
@@ -1,8 +1,7 @@
1use crate::{Rope, Selection};
1use crate::{Rope, Selection};
2
2
3/// A state represents the current editor state of a single buffer.
3/// A state represents the current editor state of a single buffer.
4−#[cfg_attr(feature = "debug", derive(Debug))]
4+#[derive(Debug, Clone)]
5−#[derive(Clone)]
6pub struct State {
5pub struct State {
7 pub doc: Rope,
6 pub doc: Rope,
8 pub selection: Selection,
7 pub selection: Selection,
helix-core/src/syntax.rs+13−21
@@ -1,12 +1,11 @@
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};
3
3
4−#[cfg(feature = "debug")]
5−use std::fmt;
6use std::{
4use std::{
7 borrow::Cow,
5 borrow::Cow,
8 cell::RefCell,
6 cell::RefCell,
9 collections::{HashMap, HashSet},
7 collections::{HashMap, HashSet},
8+ fmt,
10 path::{Path, PathBuf},
9 path::{Path, PathBuf},
11 sync::Arc,
10 sync::Arc,
12};
11};
@@ -14,15 +13,13 @@ use std::{
14use once_cell::sync::{Lazy, OnceCell};
13use once_cell::sync::{Lazy, OnceCell};
15use serde::{Deserialize, Serialize};
14use serde::{Deserialize, Serialize};
16
15
17−#[cfg_attr(feature = "debug", derive(Debug))]
18−#[derive(Serialize, Deserialize)]
16+#[derive(Debug, Serialize, Deserialize)]
19pub struct Configuration {
17pub struct Configuration {
20 pub language: Vec<LanguageConfiguration>,
18 pub language: Vec<LanguageConfiguration>,
21}
19}
22
20
23// largely based on tree-sitter/cli/src/loader.rs
21// largely based on tree-sitter/cli/src/loader.rs
24−#[cfg_attr(feature = "debug", derive(Debug))]
25−#[derive(Serialize, Deserialize)]
22+#[derive(Debug, Serialize, Deserialize)]
26#[serde(rename_all = "kebab-case")]
23#[serde(rename_all = "kebab-case")]
27pub struct LanguageConfiguration {
24pub struct LanguageConfiguration {
28 #[serde(rename = "name")]
25 #[serde(rename = "name")]
@@ -50,8 +47,7 @@ pub struct LanguageConfiguration {
50 pub(crate) indent_query: OnceCell<Option<IndentQuery>>,
47 pub(crate) indent_query: OnceCell<Option<IndentQuery>>,
51}
48}
52
49
53−#[cfg_attr(feature = "debug", derive(Debug))]
54−#[derive(Serialize, Deserialize)]
50+#[derive(Debug, Serialize, Deserialize)]
55#[serde(rename_all = "kebab-case")]
51#[serde(rename_all = "kebab-case")]
56pub struct LanguageServerConfiguration {
52pub struct LanguageServerConfiguration {
57 pub command: String,
53 pub command: String,
@@ -60,16 +56,14 @@ pub struct LanguageServerConfiguration {
60 pub args: Vec<String>,
56 pub args: Vec<String>,
61}
57}
62
58
63−#[cfg_attr(feature = "debug", derive(Debug))]
64−#[derive(Serialize, Deserialize)]
59+#[derive(Debug, Serialize, Deserialize)]
65#[serde(rename_all = "kebab-case")]
60#[serde(rename_all = "kebab-case")]
66pub struct IndentationConfiguration {
61pub struct IndentationConfiguration {
67 pub tab_width: usize,
62 pub tab_width: usize,
68 pub unit: String,
63 pub unit: String,
69}
64}
70
65
71−#[cfg_attr(feature = "debug", derive(Debug))]
72−#[derive(Serialize, Deserialize)]
66+#[derive(Debug, Serialize, Deserialize)]
73#[serde(rename_all = "kebab-case")]
67#[serde(rename_all = "kebab-case")]
74pub struct IndentQuery {
68pub struct IndentQuery {
75 #[serde(default)]
69 #[serde(default)]
@@ -196,7 +190,7 @@ impl LanguageConfiguration {
196
190
197pub static LOADER: OnceCell<Loader> = OnceCell::new();
191pub static LOADER: OnceCell<Loader> = OnceCell::new();
198
192
199−#[cfg_attr(feature = "debug", derive(Debug))]
193+#[derive(Debug)]
200pub struct Loader {
194pub struct Loader {
201 // highlight_names ?
195 // highlight_names ?
202 language_configs: Vec<Arc<LanguageConfiguration>>,
196 language_configs: Vec<Arc<LanguageConfiguration>>,
@@ -264,10 +258,9 @@ pub struct TsParser {
264 cursors: Vec<QueryCursor>,
258 cursors: Vec<QueryCursor>,
265}
259}
266
260
267−#[cfg(feature = "debug")]
268impl fmt::Debug for TsParser {
261impl fmt::Debug for TsParser {
269 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
262 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
270− f.debug_struct("TsParser").finish_non_exhaustive()
263+ f.debug_struct("TsParser").finish()
271 }
264 }
272}
265}
273
266
@@ -279,7 +272,7 @@ thread_local! {
279 })
272 })
280}
273}
281
274
282−#[cfg_attr(feature = "debug", derive(Debug))]
275+#[derive(Debug)]
283pub struct Syntax {
276pub struct Syntax {
284 config: Arc<HighlightConfiguration>,
277 config: Arc<HighlightConfiguration>,
285
278
@@ -460,7 +453,7 @@ impl Syntax {
460 // buffer_range_for_scope_at_pos
453 // buffer_range_for_scope_at_pos
461}
454}
462
455
463−#[cfg_attr(feature = "debug", derive(Debug))]
456+#[derive(Debug)]
464pub struct LanguageLayer {
457pub struct LanguageLayer {
465 // mode
458 // mode
466 // grammar
459 // grammar
@@ -769,7 +762,7 @@ pub enum HighlightEvent {
769/// Contains the data neeeded to higlight code written in a particular language.
762/// Contains the data neeeded to higlight code written in a particular language.
770///
763///
771/// This struct is immutable and can be shared between threads.
764/// This struct is immutable and can be shared between threads.
772−#[cfg_attr(feature = "debug", derive(Debug))]
765+#[derive(Debug)]
773pub struct HighlightConfiguration {
766pub struct HighlightConfiguration {
774 pub language: Grammar,
767 pub language: Grammar,
775 pub query: Query,
768 pub query: Query,
@@ -800,7 +793,7 @@ struct LocalScope<'a> {
800 local_defs: Vec<LocalDef<'a>>,
793 local_defs: Vec<LocalDef<'a>>,
801}
794}
802
795
803−#[cfg_attr(feature = "debug", derive(Debug))]
796+#[derive(Debug)]
804struct HighlightIter<'a, 'tree: 'a, F>
797struct HighlightIter<'a, 'tree: 'a, F>
805where
798where
806 F: FnMut(&str) -> Option<&'a HighlightConfiguration> + 'a,
799 F: FnMut(&str) -> Option<&'a HighlightConfiguration> + 'a,
@@ -826,10 +819,9 @@ struct HighlightIterLayer<'a, 'tree: 'a> {
826 depth: usize,
819 depth: usize,
827}
820}
828
821
829−#[cfg(feature = "debug")]
830impl<'a, 'tree: 'a> fmt::Debug for HighlightIterLayer<'a, 'tree> {
822impl<'a, 'tree: 'a> fmt::Debug for HighlightIterLayer<'a, 'tree> {
831 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
823 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
832− f.debug_struct("HighlightIterLayer").finish_non_exhaustive()
824+ f.debug_struct("HighlightIterLayer").finish()
833 }
825 }
834}
826}
835
827
helix-core/src/transaction.rs+1−2
@@ -15,8 +15,7 @@ pub enum Operation {
15 Insert(Tendril),
15 Insert(Tendril),
16}
16}
17
17
18−#[cfg_attr(feature = "debug", derive(Debug))]
19−#[derive(Copy, Clone, PartialEq, Eq)]
18+#[derive(Debug, Copy, Clone, PartialEq, Eq)]
20pub enum Assoc {
19pub enum Assoc {
21 Before,
20 Before,
22 After,
21 After,
helix-lsp/Cargo.toml−3
@@ -7,9 +7,6 @@ license = "MPL-2.0"
7
7
8# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
9
9
10−[features]
11−debug = ["helix-core/debug"]
12−
13[dependencies]
10[dependencies]
14helix-core = { path = "../helix-core" }
11helix-core = { path = "../helix-core" }
15
12
helix-lsp/src/client.rs+1−1
@@ -16,7 +16,7 @@ use tokio::{
16 sync::mpsc::{channel, UnboundedReceiver, UnboundedSender},
16 sync::mpsc::{channel, UnboundedReceiver, UnboundedSender},
17};
17};
18
18
19−#[cfg_attr(feature = "debug", derive(Debug))]
19+#[derive(Debug)]
20pub struct Client {
20pub struct Client {
21 _process: Child,
21 _process: Child,
22 server_tx: UnboundedSender<Payload>,
22 server_tx: UnboundedSender<Payload>,
helix-lsp/src/lib.rs+1−1
@@ -172,7 +172,7 @@ impl Notification {
172 }
172 }
173}
173}
174
174
175−#[cfg_attr(feature = "debug", derive(Debug))]
175+#[derive(Debug)]
176pub struct Registry {
176pub struct Registry {
177 inner: HashMap<LanguageId, Arc<Client>>,
177 inner: HashMap<LanguageId, Arc<Client>>,
178
178
helix-lsp/src/transport.rs+1−1
@@ -31,7 +31,7 @@ enum ServerMessage {
31 Call(jsonrpc::Call),
31 Call(jsonrpc::Call),
32}
32}
33
33
34−#[cfg_attr(feature = "debug", derive(Debug))]
34+#[derive(Debug)]
35pub struct Transport {
35pub struct Transport {
36 client_tx: UnboundedSender<jsonrpc::Call>,
36 client_tx: UnboundedSender<jsonrpc::Call>,
37 client_rx: UnboundedReceiver<Payload>,
37 client_rx: UnboundedReceiver<Payload>,
helix-term/Cargo.toml−1
@@ -10,7 +10,6 @@ license = "MPL-2.0"
10
10
11[features]
11[features]
12embed_runtime = ["helix-core/embed_runtime"]
12embed_runtime = ["helix-core/embed_runtime"]
13−debug = ["helix-core/debug", "helix-view/debug"]
14
13
15[[bin]]
14[[bin]]
16name = "hx"
15name = "hx"
helix-tui/Cargo.toml−1
@@ -10,7 +10,6 @@ license = "MPL-2.0"
10
10
11[features]
11[features]
12default = ["crossterm"]
12default = ["crossterm"]
13−debug = []
14
13
15[dependencies]
14[dependencies]
16bitflags = "1.0"
15bitflags = "1.0"
helix-view/Cargo.toml−1
@@ -10,7 +10,6 @@ license = "MPL-2.0"
10[features]
10[features]
11term = ["tui", "crossterm"]
11term = ["tui", "crossterm"]
12default = ["term"]
12default = ["term"]
13−debug = ["helix-core/debug", "helix-lsp/debug"]
14
13
15[dependencies]
14[dependencies]
16anyhow = "1"
15anyhow = "1"
helix-view/src/document.rs+2−5
@@ -13,8 +13,7 @@ use crate::{DocumentId, ViewId};
13
13
14use std::collections::HashMap;
14use std::collections::HashMap;
15
15
16−#[cfg_attr(feature = "debug", derive(Debug))]
17−#[derive(Copy, Clone, PartialEq, Eq, Hash)]
16+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
18pub enum Mode {
17pub enum Mode {
19 Normal,
18 Normal,
20 Select,
19 Select,
@@ -53,9 +52,7 @@ pub struct Document {
53 language_server: Option<Arc<helix_lsp::Client>>,
52 language_server: Option<Arc<helix_lsp::Client>>,
54}
53}
55
54
56−#[cfg(feature = "debug")]
57use std::fmt;
55use std::fmt;
58−#[cfg(feature = "debug")]
59impl fmt::Debug for Document {
56impl fmt::Debug for Document {
60 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
57 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
61 f.debug_struct("Document")
58 f.debug_struct("Document")
@@ -74,7 +71,7 @@ impl fmt::Debug for Document {
74 .field("version", &self.version)
71 .field("version", &self.version)
75 .field("diagnostics", &self.diagnostics)
72 .field("diagnostics", &self.diagnostics)
76 // .field("language_server", &self.language_server)
73 // .field("language_server", &self.language_server)
77− .finish_non_exhaustive()
74+ .finish()
78 }
75 }
79}
76}
80
77
helix-view/src/editor.rs+2−3
@@ -9,7 +9,7 @@ use anyhow::Error;
9
9
10pub use helix_core::diagnostic::Severity;
10pub use helix_core::diagnostic::Severity;
11
11
12−#[cfg_attr(feature = "debug", derive(Debug))]
12+#[derive(Debug)]
13pub struct Editor {
13pub struct Editor {
14 pub tree: Tree,
14 pub tree: Tree,
15 pub documents: SlotMap<DocumentId, Document>,
15 pub documents: SlotMap<DocumentId, Document>,
@@ -21,8 +21,7 @@ pub struct Editor {
21 pub status_msg: Option<(String, Severity)>,
21 pub status_msg: Option<(String, Severity)>,
22}
22}
23
23
24−#[cfg_attr(feature = "debug", derive(Debug))]
25−#[derive(Copy, Clone)]
24+#[derive(Debug, Copy, Clone)]
26pub enum Action {
25pub enum Action {
27 Replace,
26 Replace,
28 HorizontalSplit,
27 HorizontalSplit,
helix-view/src/tree.rs+6−7
@@ -4,7 +4,7 @@ use tui::layout::Rect;
4
4
5// the dimensions are recomputed on windo resize/tree change.
5// the dimensions are recomputed on windo resize/tree change.
6//
6//
7−#[cfg_attr(feature = "debug", derive(Debug))]
7+#[derive(Debug)]
8pub struct Tree {
8pub struct Tree {
9 root: ViewId,
9 root: ViewId,
10 // (container, index inside the container)
10 // (container, index inside the container)
@@ -18,13 +18,13 @@ pub struct Tree {
18 stack: Vec<(ViewId, Rect)>,
18 stack: Vec<(ViewId, Rect)>,
19}
19}
20
20
21−#[cfg_attr(feature = "debug", derive(Debug))]
21+#[derive(Debug)]
22pub struct Node {
22pub struct Node {
23 parent: ViewId,
23 parent: ViewId,
24 content: Content,
24 content: Content,
25}
25}
26
26
27−#[cfg_attr(feature = "debug", derive(Debug))]
27+#[derive(Debug)]
28pub enum Content {
28pub enum Content {
29 View(Box<View>),
29 View(Box<View>),
30 Container(Box<Container>),
30 Container(Box<Container>),
@@ -48,15 +48,14 @@ impl Node {
48
48
49// TODO: screen coord to container + container coordinate helpers
49// TODO: screen coord to container + container coordinate helpers
50
50
51−#[cfg_attr(feature = "debug", derive(Debug))]
52−#[derive(PartialEq, Eq)]
51+#[derive(Debug, PartialEq, Eq)]
53pub enum Layout {
52pub enum Layout {
54 Horizontal,
53 Horizontal,
55 Vertical,
54 Vertical,
56 // could explore stacked/tabbed
55 // could explore stacked/tabbed
57}
56}
58
57
59−#[cfg_attr(feature = "debug", derive(Debug))]
58+#[derive(Debug)]
60pub struct Container {
59pub struct Container {
61 layout: Layout,
60 layout: Layout,
62 children: Vec<ViewId>,
61 children: Vec<ViewId>,
@@ -437,7 +436,7 @@ impl Tree {
437 }
436 }
438}
437}
439
438
440−#[cfg_attr(feature = "debug", derive(Debug))]
439+#[derive(Debug)]
441pub struct Traverse<'a> {
440pub struct Traverse<'a> {
442 tree: &'a Tree,
441 tree: &'a Tree,
443 stack: Vec<ViewId>, // TODO: reuse the one we use on update
442 stack: Vec<ViewId>, // TODO: reuse the one we use on update
helix-view/src/view.rs+2−2
@@ -12,7 +12,7 @@ pub const PADDING: usize = 5;
12
12
13type Jump = (DocumentId, Selection);
13type Jump = (DocumentId, Selection);
14
14
15−#[cfg_attr(feature = "debug", derive(Debug))]
15+#[derive(Debug)]
16pub struct JumpList {
16pub struct JumpList {
17 jumps: Vec<Jump>,
17 jumps: Vec<Jump>,
18 current: usize,
18 current: usize,
@@ -59,7 +59,7 @@ impl JumpList {
59 }
59 }
60}
60}
61
61
62−#[cfg_attr(feature = "debug", derive(Debug))]
62+#[derive(Debug)]
63pub struct View {
63pub struct View {
64 pub id: ViewId,
64 pub id: ViewId,
65 pub doc: DocumentId,
65 pub doc: DocumentId,