diff options
Diffstat (limited to 'tree-viz/src')
-rw-r--r-- | tree-viz/src/app.rs | 17 | ||||
-rw-r--r-- | tree-viz/src/config.rs | 2 | ||||
-rw-r--r-- | tree-viz/src/main.rs | 9 |
3 files changed, 27 insertions, 1 deletions
diff --git a/tree-viz/src/app.rs b/tree-viz/src/app.rs index 68d3641..8581084 100644 --- a/tree-viz/src/app.rs +++ b/tree-viz/src/app.rs | |||
@@ -105,6 +105,23 @@ impl App { | |||
105 | ) | 105 | ) |
106 | .unwrap(); | 106 | .unwrap(); |
107 | 107 | ||
108 | if self.config.show_field_name { | ||
109 | if let Some(f) = cursor.field_name() { | ||
110 | write!( | ||
111 | tree_string, | ||
112 | "{} ", | ||
113 | if in_capture.is_some() { | ||
114 | Style::new().on_yellow().on_bright() | ||
115 | } else { | ||
116 | Style::new() | ||
117 | } | ||
118 | .yellow() | ||
119 | .apply_to(f) | ||
120 | ) | ||
121 | .unwrap() | ||
122 | } | ||
123 | } | ||
124 | |||
108 | write!( | 125 | write!( |
109 | tree_string, | 126 | tree_string, |
110 | "{} ", | 127 | "{} ", |
diff --git a/tree-viz/src/config.rs b/tree-viz/src/config.rs index 6f34291..18ed5cc 100644 --- a/tree-viz/src/config.rs +++ b/tree-viz/src/config.rs | |||
@@ -5,6 +5,7 @@ pub struct Config { | |||
5 | pub indent_level: usize, | 5 | pub indent_level: usize, |
6 | pub show_ranges: bool, | 6 | pub show_ranges: bool, |
7 | pub show_src: bool, | 7 | pub show_src: bool, |
8 | pub show_field_name: bool, | ||
8 | } | 9 | } |
9 | 10 | ||
10 | impl Default for Config { | 11 | impl Default for Config { |
@@ -19,6 +20,7 @@ impl Config { | |||
19 | indent_level: 2, | 20 | indent_level: 2, |
20 | show_ranges: true, | 21 | show_ranges: true, |
21 | show_src: true, | 22 | show_src: true, |
23 | show_field_name: true, | ||
22 | } | 24 | } |
23 | } | 25 | } |
24 | } | 26 | } |
diff --git a/tree-viz/src/main.rs b/tree-viz/src/main.rs index 79964cb..9c73062 100644 --- a/tree-viz/src/main.rs +++ b/tree-viz/src/main.rs | |||
@@ -16,7 +16,14 @@ use once_cell::sync::Lazy; | |||
16 | use tree_sitter::Language; | 16 | use tree_sitter::Language; |
17 | 17 | ||
18 | //pub static LANGUAGE: Lazy<Language> = Lazy::new(tree_sitter_rust::language); | 18 | //pub static LANGUAGE: Lazy<Language> = Lazy::new(tree_sitter_rust::language); |
19 | pub static LANGUAGE: Lazy<Language> = Lazy::new(tree_sitter_typescript::language_typescript); | 19 | //pub static LANGUAGE: Lazy<Language> = Lazy::new(tree_sitter_typescript::language_tsx); |
20 | //pub static LANGUAGE: Lazy<Language> = Lazy::new(tree_sitter_javascript::language); | ||
21 | //pub static LANGUAGE: Lazy<Language> = Lazy::new(tree_sitter_mdx::language); | ||
22 | //pub static LANGUAGE: Lazy<Language> = Lazy::new(tree_sitter_json::language); | ||
23 | //pub static LANGUAGE: Lazy<Language> = Lazy::new(tree_sitter_python::language); | ||
24 | //pub static LANGUAGE: Lazy<Language> = Lazy::new(tree_sitter_ruby::language); | ||
25 | //pub static LANGUAGE: Lazy<Language> = Lazy::new(tree_sitter_r::language); | ||
26 | pub static LANGUAGE: Lazy<Language> = Lazy::new(tree_sitter_php::language); | ||
20 | 27 | ||
21 | fn main() { | 28 | fn main() { |
22 | let mut args = env::args(); | 29 | let mut args = env::args(); |