textbringer-tree-sitter 1.2.6 → 1.2.7
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/lib/textbringer/tree_sitter/node_maps/ruby.rb +9 -3
- data/lib/textbringer/tree_sitter/version.rb +1 -1
- data/lib/textbringer/tree_sitter_adapter.rb +4 -18
- data/samples/sample.js +2 -0
- data/samples/sample.py +2 -0
- data/samples/sample.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 649cf41ebba5efaacc1cfc1ebfa454f9941b66e5e0fe3206250697c01c5f5950
|
|
4
|
+
data.tar.gz: f6e5156b025e11d6f2f874ac1be0ea46bb39d8a68330e64952712f6554b17368
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fc5e34861227bf37ab47a3f1997d148a8723955791312ce31cf4fa3afc792d038f5ef32ca347ac9041eabd3f6d24ecbf614351c89be261cd86fd39e289cd87bf
|
|
7
|
+
data.tar.gz: 50adec53e1fc7d8d821a7891dccb2080e09bb5d46308189ec944e49d5d7afdd9f66258b40b437649f6c4cb7af89f0c59365a0ae2dac8b9c049c34dbad9ac88a6
|
|
@@ -74,11 +74,17 @@ module Textbringer
|
|
|
74
74
|
instance_variable
|
|
75
75
|
class_variable
|
|
76
76
|
global_variable
|
|
77
|
+
forward_argument
|
|
78
|
+
forward_parameter
|
|
77
79
|
],
|
|
78
80
|
type: %i[],
|
|
79
|
-
operator: %i[
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
operator: %i[
|
|
82
|
+
operator
|
|
83
|
+
],
|
|
84
|
+
punctuation: %i[
|
|
85
|
+
empty_statement
|
|
86
|
+
],
|
|
87
|
+
builtin: %i[nil true false hash_splat_nil],
|
|
82
88
|
property: %i[]
|
|
83
89
|
}.freeze
|
|
84
90
|
|
|
@@ -73,18 +73,13 @@ module Textbringer
|
|
|
73
73
|
|
|
74
74
|
attrs = Face[face]&.attributes
|
|
75
75
|
if attrs
|
|
76
|
-
# Tree-sitter
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
end_char = byte_offset_to_char_offset(buffer_text, end_byte)
|
|
80
|
-
|
|
81
|
-
# base_pos + offset でバッファ内の絶対位置を計算
|
|
82
|
-
highlight_on[base_pos + start_char] = attrs
|
|
83
|
-
highlight_off[base_pos + end_char] = attrs
|
|
76
|
+
# Tree-sitter も Textbringer もバイトオフセットを使う
|
|
77
|
+
highlight_on[base_pos + start_byte] = attrs
|
|
78
|
+
highlight_off[base_pos + end_byte] = attrs
|
|
84
79
|
|
|
85
80
|
if TreeSitterAdapter.debug? && highlight_on.size <= 5
|
|
86
81
|
File.open("/tmp/tree_sitter_debug.log", "a") do |f|
|
|
87
|
-
f.puts " #{node.type} pos=#{base_pos +
|
|
82
|
+
f.puts " #{node.type} pos=#{base_pos + start_byte}-#{base_pos + end_byte} face=#{face}"
|
|
88
83
|
end
|
|
89
84
|
end
|
|
90
85
|
end
|
|
@@ -202,15 +197,6 @@ module Textbringer
|
|
|
202
197
|
HIGHLIGHT_LEVELS.take(level).flatten
|
|
203
198
|
end
|
|
204
199
|
|
|
205
|
-
# Tree-sitter の byte offset を Textbringer の character offset に変換
|
|
206
|
-
# UTF-8 multibyte 文字対応のために必要
|
|
207
|
-
def byte_offset_to_char_offset(string, byte_offset)
|
|
208
|
-
return 0 if byte_offset <= 0
|
|
209
|
-
return string.length if byte_offset >= string.bytesize
|
|
210
|
-
|
|
211
|
-
# byte_offset までの部分文字列の文字数を返す
|
|
212
|
-
string.byteslice(0, byte_offset).length
|
|
213
|
-
end
|
|
214
200
|
end
|
|
215
201
|
end
|
|
216
202
|
|
data/samples/sample.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// Line comment
|
|
2
|
+
// 日本語のコメント
|
|
2
3
|
/* Block comment */
|
|
3
4
|
/** JSDoc comment */
|
|
4
5
|
|
|
@@ -8,6 +9,7 @@ let count = 0;
|
|
|
8
9
|
var legacy = "old style";
|
|
9
10
|
|
|
10
11
|
// --- Strings ---
|
|
12
|
+
const greeting = "こんにちは世界";
|
|
11
13
|
const simple = "double quoted";
|
|
12
14
|
const single = 'single quoted';
|
|
13
15
|
const template = `Hello, ${count + 1} world!`;
|
data/samples/sample.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# Single line comment
|
|
2
|
+
# 日本語のコメント
|
|
2
3
|
|
|
3
4
|
"""
|
|
4
5
|
Module docstring.
|
|
@@ -38,6 +39,7 @@ complex_val = 3 + 4j
|
|
|
38
39
|
separator = 1_000_000
|
|
39
40
|
|
|
40
41
|
# --- Strings ---
|
|
42
|
+
greeting = "こんにちは世界"
|
|
41
43
|
single = 'single quoted'
|
|
42
44
|
double = "double quoted"
|
|
43
45
|
triple_single = '''
|
data/samples/sample.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# Single line comment
|
|
4
|
+
# 日本語のコメント
|
|
4
5
|
|
|
5
6
|
=begin
|
|
6
7
|
Multi-line
|
|
@@ -62,6 +63,7 @@ end
|
|
|
62
63
|
end
|
|
63
64
|
|
|
64
65
|
# --- Strings ---
|
|
66
|
+
greeting = "こんにちは世界"
|
|
65
67
|
single = 'single quoted'
|
|
66
68
|
double = "double quoted with #{1 + 2} interpolation"
|
|
67
69
|
heredoc = <<~HEREDOC
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: textbringer-tree-sitter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.2.
|
|
4
|
+
version: 1.2.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- yancya
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-02-
|
|
11
|
+
date: 2026-02-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: textbringer
|