summaryrefslogtreecommitdiff
path: root/tree-viz
diff options
context:
space:
mode:
Diffstat (limited to 'tree-viz')
-rw-r--r--tree-viz/Cargo.toml9
-rw-r--r--tree-viz/src/app.rs17
-rw-r--r--tree-viz/src/config.rs2
-rw-r--r--tree-viz/src/main.rs9
4 files changed, 35 insertions, 2 deletions
diff --git a/tree-viz/Cargo.toml b/tree-viz/Cargo.toml
index 04107d3..ddac4f8 100644
--- a/tree-viz/Cargo.toml
+++ b/tree-viz/Cargo.toml
@@ -7,12 +7,19 @@ edition = "2021"
7 7
8[dependencies] 8[dependencies]
9tree-sitter-elm = "5.6.3" 9tree-sitter-elm = "5.6.3"
10tree-sitter-rust = "0.20.1" 10tree-sitter-ruby = "0.20.0"
11tree-sitter-rust = "0.20.3"
11tree-sitter = "^0.20.8" 12tree-sitter = "^0.20.8"
12console = "^0.15" 13console = "^0.15"
13once_cell = "1.14.0" 14once_cell = "1.14.0"
14tree-sitter-go = "0.19.1" 15tree-sitter-go = "0.19.1"
15tree-sitter-typescript = "0.20.1" 16tree-sitter-typescript = "0.20.1"
17tree-sitter-javascript = "0.20.0"
18tree-sitter-mdx = { git = "https://github.com/jlopezcur/tree-sitter-mdx" }
19tree-sitter-json = { git = "https://github.com/tree-sitter/tree-sitter-json" }
20tree-sitter-python = "0.20.2"
21tree-sitter-r = "0.19.5"
22tree-sitter-php = { git = "https://github.com/tree-sitter/tree-sitter-php" }
16 23
17[dependencies.notify] 24[dependencies.notify]
18version = "5.0.0" 25version = "5.0.0"
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
10impl Default for Config { 11impl 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;
16use tree_sitter::Language; 16use 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);
19pub 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);
26pub static LANGUAGE: Lazy<Language> = Lazy::new(tree_sitter_php::language);
20 27
21fn main() { 28fn main() {
22 let mut args = env::args(); 29 let mut args = env::args();