textbringer-tree-sitter 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE.txt +13 -1
- data/README.md +44 -53
- data/exe/textbringer-tree-sitter +16 -4
- data/lefthook.yml +5 -0
- data/lib/textbringer/tree_sitter/node_maps/sql.rb +54 -0
- data/lib/textbringer/tree_sitter/node_maps.rb +2 -0
- data/lib/textbringer/tree_sitter/version.rb +1 -1
- data/lib/textbringer_plugin.rb +5 -0
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b7273acdfaffa92b93724cc56ebf35c6e0d645756203b7b32a1dedea38f615fb
|
|
4
|
+
data.tar.gz: a7b77614d915a8aaa64810e7332cae96342e108fda2cf0e7fc23d02e5c82e6bd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b7904ef48cc189a0130d440bd32a2f5f5ee4381300b93ed93127297f8258a3600d4db1e885c204e4e49d415f0535847e3348016795915bdee13fa7b2a118371d
|
|
7
|
+
data.tar.gz: 0aee8946b437bafc0b5051c6d2000b37a3dd9da5f9c992cf7e40baa0ac91c322f3af725470fea44697f234f36084ac733280f6103e960d1fb3bd211bca0f8607
|
data/LICENSE.txt
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
|
2
2
|
Version 2, December 2004
|
|
3
3
|
|
|
4
|
-
Copyright (C)
|
|
4
|
+
Copyright (C) 2026 yancya <yancya@upec.jp>
|
|
5
5
|
|
|
6
6
|
Everyone is permitted to copy and distribute verbatim or modified
|
|
7
7
|
copies of this license document, and changing it is allowed as long
|
|
@@ -11,3 +11,15 @@ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
|
|
11
11
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
12
12
|
|
|
13
13
|
0. You just DO WHAT THE FUCK YOU WANT TO.
|
|
14
|
+
|
|
15
|
+
--------------------------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
DISCLAIMER
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
data/README.md
CHANGED
|
@@ -1,84 +1,81 @@
|
|
|
1
1
|
# textbringer-tree-sitter
|
|
2
2
|
|
|
3
|
-
Tree-sitter
|
|
3
|
+
Tree-sitter based syntax highlighting plugin for Textbringer.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Features
|
|
6
6
|
|
|
7
|
-
- Tree-sitter
|
|
8
|
-
-
|
|
9
|
-
- Emacs
|
|
10
|
-
-
|
|
7
|
+
- Accurate syntax parsing with Tree-sitter
|
|
8
|
+
- Properly highlights Terraform/HCL `for`, `in`, and function calls (which Rouge fails to recognize)
|
|
9
|
+
- Emacs-style feature-based level control
|
|
10
|
+
- Customizable node mappings
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## Installation
|
|
13
13
|
|
|
14
14
|
```ruby
|
|
15
15
|
gem 'textbringer-tree-sitter'
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
- Ruby, Python, JavaScript, JSON, Bash
|
|
18
|
+
### Installing Parsers
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
Parsers are not bundled with the gem. Use the CLI tool to install them:
|
|
22
21
|
|
|
23
22
|
```bash
|
|
24
|
-
#
|
|
23
|
+
# List available parsers
|
|
25
24
|
textbringer-tree-sitter list
|
|
26
25
|
|
|
27
|
-
#
|
|
26
|
+
# Install a specific parser (downloads prebuilt or builds from source)
|
|
27
|
+
textbringer-tree-sitter get ruby
|
|
28
28
|
textbringer-tree-sitter get hcl
|
|
29
|
+
textbringer-tree-sitter get markdown
|
|
29
30
|
|
|
30
|
-
#
|
|
31
|
-
textbringer-tree-sitter get yaml
|
|
32
|
-
|
|
33
|
-
# Go parser をビルド&インストール
|
|
34
|
-
textbringer-tree-sitter get go
|
|
35
|
-
|
|
36
|
-
# プリビルド済み parser をすべてインストール
|
|
31
|
+
# Install all prebuilt parsers at once
|
|
37
32
|
textbringer-tree-sitter get-all
|
|
38
33
|
```
|
|
39
34
|
|
|
40
|
-
### Parser
|
|
35
|
+
### Parser Location
|
|
41
36
|
|
|
42
|
-
|
|
37
|
+
Parsers are stored in `~/.textbringer/parsers/{platform}/`.
|
|
43
38
|
|
|
44
39
|
```bash
|
|
45
|
-
#
|
|
40
|
+
# Show parser directory
|
|
46
41
|
textbringer-tree-sitter path
|
|
47
42
|
```
|
|
48
43
|
|
|
49
|
-
##
|
|
44
|
+
## Usage
|
|
45
|
+
|
|
46
|
+
Once a parser is installed and a node_map exists for the language, syntax highlighting is automatically enabled for the corresponding Mode.
|
|
50
47
|
|
|
51
|
-
|
|
48
|
+
For custom Modes, call `use_tree_sitter`:
|
|
52
49
|
|
|
53
50
|
```ruby
|
|
54
|
-
class
|
|
51
|
+
class MyMode < ProgrammingMode
|
|
55
52
|
extend Textbringer::TreeSitterAdapter::ClassMethods
|
|
56
53
|
use_tree_sitter :ruby
|
|
57
54
|
end
|
|
58
55
|
```
|
|
59
56
|
|
|
60
|
-
##
|
|
57
|
+
## Customization
|
|
61
58
|
|
|
62
|
-
###
|
|
59
|
+
### Highlight Level (Emacs-style)
|
|
63
60
|
|
|
64
61
|
```ruby
|
|
65
62
|
# ~/.textbringer.rb
|
|
66
63
|
|
|
67
|
-
# Level 1: comment, string
|
|
64
|
+
# Level 1: comment, string only
|
|
68
65
|
# Level 2: + keyword, type, constant
|
|
69
|
-
# Level 3: + function_name, variable, number (
|
|
66
|
+
# Level 3: + function_name, variable, number (default)
|
|
70
67
|
# Level 4: + operator, punctuation, builtin
|
|
71
68
|
|
|
72
69
|
CONFIG[:tree_sitter_highlight_level] = 4
|
|
73
70
|
```
|
|
74
71
|
|
|
75
|
-
###
|
|
72
|
+
### Individual Feature Selection
|
|
76
73
|
|
|
77
74
|
```ruby
|
|
78
75
|
CONFIG[:tree_sitter_enabled_features] = [:comment, :string, :keyword]
|
|
79
76
|
```
|
|
80
77
|
|
|
81
|
-
###
|
|
78
|
+
### Custom Node Mappings
|
|
82
79
|
|
|
83
80
|
```ruby
|
|
84
81
|
Textbringer::TreeSitter::NodeMaps.register(:ruby, {
|
|
@@ -86,40 +83,34 @@ Textbringer::TreeSitter::NodeMaps.register(:ruby, {
|
|
|
86
83
|
})
|
|
87
84
|
```
|
|
88
85
|
|
|
89
|
-
###
|
|
86
|
+
### Custom Parser Path
|
|
90
87
|
|
|
91
88
|
```ruby
|
|
92
89
|
CONFIG[:tree_sitter_parser_dir] = "/path/to/your/parsers"
|
|
93
90
|
```
|
|
94
91
|
|
|
95
|
-
##
|
|
92
|
+
## Supported Languages
|
|
96
93
|
|
|
97
|
-
###
|
|
94
|
+
### Prebuilt Parsers (via Faveod)
|
|
98
95
|
|
|
99
|
-
|
|
100
|
-
|------|------|
|
|
101
|
-
| Ruby | ✓ 自動 |
|
|
102
|
-
| Python | ✓ 自動 |
|
|
103
|
-
| JavaScript | ✓ 自動 |
|
|
104
|
-
| JSON | ✓ 自動 |
|
|
105
|
-
| Bash | ✓ 自動 |
|
|
106
|
-
| C | `get c` |
|
|
107
|
-
| Java | `get java` |
|
|
108
|
-
| Rust | `get rust` |
|
|
109
|
-
| HTML | `get html` |
|
|
110
|
-
| PHP | `get php` |
|
|
96
|
+
bash, c, c-sharp, cobol, embedded-template, groovy, haml, html, java, javascript, json, pascal, php, python, ruby, rust
|
|
111
97
|
|
|
112
|
-
###
|
|
98
|
+
### Build-required Parsers
|
|
113
99
|
|
|
114
|
-
|
|
|
115
|
-
|
|
100
|
+
| Language | Command |
|
|
101
|
+
|----------|---------|
|
|
116
102
|
| HCL (Terraform) | `textbringer-tree-sitter get hcl` |
|
|
117
103
|
| YAML | `textbringer-tree-sitter get yaml` |
|
|
118
104
|
| Go | `textbringer-tree-sitter get go` |
|
|
119
105
|
| TypeScript | `textbringer-tree-sitter get typescript` |
|
|
120
|
-
|
|
|
121
|
-
|
|
|
106
|
+
| TSX | `textbringer-tree-sitter get tsx` |
|
|
107
|
+
| SQL | `textbringer-tree-sitter get sql` |
|
|
108
|
+
| Markdown | `textbringer-tree-sitter get markdown` |
|
|
109
|
+
|
|
110
|
+
## License
|
|
111
|
+
|
|
112
|
+
WTFPL - See LICENSE.txt for details.
|
|
122
113
|
|
|
123
|
-
##
|
|
114
|
+
## Disclaimer
|
|
124
115
|
|
|
125
|
-
|
|
116
|
+
THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/exe/textbringer-tree-sitter
CHANGED
|
@@ -56,10 +56,11 @@ module TextbringerTreeSitterCLI
|
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
58
|
sql: {
|
|
59
|
-
repo: "
|
|
59
|
+
repo: "m-novikov/tree-sitter-sql",
|
|
60
60
|
branch: "main",
|
|
61
61
|
build_cmd: ->(src_dir, out_file) {
|
|
62
|
-
|
|
62
|
+
# scanner.cc requires C++
|
|
63
|
+
"c++ -shared -fPIC -O2 -std=c++14 -I#{src_dir}/src #{src_dir}/src/parser.c #{src_dir}/src/scanner.cc -o #{out_file}"
|
|
63
64
|
}
|
|
64
65
|
},
|
|
65
66
|
markdown: {
|
|
@@ -482,8 +483,19 @@ module TextbringerTreeSitterCLI
|
|
|
482
483
|
skip_map = args.include?("--no-map")
|
|
483
484
|
success = get_parser(lang)
|
|
484
485
|
if success && !skip_map
|
|
485
|
-
|
|
486
|
-
|
|
486
|
+
# デフォルト node_map がある言語はスキップ
|
|
487
|
+
default_node_map_languages = %w[
|
|
488
|
+
bash c cobol csharp groovy haml hcl html java javascript
|
|
489
|
+
json pascal php python ruby rust sql yaml
|
|
490
|
+
]
|
|
491
|
+
lang_normalized = lang.to_s.gsub("-", "")
|
|
492
|
+
if default_node_map_languages.include?(lang_normalized)
|
|
493
|
+
puts ""
|
|
494
|
+
puts "Using default node_map for #{lang} (included in gem)"
|
|
495
|
+
else
|
|
496
|
+
puts ""
|
|
497
|
+
generate_node_map(lang)
|
|
498
|
+
end
|
|
487
499
|
end
|
|
488
500
|
exit(success ? 0 : 1)
|
|
489
501
|
when "get-all"
|
data/lefthook.yml
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Textbringer
|
|
4
|
+
module TreeSitter
|
|
5
|
+
module NodeMaps
|
|
6
|
+
SQL_FEATURES = {
|
|
7
|
+
keyword: %i[
|
|
8
|
+
SELECT FROM WHERE JOIN LEFT RIGHT INNER OUTER FULL NATURAL CROSS
|
|
9
|
+
ON AND OR NOT IN IS NULL BETWEEN LIKE ILIKE
|
|
10
|
+
INSERT INTO VALUES UPDATE SET DELETE
|
|
11
|
+
CREATE DROP ALTER TABLE INDEX VIEW SCHEMA DATABASE
|
|
12
|
+
PRIMARY_KEY FOREIGN_KEY UNIQUE CHECK CONSTRAINT REFERENCES
|
|
13
|
+
GROUP_BY ORDER_BY HAVING LIMIT OFFSET FETCH
|
|
14
|
+
UNION INTERSECT EXCEPT ALL DISTINCT
|
|
15
|
+
AS ASC DESC NULLS FIRST LAST
|
|
16
|
+
CASE WHEN THEN ELSE END
|
|
17
|
+
BEGIN COMMIT ROLLBACK TRANSACTION
|
|
18
|
+
IF EXISTS IF_EXISTS IF_NOT_EXISTS
|
|
19
|
+
TRUE FALSE DEFAULT
|
|
20
|
+
WITH RECURSIVE
|
|
21
|
+
GRANT REVOKE PRIVILEGES
|
|
22
|
+
RETURNS RETURN FUNCTION PROCEDURE
|
|
23
|
+
FOR EACH ROW TRIGGER
|
|
24
|
+
CASCADE RESTRICT SET_NULL SET_DEFAULT
|
|
25
|
+
VOLATILE STABLE IMMUTABLE
|
|
26
|
+
DECLARE EXECUTE
|
|
27
|
+
],
|
|
28
|
+
comment: %i[comment line_comment block_comment],
|
|
29
|
+
string: %i[string],
|
|
30
|
+
number: %i[number],
|
|
31
|
+
type: %i[
|
|
32
|
+
type_cast constrained_type array_type
|
|
33
|
+
INTEGER INT SMALLINT BIGINT
|
|
34
|
+
REAL FLOAT DOUBLE DECIMAL NUMERIC
|
|
35
|
+
VARCHAR CHAR TEXT
|
|
36
|
+
BOOLEAN BOOL
|
|
37
|
+
DATE TIME TIMESTAMP TIMESTAMPTZ
|
|
38
|
+
JSON JSONB XML
|
|
39
|
+
UUID BYTEA
|
|
40
|
+
SERIAL BIGSERIAL
|
|
41
|
+
],
|
|
42
|
+
function_name: %i[function_call],
|
|
43
|
+
variable: %i[identifier dotted_name],
|
|
44
|
+
operator: %i[binary_operator comparison_operator],
|
|
45
|
+
punctuation: %i[delimiter],
|
|
46
|
+
constant: %i[boolean_expression],
|
|
47
|
+
}.freeze
|
|
48
|
+
|
|
49
|
+
SQL = SQL_FEATURES.flat_map { |face, nodes|
|
|
50
|
+
nodes.map { |node| [node, face] }
|
|
51
|
+
}.to_h.freeze
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -16,6 +16,7 @@ require_relative "node_maps/pascal"
|
|
|
16
16
|
require_relative "node_maps/php"
|
|
17
17
|
require_relative "node_maps/python"
|
|
18
18
|
require_relative "node_maps/rust"
|
|
19
|
+
require_relative "node_maps/sql"
|
|
19
20
|
require_relative "node_maps/yaml"
|
|
20
21
|
|
|
21
22
|
module Textbringer
|
|
@@ -69,6 +70,7 @@ module Textbringer
|
|
|
69
70
|
php: PHP,
|
|
70
71
|
python: PYTHON,
|
|
71
72
|
rust: RUST,
|
|
73
|
+
sql: SQL,
|
|
72
74
|
yaml: YAML_LANG
|
|
73
75
|
}
|
|
74
76
|
end
|
data/lib/textbringer_plugin.rb
CHANGED
|
@@ -91,6 +91,11 @@ Textbringer::TreeSitter::NodeMaps.available_languages.each do |language|
|
|
|
91
91
|
Textbringer.class_eval <<~RUBY, __FILE__, __LINE__ + 1
|
|
92
92
|
class #{mode_name} < ProgrammingMode
|
|
93
93
|
self.file_name_pattern = #{pattern.inspect}
|
|
94
|
+
|
|
95
|
+
# 最低限の indent_line を定義(改行できるように)
|
|
96
|
+
def indent_line
|
|
97
|
+
# デフォルトは何もしない
|
|
98
|
+
end
|
|
94
99
|
end
|
|
95
100
|
RUBY
|
|
96
101
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: textbringer-tree-sitter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- yancya
|
|
@@ -69,7 +69,7 @@ dependencies:
|
|
|
69
69
|
description: Provides accurate syntax highlighting using Tree-sitter parsers for Textbringer
|
|
70
70
|
editor
|
|
71
71
|
email:
|
|
72
|
-
- yancya@
|
|
72
|
+
- yancya@upec.jp
|
|
73
73
|
executables:
|
|
74
74
|
- textbringer-tree-sitter
|
|
75
75
|
extensions:
|
|
@@ -82,6 +82,7 @@ files:
|
|
|
82
82
|
- Rakefile
|
|
83
83
|
- exe/textbringer-tree-sitter
|
|
84
84
|
- ext/textbringer_tree_sitter/extconf.rb
|
|
85
|
+
- lefthook.yml
|
|
85
86
|
- lib/textbringer/tree_sitter/node_maps.rb
|
|
86
87
|
- lib/textbringer/tree_sitter/node_maps/bash.rb
|
|
87
88
|
- lib/textbringer/tree_sitter/node_maps/c.rb
|
|
@@ -99,6 +100,7 @@ files:
|
|
|
99
100
|
- lib/textbringer/tree_sitter/node_maps/python.rb
|
|
100
101
|
- lib/textbringer/tree_sitter/node_maps/ruby.rb
|
|
101
102
|
- lib/textbringer/tree_sitter/node_maps/rust.rb
|
|
103
|
+
- lib/textbringer/tree_sitter/node_maps/sql.rb
|
|
102
104
|
- lib/textbringer/tree_sitter/node_maps/yaml.rb
|
|
103
105
|
- lib/textbringer/tree_sitter/version.rb
|
|
104
106
|
- lib/textbringer/tree_sitter_adapter.rb
|