diff --git a/extension.toml b/extension.toml index 8900e27..23bd217 100644 --- a/extension.toml +++ b/extension.toml @@ -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" diff --git a/languages/empirical/config.toml b/languages/empirical/config.toml new file mode 100644 index 0000000..c6e85e4 --- /dev/null +++ b/languages/empirical/config.toml @@ -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"] diff --git a/languages/empirical/highlights.scm b/languages/empirical/highlights.scm new file mode 100644 index 0000000..2a01594 --- /dev/null +++ b/languages/empirical/highlights.scm @@ -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) diff --git a/languages/empirical/outline.scm b/languages/empirical/outline.scm new file mode 100644 index 0000000..991beb2 --- /dev/null +++ b/languages/empirical/outline.scm @@ -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)) diff --git a/languages/ruby/injections.scm b/languages/ruby/injections.scm index 3ad8143..76717cc 100644 --- a/languages/ruby/injections.scm +++ b/languages/ruby/injections.scm @@ -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") +)