Skip to content

Commit 1021c4c

Browse files
committed
feat(empirical): proof of concept for the Empirical lang
1 parent abd9665 commit 1021c4c

File tree

5 files changed

+86
-0
lines changed

5 files changed

+86
-0
lines changed

extension.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ commit = "c70c1de07dedd532089c0c90835c8ed9fa694f5c"
5050
repository = "https://github.com/joker1007/tree-sitter-rbs"
5151
commit = "de893b166476205b09e79cd3689f95831269579a"
5252

53+
[grammars.empirical]
54+
repository = "https://github.com/vitallium/tree-sitter-empirical"
55+
commit = "6a95f84161c0409eac5b667a1a2e5eb95e5cf787"
56+
5357
[[capabilities]]
5458
kind = "process:exec"
5559
command = "gem"

languages/empirical/config.toml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name = "Empirical"
2+
grammar = "empirical"
3+
path_suffixes = ["rb"]
4+
first_line_pattern = '^#!.*\bruby\b'
5+
line_comments = ["# "]
6+
autoclose_before = ";:.,=}])>"
7+
brackets = [
8+
{ start = "{", end = "}", close = true, newline = true },
9+
{ start = "[", end = "]", close = true, newline = true },
10+
{ start = "(", end = ")", close = true, newline = true },
11+
{ start = "\"", end = "\"", close = true, newline = false, not_in = [
12+
"comment",
13+
"string",
14+
] },
15+
{ start = "'", end = "'", close = true, newline = false, not_in = [
16+
"comment",
17+
"string",
18+
] },
19+
]
20+
collapsed_placeholder = "# ..."
21+
tab_size = 2
22+
scope_opt_in_language_servers = ["tailwindcss-language-server"]
23+
word_characters = ["?", "!"]
24+
25+
[overrides.string]
26+
completion_query_characters = ["-", "."]
27+
opt_into_language_servers = ["tailwindcss-language-server"]

languages/empirical/highlights.scm

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
; Empirical-specific syntax highlighting
2+
; NOTE: Ruby base syntax is handled by the Ruby grammar
3+
; This file ONLY highlights Empirical extensions
4+
5+
; EMPIRICAL: 'fun' keyword
6+
"fun" @keyword.function
7+
8+
; EMPIRICAL: Function name in empirical_fun_method
9+
(empirical_fun_method
10+
name: [(identifier) (constant)] @function.method)
11+
12+
; EMPIRICAL: Type annotations in parameters
13+
(empirical_parameter
14+
name: (identifier) @variable.parameter
15+
type: (empirical_type) @type)
16+
17+
; EMPIRICAL: Return type annotations
18+
(empirical_return_type
19+
type: (empirical_type) @type)
20+
21+
; EMPIRICAL: Generic type names (e.g., _Hash, _Array)
22+
(empirical_generic_type
23+
name: (constant) @type.builtin)

languages/empirical/outline.scm

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
; Empirical outline - show fun methods in document outline
2+
3+
; EMPIRICAL: fun method definitions
4+
(empirical_fun_method
5+
name: (identifier) @name) @item
6+
7+
; EMPIRICAL: fun method with "fun" keyword as context
8+
(empirical_fun_method
9+
"fun" @context
10+
name: (identifier) @name) @item
11+
12+
; EMPIRICAL: fun method in class/module context
13+
(class
14+
(body_statement
15+
(empirical_fun_method
16+
"fun" @context
17+
name: (identifier) @name) @item))
18+
19+
(module
20+
(body_statement
21+
(empirical_fun_method
22+
"fun" @context
23+
name: (identifier) @name) @item))

languages/ruby/injections.scm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,12 @@
66
((regex
77
(string_content) @content)
88
(#set! "language" "regex"))
9+
10+
; Empirical type system support
11+
(body_statement
12+
(call
13+
method: (identifier) @_name (#any-of? @_name "fun")
14+
arguments: (_)
15+
) @content
16+
(#set! "language" "empirical")
17+
)

0 commit comments

Comments
 (0)