textbringer-tree-sitter 1.1.0 → 1.2.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/CI_PARSER_SETUP.md +92 -0
- data/CLAUDE.md +101 -21
- data/DISCLAIMER +9 -0
- data/LICENSE +13 -0
- data/README.md +147 -23
- data/Rakefile +17 -0
- data/exe/textbringer-tree-sitter +487 -77
- data/ext/textbringer_tree_sitter/extconf.rb +94 -26
- data/lib/textbringer/tree_sitter/language_aliases.rb +67 -0
- data/lib/textbringer/tree_sitter/node_maps/bash.rb +61 -6
- data/lib/textbringer/tree_sitter/node_maps/c.rb +187 -9
- data/lib/textbringer/tree_sitter/node_maps/crystal.rb +144 -0
- data/lib/textbringer/tree_sitter/node_maps/csharp.rb +261 -6
- data/lib/textbringer/tree_sitter/node_maps/elixir.rb +93 -0
- data/lib/textbringer/tree_sitter/node_maps/hcl.rb +27 -9
- data/lib/textbringer/tree_sitter/node_maps/html.rb +12 -1
- data/lib/textbringer/tree_sitter/node_maps/java.rb +161 -7
- data/lib/textbringer/tree_sitter/node_maps/javascript.rb +100 -4
- data/lib/textbringer/tree_sitter/node_maps/json.rb +12 -3
- data/lib/textbringer/tree_sitter/node_maps/pascal.rb +196 -11
- data/lib/textbringer/tree_sitter/node_maps/python.rb +124 -6
- data/lib/textbringer/tree_sitter/node_maps/ruby.rb +92 -8
- data/lib/textbringer/tree_sitter/node_maps/rust.rb +187 -4
- data/lib/textbringer/tree_sitter/node_maps/swift.rb +133 -0
- data/lib/textbringer/tree_sitter/node_maps/yaml.rb +22 -0
- data/lib/textbringer/tree_sitter/node_maps.rb +18 -6
- data/lib/textbringer/tree_sitter/platform.rb +50 -0
- data/lib/textbringer/tree_sitter/version.rb +1 -1
- data/lib/textbringer/tree_sitter_adapter.rb +64 -5
- data/lib/textbringer/tree_sitter_config.rb +10 -20
- data/lib/textbringer_plugin.rb +20 -0
- data/scripts/build_parsers.sh +38 -11
- data/scripts/download_parsers.sh +176 -0
- metadata +11 -3
- data/LICENSE.txt +0 -25
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e49bbd134f0163af928c442de2eae8804655ca7acf9a86d13b29e3b4335857bf
|
|
4
|
+
data.tar.gz: fcb3bdd6fd34d0b199e27e647174c1b432aa5fdd7cbde79319d747e33ef13be4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a4ff22e0d8c167cd96b019815411ac1f91b0f8687d8de5559d652269531316f3bc465a7851c964fc252ec2895aabe45af0e163b732976f767ec3f5618240748d
|
|
7
|
+
data.tar.gz: 9c29a6c31361c69b29212dfc52731c51889eebea551c6e14a8a30a48a8ff98e6edeca29a68a4b2588879506c8cf7dcd7d9176b90b69aba7a48fca204fbea71a9
|
data/CI_PARSER_SETUP.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# CI Parser Setup Instructions
|
|
2
|
+
|
|
3
|
+
## Problem
|
|
4
|
+
|
|
5
|
+
Tests skip when tree-sitter parsers are not installed, leading to false-green builds in CI.
|
|
6
|
+
|
|
7
|
+
## Solution
|
|
8
|
+
|
|
9
|
+
Add a step to download parsers before running tests in your CI workflow.
|
|
10
|
+
|
|
11
|
+
## Required Changes to `.github/workflows/ci.yml`
|
|
12
|
+
|
|
13
|
+
Add the following step **before** the "Run tests" step:
|
|
14
|
+
|
|
15
|
+
```yaml
|
|
16
|
+
- name: Setup parsers for tests
|
|
17
|
+
run: bundle exec rake parsers:download
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Complete Example
|
|
21
|
+
|
|
22
|
+
```yaml
|
|
23
|
+
name: CI
|
|
24
|
+
|
|
25
|
+
on:
|
|
26
|
+
push:
|
|
27
|
+
branches: [main]
|
|
28
|
+
pull_request:
|
|
29
|
+
branches: [main]
|
|
30
|
+
|
|
31
|
+
jobs:
|
|
32
|
+
test:
|
|
33
|
+
runs-on: ubuntu-latest
|
|
34
|
+
strategy:
|
|
35
|
+
matrix:
|
|
36
|
+
ruby-version: ['3.3', '3.4', '4.0']
|
|
37
|
+
|
|
38
|
+
steps:
|
|
39
|
+
- uses: actions/checkout@v4
|
|
40
|
+
|
|
41
|
+
- name: Set up Ruby ${{ matrix.ruby-version }}
|
|
42
|
+
uses: ruby/setup-ruby@v1
|
|
43
|
+
with:
|
|
44
|
+
ruby-version: ${{ matrix.ruby-version }}
|
|
45
|
+
bundler-cache: true
|
|
46
|
+
|
|
47
|
+
- name: Setup parsers for tests
|
|
48
|
+
run: bundle exec rake parsers:download
|
|
49
|
+
|
|
50
|
+
- name: Run tests
|
|
51
|
+
run: bundle exec rake test
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Available Rake Tasks
|
|
55
|
+
|
|
56
|
+
- `rake parsers:download` - Download prebuilt parsers (fastest, recommended for CI)
|
|
57
|
+
- `rake parsers:build` - Build parsers from source (requires compiler)
|
|
58
|
+
- `rake parsers:setup` - Download if possible, fall back to build
|
|
59
|
+
|
|
60
|
+
## Parsers Required for Tests
|
|
61
|
+
|
|
62
|
+
- `ruby` - For Ruby syntax highlighting tests
|
|
63
|
+
- `hcl` - For HCL/Terraform tests
|
|
64
|
+
- `markdown` - For Markdown integration tests
|
|
65
|
+
|
|
66
|
+
## Manual Setup (Development)
|
|
67
|
+
|
|
68
|
+
To run tests locally with parsers:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
bundle exec rake parsers:download
|
|
72
|
+
bundle exec rake test
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Or build from source:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
./scripts/build_parsers.sh
|
|
79
|
+
bundle exec rake test
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Troubleshooting
|
|
83
|
+
|
|
84
|
+
If parser download fails in CI:
|
|
85
|
+
1. Check network connectivity to GitHub
|
|
86
|
+
2. Verify the Faveod/tree-sitter-parsers release version in `scripts/download_parsers.sh`
|
|
87
|
+
3. Fall back to building from source: `bundle exec rake parsers:build`
|
|
88
|
+
|
|
89
|
+
## References
|
|
90
|
+
|
|
91
|
+
- Issue: #20
|
|
92
|
+
- Parser source: https://github.com/Faveod/tree-sitter-parsers
|
data/CLAUDE.md
CHANGED
|
@@ -6,6 +6,11 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
|
|
6
6
|
|
|
7
7
|
Textbringer(Ruby製ターミナルエディタ)に Tree-sitter ベースのシンタックスハイライトを提供するプラグイン gem。textbringer-rouge の代替として、より正確な構文解析を実現する(特に Terraform/HCL で Rouge の lexer に問題があるため)。
|
|
8
8
|
|
|
9
|
+
## Textbringer とは
|
|
10
|
+
|
|
11
|
+
* Ruby 製の Emacs 風テキストエディタ
|
|
12
|
+
* コマンド名は `txtb`
|
|
13
|
+
|
|
9
14
|
## 開発コマンド
|
|
10
15
|
|
|
11
16
|
```bash
|
|
@@ -14,8 +19,35 @@ bundle exec rake test
|
|
|
14
19
|
bundle exec ruby -Ilib:test test/test_*.rb # 単一テスト
|
|
15
20
|
bundle exec rake build
|
|
16
21
|
bundle exec rubocop
|
|
22
|
+
|
|
23
|
+
# デバッグモード(/tmp/tree_sitter_debug.log に出力)
|
|
24
|
+
TEXTBRINGER_TREE_SITTER_DEBUG=1 textbringer
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## CLI ツール
|
|
28
|
+
|
|
29
|
+
gem に同梱の `textbringer-tree-sitter` コマンドで parser 管理:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
textbringer-tree-sitter list # 利用可能な parser 一覧
|
|
33
|
+
textbringer-tree-sitter get <lang> # parser ダウンロード/ビルド + node_map 自動生成
|
|
34
|
+
textbringer-tree-sitter get <lang> --no-map # node_map 生成をスキップ
|
|
35
|
+
textbringer-tree-sitter get-all # Faveod prebuilt を一括インストール
|
|
36
|
+
textbringer-tree-sitter generate-map <lang> # 既存 parser から node_map 再生成
|
|
37
|
+
textbringer-tree-sitter path # parser ディレクトリ表示
|
|
17
38
|
```
|
|
18
39
|
|
|
40
|
+
### Parser の配置場所
|
|
41
|
+
|
|
42
|
+
- `~/.textbringer/parsers/{platform}/` にインストールされる
|
|
43
|
+
- プラットフォーム例: `darwin-arm64`, `linux-x64`
|
|
44
|
+
- カスタムパスは `CONFIG[:tree_sitter_parser_dir]` で指定可能
|
|
45
|
+
|
|
46
|
+
### Parser の種類
|
|
47
|
+
|
|
48
|
+
- **Faveod prebuilt**: bash, c, c-sharp, cobol, embedded-template, groovy, haml, html, java, javascript, json, pascal, php, python, ruby, rust
|
|
49
|
+
- **ビルド必須**: hcl, yaml, go, typescript, tsx, sql, markdown (各リポジトリから clone & build)
|
|
50
|
+
|
|
19
51
|
## アーキテクチャ
|
|
20
52
|
|
|
21
53
|
### 構造
|
|
@@ -23,54 +55,102 @@ bundle exec rubocop
|
|
|
23
55
|
```
|
|
24
56
|
lib/
|
|
25
57
|
├── textbringer/
|
|
26
|
-
│ ├── tree_sitter_adapter.rb # Window モンキーパッチ +
|
|
27
|
-
│ ├── tree_sitter_config.rb # Parser
|
|
58
|
+
│ ├── tree_sitter_adapter.rb # Window モンキーパッチ + ハイライト実装
|
|
59
|
+
│ ├── tree_sitter_config.rb # Parser パス解決、Face 定義
|
|
28
60
|
│ └── tree_sitter/
|
|
29
61
|
│ ├── version.rb
|
|
30
|
-
│
|
|
31
|
-
│
|
|
32
|
-
│
|
|
62
|
+
│ ├── node_maps.rb # NodeMap レジストリ
|
|
63
|
+
│ └── node_maps/ # デフォルト NodeMap 定義
|
|
64
|
+
│ ├── ruby.rb, hcl.rb, bash.rb, ...
|
|
33
65
|
└── textbringer_plugin.rb # エントリポイント
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
└── linux-x64/
|
|
66
|
+
exe/
|
|
67
|
+
└── textbringer-tree-sitter # CLI tool(parser 管理)
|
|
37
68
|
```
|
|
38
69
|
|
|
39
70
|
### 主要コンポーネント
|
|
40
71
|
|
|
41
|
-
- **TreeSitterAdapter**:
|
|
42
|
-
-
|
|
43
|
-
-
|
|
72
|
+
- **TreeSitterAdapter**:
|
|
73
|
+
- Window#highlight をモンキーパッチして `custom_highlight` に差し替え
|
|
74
|
+
- Mode クラスに `use_tree_sitter(:lang)` を提供(prepend で注入)
|
|
75
|
+
- Emacs 風 4 段階ハイライトレベル制御(HIGHLIGHT_LEVELS)
|
|
76
|
+
|
|
77
|
+
- **TreeSitterConfig**:
|
|
78
|
+
- プラットフォーム検出(darwin-arm64, linux-x64 等)
|
|
79
|
+
- Parser パス解決(CONFIG → ~/.textbringer/parsers → gem内 の優先順)
|
|
80
|
+
- デフォルト Face 定義(comment, string, keyword, ...)
|
|
81
|
+
|
|
82
|
+
- **NodeMaps**:
|
|
83
|
+
- 言語ごとの `node_type → face` マッピング辞書
|
|
84
|
+
- `register(:lang, mapping)` でレジストリに登録
|
|
85
|
+
- ユーザーカスタム NodeMap は `~/.textbringer/tree_sitter/node_maps/` に配置
|
|
44
86
|
|
|
45
87
|
### 依存関係
|
|
46
88
|
|
|
47
|
-
- `ruby_tree_sitter` (~> 2.0) -
|
|
89
|
+
- `ruby_tree_sitter` (~> 2.0) - LANGUAGE_VERSION 6-14 対応
|
|
48
90
|
- `textbringer` (>= 1.0)
|
|
49
91
|
|
|
50
|
-
|
|
92
|
+
### カスタマイズ設定(~/.textbringer.rb)
|
|
51
93
|
|
|
52
|
-
|
|
94
|
+
```ruby
|
|
95
|
+
# ハイライトレベル (1-4, default: 3)
|
|
96
|
+
CONFIG[:tree_sitter_highlight_level] = 4
|
|
53
97
|
|
|
54
|
-
|
|
98
|
+
# 個別 feature 選択(レベルより優先)
|
|
99
|
+
CONFIG[:tree_sitter_enabled_features] = [:comment, :string, :keyword]
|
|
55
100
|
|
|
101
|
+
# カスタム parser ディレクトリ
|
|
102
|
+
CONFIG[:tree_sitter_parser_dir] = "/path/to/parsers"
|
|
103
|
+
|
|
104
|
+
# カスタム NodeMap 読み込み
|
|
105
|
+
require "~/.textbringer/tree_sitter/node_maps/mylang.rb"
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## NodeMap の追加方法
|
|
109
|
+
|
|
110
|
+
新しい言語をサポートする手順:
|
|
111
|
+
|
|
112
|
+
1. **Parser インストール**
|
|
113
|
+
```bash
|
|
114
|
+
textbringer-tree-sitter get <lang> # 自動で node_map も生成される
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
2. **生成された NodeMap を確認・編集**
|
|
118
|
+
- `~/.textbringer/tree_sitter/node_maps/<lang>.rb` に生成される
|
|
119
|
+
- ヒューリスティックで推測されたマッピングをレビュー
|
|
120
|
+
- コメント化された unmapped nodes を必要に応じて追加
|
|
121
|
+
|
|
122
|
+
3. **~/.textbringer.rb で読み込み**
|
|
123
|
+
```ruby
|
|
124
|
+
require "~/.textbringer/tree_sitter/node_maps/<lang>.rb"
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
4. **gem にコントリビュート**(オプション)
|
|
128
|
+
- `lib/textbringer/tree_sitter/node_maps/<lang>.rb` に配置
|
|
129
|
+
- デフォルト NodeMap として同梱
|
|
130
|
+
|
|
131
|
+
## Tree-sitter Parser の互換性
|
|
132
|
+
|
|
133
|
+
### LANGUAGE_VERSION
|
|
134
|
+
|
|
135
|
+
ruby_tree_sitter 2.0.0 は **LANGUAGE_VERSION 6-14** をサポート。
|
|
136
|
+
|
|
137
|
+
ビルド前に互換性確認:
|
|
56
138
|
```bash
|
|
57
139
|
grep LANGUAGE_VERSION src/parser.c | head -1
|
|
58
140
|
```
|
|
59
141
|
|
|
60
|
-
### HCL
|
|
142
|
+
### 手動ビルド例(HCL)
|
|
61
143
|
|
|
62
|
-
|
|
144
|
+
CLI tool 使わずビルドする場合:
|
|
63
145
|
|
|
64
146
|
```bash
|
|
65
147
|
git clone https://github.com/mitchellh/tree-sitter-hcl.git
|
|
66
148
|
cd tree-sitter-hcl
|
|
67
149
|
c++ -shared -fPIC -O2 -std=c++14 -Isrc src/parser.c src/scanner.cc -o libtree-sitter-hcl.dylib
|
|
150
|
+
cp libtree-sitter-hcl.dylib ~/.textbringer/parsers/darwin-arm64/
|
|
68
151
|
```
|
|
69
152
|
|
|
70
|
-
### プリビルド parser の取得
|
|
71
|
-
|
|
72
|
-
Faveod/tree-sitter-parsers から取得可能:bash, c, javascript, json, python, ruby, rust 等
|
|
73
|
-
|
|
74
153
|
## 参考実装
|
|
75
154
|
|
|
76
155
|
- [textbringer-rouge](https://github.com/yancya/textbringer-rouge) - Window モンキーパッチの実装パターン
|
|
156
|
+
- [Faveod/tree-sitter-parsers](https://github.com/Faveod/tree-sitter-parsers) - prebuilt parsers の配布元
|
data/DISCLAIMER
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
DISCLAIMER
|
|
2
|
+
|
|
3
|
+
THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
4
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
5
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
6
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
7
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
8
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
9
|
+
SOFTWARE.
|
data/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
|
2
|
+
Version 2, December 2004
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2026 yancya <yancya@upec.jp>
|
|
5
|
+
|
|
6
|
+
Everyone is permitted to copy and distribute verbatim or modified
|
|
7
|
+
copies of this license document, and changing it is allowed as long
|
|
8
|
+
as the name is changed.
|
|
9
|
+
|
|
10
|
+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
|
11
|
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
12
|
+
|
|
13
|
+
0. You just DO WHAT THE FUCK YOU WANT TO.
|
data/README.md
CHANGED
|
@@ -15,20 +15,49 @@ Tree-sitter based syntax highlighting plugin for Textbringer.
|
|
|
15
15
|
gem 'textbringer-tree-sitter'
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
###
|
|
18
|
+
### Default Parsers
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
The following parsers are **automatically installed** during `gem install`:
|
|
21
|
+
|
|
22
|
+
- **ruby**
|
|
23
|
+
- **python**
|
|
24
|
+
- **javascript**
|
|
25
|
+
- **json**
|
|
26
|
+
- **bash**
|
|
27
|
+
|
|
28
|
+
These are downloaded from [Faveod/tree-sitter-parsers](https://github.com/Faveod/tree-sitter-parsers) and placed in `~/.textbringer/parsers/{platform}/`.
|
|
29
|
+
|
|
30
|
+
### Opt-out of Automatic Downloads
|
|
31
|
+
|
|
32
|
+
To skip automatic parser downloads (useful in offline or restricted environments), set the environment variable:
|
|
21
33
|
|
|
22
34
|
```bash
|
|
23
|
-
|
|
35
|
+
export TEXTBRINGER_TREE_SITTER_NO_DOWNLOAD=1
|
|
36
|
+
gem install textbringer-tree-sitter
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
When this variable is set:
|
|
40
|
+
- `gem install` will skip automatic parser downloads
|
|
41
|
+
- CLI commands (`get`, `get-all`) will refuse to download with an error message
|
|
42
|
+
- You can still manually place parsers in `~/.textbringer/parsers/{platform}/`
|
|
43
|
+
|
|
44
|
+
### Installing Additional Parsers
|
|
45
|
+
|
|
46
|
+
Use the CLI tool to install additional parsers:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# List available parsers and their installation status
|
|
24
50
|
textbringer-tree-sitter list
|
|
25
51
|
|
|
26
52
|
# Install a specific parser (downloads prebuilt or builds from source)
|
|
27
|
-
|
|
53
|
+
# Also generates a node_map if one doesn't exist in the gem
|
|
28
54
|
textbringer-tree-sitter get hcl
|
|
29
55
|
textbringer-tree-sitter get markdown
|
|
30
56
|
|
|
31
|
-
# Install
|
|
57
|
+
# Install parser only, skip node_map generation
|
|
58
|
+
textbringer-tree-sitter get markdown --no-map
|
|
59
|
+
|
|
60
|
+
# Install all Faveod prebuilt parsers at once
|
|
32
61
|
textbringer-tree-sitter get-all
|
|
33
62
|
```
|
|
34
63
|
|
|
@@ -43,7 +72,16 @@ textbringer-tree-sitter path
|
|
|
43
72
|
|
|
44
73
|
## Usage
|
|
45
74
|
|
|
46
|
-
|
|
75
|
+
### Automatic Highlighting
|
|
76
|
+
|
|
77
|
+
Once a parser is installed and a node_map exists for the language, syntax highlighting is automatically enabled for the corresponding Mode (e.g., RubyMode, PythonMode, HCLMode).
|
|
78
|
+
|
|
79
|
+
The `get` command:
|
|
80
|
+
1. Downloads or builds the parser
|
|
81
|
+
2. Automatically generates a node_map if one doesn't exist in the gem
|
|
82
|
+
3. Places the node_map in `~/.textbringer/tree_sitter/node_maps/`
|
|
83
|
+
|
|
84
|
+
### Custom Modes
|
|
47
85
|
|
|
48
86
|
For custom Modes, call `use_tree_sitter`:
|
|
49
87
|
|
|
@@ -54,6 +92,59 @@ class MyMode < ProgrammingMode
|
|
|
54
92
|
end
|
|
55
93
|
```
|
|
56
94
|
|
|
95
|
+
## Custom Languages
|
|
96
|
+
|
|
97
|
+
You can add languages not included in the gem by creating a configuration file.
|
|
98
|
+
|
|
99
|
+
### 1. Initialize config file
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
textbringer-tree-sitter init
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
This creates `~/.textbringer/tree_sitter/languages.yml`.
|
|
106
|
+
|
|
107
|
+
### 2. Edit the configuration file
|
|
108
|
+
|
|
109
|
+
```yaml
|
|
110
|
+
# Simple format (minimal config)
|
|
111
|
+
elixir:
|
|
112
|
+
repo: elixir-lang/tree-sitter-elixir
|
|
113
|
+
|
|
114
|
+
# Detailed format (full control)
|
|
115
|
+
zig:
|
|
116
|
+
repo: maxxnino/tree-sitter-zig
|
|
117
|
+
branch: master
|
|
118
|
+
commit: abc123 # Optional: pin to specific commit
|
|
119
|
+
subdir: "" # Optional: subdirectory within repo
|
|
120
|
+
build_cmd: "cc -shared -fPIC -O2 -I{src}/src {src}/src/parser.c -o {output}"
|
|
121
|
+
|
|
122
|
+
# Use a fork instead of curated version
|
|
123
|
+
ruby:
|
|
124
|
+
repo: my-username/tree-sitter-ruby
|
|
125
|
+
branch: experimental
|
|
126
|
+
|
|
127
|
+
# Use Faveod prebuilt parser
|
|
128
|
+
groovy:
|
|
129
|
+
source: faveod
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### 3. Install the language
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
textbringer-tree-sitter get elixir
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
The custom language will override any curated language with the same name.
|
|
139
|
+
|
|
140
|
+
### 4. List all languages
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
textbringer-tree-sitter list
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
This shows both curated (built-in) and user-defined languages.
|
|
147
|
+
|
|
57
148
|
## Customization
|
|
58
149
|
|
|
59
150
|
### Highlight Level (Emacs-style)
|
|
@@ -91,26 +182,59 @@ CONFIG[:tree_sitter_parser_dir] = "/path/to/your/parsers"
|
|
|
91
182
|
|
|
92
183
|
## Supported Languages
|
|
93
184
|
|
|
94
|
-
###
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
|
101
|
-
|
|
102
|
-
|
|
|
103
|
-
|
|
|
104
|
-
|
|
|
105
|
-
|
|
|
106
|
-
|
|
|
107
|
-
|
|
|
108
|
-
|
|
|
185
|
+
### Ready to Use (Prebuilt + Node Map Included)
|
|
186
|
+
|
|
187
|
+
These parsers are available from Faveod and include node_maps in the gem:
|
|
188
|
+
|
|
189
|
+
| Language | Auto-installed on `gem install` | Command |
|
|
190
|
+
|----------|--------------------------------|---------|
|
|
191
|
+
| bash | ✅ | `textbringer-tree-sitter get bash` |
|
|
192
|
+
| c | | `textbringer-tree-sitter get c` |
|
|
193
|
+
| c-sharp | | `textbringer-tree-sitter get c-sharp` |
|
|
194
|
+
| cobol | | `textbringer-tree-sitter get cobol` |
|
|
195
|
+
| embedded-template | | `textbringer-tree-sitter get embedded-template` |
|
|
196
|
+
| groovy | | `textbringer-tree-sitter get groovy` |
|
|
197
|
+
| haml | | `textbringer-tree-sitter get haml` |
|
|
198
|
+
| html | | `textbringer-tree-sitter get html` |
|
|
199
|
+
| java | | `textbringer-tree-sitter get java` |
|
|
200
|
+
| javascript | ✅ | `textbringer-tree-sitter get javascript` |
|
|
201
|
+
| json | ✅ | `textbringer-tree-sitter get json` |
|
|
202
|
+
| pascal | | `textbringer-tree-sitter get pascal` |
|
|
203
|
+
| php | | `textbringer-tree-sitter get php` |
|
|
204
|
+
| python | ✅ | `textbringer-tree-sitter get python` |
|
|
205
|
+
| ruby | ✅ | `textbringer-tree-sitter get ruby` |
|
|
206
|
+
| rust | | `textbringer-tree-sitter get rust` |
|
|
207
|
+
|
|
208
|
+
### Build-required (Node Map Included)
|
|
209
|
+
|
|
210
|
+
These parsers require building from source but include node_maps:
|
|
211
|
+
|
|
212
|
+
| Language | Command | Repository |
|
|
213
|
+
|----------|---------|------------|
|
|
214
|
+
| HCL (Terraform) | `textbringer-tree-sitter get hcl` | mitchellh/tree-sitter-hcl |
|
|
215
|
+
| YAML | `textbringer-tree-sitter get yaml` | tree-sitter-grammars/tree-sitter-yaml |
|
|
216
|
+
| SQL | `textbringer-tree-sitter get sql` | m-novikov/tree-sitter-sql |
|
|
217
|
+
|
|
218
|
+
### Build-required (Node Map Not Included)
|
|
219
|
+
|
|
220
|
+
These parsers require building from source and node_map generation:
|
|
221
|
+
|
|
222
|
+
| Language | Command | Note |
|
|
223
|
+
|----------|---------|------|
|
|
224
|
+
| Go | `textbringer-tree-sitter get go` | Generates node_map in `~/.textbringer/tree_sitter/node_maps/` |
|
|
225
|
+
| TypeScript | `textbringer-tree-sitter get typescript` | Generates node_map in `~/.textbringer/tree_sitter/node_maps/` |
|
|
226
|
+
| TSX | `textbringer-tree-sitter get tsx` | Generates node_map in `~/.textbringer/tree_sitter/node_maps/` |
|
|
227
|
+
| Markdown | `textbringer-tree-sitter get markdown` | Generates node_map in `~/.textbringer/tree_sitter/node_maps/` |
|
|
228
|
+
|
|
229
|
+
To regenerate a node_map manually:
|
|
230
|
+
```bash
|
|
231
|
+
textbringer-tree-sitter generate-map <language>
|
|
232
|
+
```
|
|
109
233
|
|
|
110
234
|
## License
|
|
111
235
|
|
|
112
|
-
WTFPL - See LICENSE
|
|
236
|
+
WTFPL - See [LICENSE](LICENSE) for details.
|
|
113
237
|
|
|
114
238
|
## Disclaimer
|
|
115
239
|
|
|
116
|
-
|
|
240
|
+
See [DISCLAIMER](DISCLAIMER) for details.
|
data/Rakefile
CHANGED
|
@@ -9,4 +9,21 @@ Rake::TestTask.new(:test) do |t|
|
|
|
9
9
|
t.test_files = FileList["test/**/test_*.rb"]
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
+
namespace :parsers do
|
|
13
|
+
desc "Download prebuilt parsers for CI (ruby, hcl, markdown)"
|
|
14
|
+
task :download do
|
|
15
|
+
sh "bash scripts/download_parsers.sh ruby hcl markdown"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
desc "Build parsers from source (HCL, Ruby)"
|
|
19
|
+
task :build do
|
|
20
|
+
sh "bash scripts/build_parsers.sh"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
desc "Setup parsers for testing (downloads if available, falls back to build)"
|
|
24
|
+
task :setup do
|
|
25
|
+
sh "bash scripts/download_parsers.sh ruby hcl markdown || bash scripts/build_parsers.sh"
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
12
29
|
task default: :test
|