Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions extension.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ commit = "c70c1de07dedd532089c0c90835c8ed9fa694f5c"
repository = "https://github.com/joker1007/tree-sitter-rbs"
commit = "de893b166476205b09e79cd3689f95831269579a"

[grammars.empirical]
repository = "https://github.com/vitallium/tree-sitter-empirical"
commit = "6a95f84161c0409eac5b667a1a2e5eb95e5cf787"

[[capabilities]]
kind = "process:exec"
command = "gem"
Expand Down
27 changes: 27 additions & 0 deletions languages/empirical/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name = "Empirical"
grammar = "empirical"
path_suffixes = ["rb"]
first_line_pattern = '^#!.*\bruby\b'
line_comments = ["# "]
autoclose_before = ";:.,=}])>"
brackets = [
{ start = "{", end = "}", close = true, newline = true },
{ start = "[", end = "]", close = true, newline = true },
{ start = "(", end = ")", close = true, newline = true },
{ start = "\"", end = "\"", close = true, newline = false, not_in = [
"comment",
"string",
] },
{ start = "'", end = "'", close = true, newline = false, not_in = [
"comment",
"string",
] },
]
collapsed_placeholder = "# ..."
tab_size = 2
scope_opt_in_language_servers = ["tailwindcss-language-server"]
word_characters = ["?", "!"]

[overrides.string]
completion_query_characters = ["-", "."]
opt_into_language_servers = ["tailwindcss-language-server"]
23 changes: 23 additions & 0 deletions languages/empirical/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
; Empirical-specific syntax highlighting
; NOTE: Ruby base syntax is handled by the Ruby grammar
; This file ONLY highlights Empirical extensions

; EMPIRICAL: 'fun' keyword
"fun" @keyword.function

; EMPIRICAL: Function name in empirical_fun_method
(empirical_fun_method
name: [(identifier) (constant)] @function.method)

; EMPIRICAL: Type annotations in parameters
(empirical_parameter
name: (identifier) @variable.parameter
type: (empirical_type) @type)

; EMPIRICAL: Return type annotations
(empirical_return_type
type: (empirical_type) @type)

; EMPIRICAL: Generic type names (e.g., _Hash, _Array)
(empirical_generic_type
name: (constant) @type.builtin)
23 changes: 23 additions & 0 deletions languages/empirical/outline.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
; Empirical outline - show fun methods in document outline

; EMPIRICAL: fun method definitions
(empirical_fun_method
name: (identifier) @name) @item

; EMPIRICAL: fun method with "fun" keyword as context
(empirical_fun_method
"fun" @context
name: (identifier) @name) @item

; EMPIRICAL: fun method in class/module context
(class
(body_statement
(empirical_fun_method
"fun" @context
name: (identifier) @name) @item))

(module
(body_statement
(empirical_fun_method
"fun" @context
name: (identifier) @name) @item))
9 changes: 9 additions & 0 deletions languages/ruby/injections.scm
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@
((regex
(string_content) @content)
(#set! "language" "regex"))

; Empirical type system support
(body_statement
(call
method: (identifier) @_name (#any-of? @_name "fun")
arguments: (_)
) @content
(#set! "language" "empirical")
)