Skip to content
Merged
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
70 changes: 70 additions & 0 deletions .tsqueryrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"$schema": "https://raw.githubusercontent.com/ribru17/ts_query_ls/refs/heads/master/schemas/config.json",
"parser_install_directories": ["./grammars"],
"language_retrieval_patterns": ["languages/([^/]+)/[^/]+\\.scm"],
"parser_aliases": {
"erb": "embedded_template",
"html-erb": "embedded_template",
"js-erb": "embedded_template",
"yaml-erb": "embedded_template"
},
"valid_captures": {
"highlights": {
"attribute": "An attribute",
"boolean": "A boolean value",
"comment": "A comment",
"comment.doc": "A documentation comment",
"constant": "A constant",
"constant.builtin": "A built-in constant",
"constructor": "A constructor",
"embedded": "Embedded content",
"emphasis": "Emphasized text",
"emphasis.strong": "Strongly emphasized text",
"enum": "An enumeration",
"function": "A function",
"function.builtin": "A built-in function",
"function.method": "A method",
"function.method.builtin": "A built-in method",
"hint": "A hint",
"keyword": "A keyword",
"keyword.exception": "A keyword for exception handling",
"keyword.import": "An import keyword",
"label": "A label",
"link_text": "Link text",
"link_uri": "A link URI",
"number": "A numeric value",
"operator": "An operator",
"predictive": "Predictive text",
"preproc": "A preprocessor directive",
"primary": "A primary element",
"property": "A property",
"punctuation": "Punctuation",
"punctuation.bracket": "A bracket",
"punctuation.delimiter": "A delimiter",
"punctuation.list_marker": "A list marker",
"punctuation.special": "Special punctuation",
"string": "A string literal",
"string.escape": "An escaped character in a string",
"string.regex": "A regular expression",
"string.special": "A special string",
"string.special.symbol": "A special symbol",
"tag": "A tag",
"tag.doctype": "A doctype (e.g., in HTML)",
"text.literal": "Literal text",
"title": "A title",
"type": "A type",
"type.super": "A superclass type",
"variable": "A variable",
"variable.parameter": "A function or method parameter",
"variable.special": "A special variable",
"variant": "A variant"
},
"runnables": {
"name": "Captures the \"scripts\" key",
"run": "Captures the script name",
"script": "Also captures the script name (for different purposes)",
"RUBY_TEST_NAME": "A ruby test name",
"_ruby-test": "A ruby test name"
}
}
}
14 changes: 11 additions & 3 deletions languages/rbs/indents.scm
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@
(record_type)
] @indent.begin

(_ "[" "]" @end) @indent
(_ "{" "}" @end) @indent
(_ "(" ")" @end) @indent
(_
"["
"]" @end) @indent

(_
"{"
"}" @end) @indent

(_
"("
")" @end) @indent

(comment) @indent.ignore
63 changes: 48 additions & 15 deletions languages/ruby/brackets.scm
Original file line number Diff line number Diff line change
@@ -1,15 +1,48 @@
("(" @open ")" @close)
("[" @open "]" @close)
("{" @open "}" @close)
("\"" @open "\"" @close)
("do" @open "end" @close)

(block_parameters "|" @open "|" @close)
(interpolation "#{" @open "}" @close)

(if "if" @open "end" @close)
(unless "unless" @open "end" @close)
(begin "begin" @open "end" @close)
(module "module" @open "end" @close)
(_ . "def" @open "end" @close)
(_ . "class" @open "end" @close)
("(" @open
")" @close)

("[" @open
"]" @close)

("{" @open
"}" @close)

("\"" @open
"\"" @close)

("do" @open
"end" @close)

(block_parameters
"|" @open
"|" @close)

(interpolation
"#{" @open
"}" @close)

(if
"if" @open
"end" @close)

(unless
"unless" @open
"end" @close)

(begin
"begin" @open
"end" @close)

(module
"module" @open
"end" @close)

(_
.
"def" @open
"end" @close)

(_
.
"class" @open
"end" @close)
38 changes: 30 additions & 8 deletions languages/ruby/debugger.scm
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
(assignment left: (identifier) @debug-variable)
(assignment left: (call receiver: (identifier) @debug-variable))
(assignment left: (call method: (identifier) @debug-variable))
(call (argument_list (call receiver: (identifier) @debug-variable)))
(call (argument_list (call method: (identifier) @debug-variable)))
(assignment
left: (identifier) @debug-variable)

(call (argument_list (identifier) @debug-variable))
(assignment
left: (call
receiver: (identifier) @debug-variable))

(method (method_parameters) @debug-variable)
(body_statement (assignment (instance_variable) @debug-variable))
(assignment
left: (call
method: (identifier) @debug-variable))

(call
(argument_list
(call
receiver: (identifier) @debug-variable)))

(call
(argument_list
(call
method: (identifier) @debug-variable)))

(call
(argument_list
(identifier) @debug-variable))

(method
(method_parameters) @debug-variable)

(body_statement
(assignment
(instance_variable) @debug-variable))

(program) @debug-scope

(body_statement) @debug-scope
42 changes: 20 additions & 22 deletions languages/ruby/embedding.scm
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
(
(comment)* @context
.
[
(module
"module" @name
name: (_) @name)
(method
"def" @name
name: (_) @name
body: (body_statement) @collapse)
(class
"class" @name
name: (_) @name)
(singleton_method
"def" @name
object: (_) @name
"." @name
name: (_) @name
body: (body_statement) @collapse)
] @item
)
((comment)* @context
.
[
(module
"module" @name
name: (_) @name)
(method
"def" @name
name: (_) @name
body: (body_statement) @collapse)
(class
"class" @name
name: (_) @name)
(singleton_method
"def" @name
object: (_) @name
"." @name
name: (_) @name
body: (body_statement) @collapse)
] @item)
63 changes: 41 additions & 22 deletions languages/ruby/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
] @variable

; Keywords

[
"alias"
"and"
Expand Down Expand Up @@ -40,41 +39,63 @@
(#match? @keyword "^(private|protected|public)$"))

; Function calls

(call
method: [(identifier) (constant)] @function.method)
method: [
(identifier)
(constant)
] @function.method)

((identifier) @keyword.import
(#any-of? @keyword.import "require" "require_relative" "load"))
(#any-of? @keyword.import "require" "require_relative" "load"))

"defined?" @function.method.builtin

; Function definitions

(alias (identifier) @function.method)
(setter (identifier) @function.method)
(method name: [(identifier) (constant)] @function.method)
(singleton_method name: [(identifier) (constant)] @function.method)
(method_parameters [
(identifier) @variable.parameter
(optional_parameter name: (identifier) @variable.parameter)
(keyword_parameter [name: (identifier) (":")] @variable.parameter)
(alias
(identifier) @function.method)

(setter
(identifier) @function.method)

(method
name: [
(identifier)
(constant)
] @function.method)

(singleton_method
name: [
(identifier)
(constant)
] @function.method)

(method_parameters
[
(identifier) @variable.parameter
(optional_parameter
name: (identifier) @variable.parameter)
(keyword_parameter
[
name: (identifier)
":"
] @variable.parameter)
])

(block_parameters (identifier) @variable.parameter)
(block_parameters
(identifier) @variable.parameter)

; Identifiers

((identifier) @constant.builtin
(#match? @constant.builtin "^__(FILE|LINE|ENCODING)__$"))

(file) @constant.builtin

(line) @constant.builtin

(encoding) @constant.builtin

(hash_splat_nil
"**" @operator
) @constant.builtin
"**" @operator) @constant.builtin

(constant) @type

Expand All @@ -94,6 +115,7 @@
(constant) @type.super)))

(self) @variable.special

(super) @variable.special

[
Expand All @@ -110,7 +132,6 @@
(#any-of? @keyword.exception "raise" "fail" "catch" "throw"))

; Literals

[
(string)
(bare_string)
Expand All @@ -127,6 +148,7 @@
] @string.special.symbol

(regex) @string.regex

(escape_sequence) @string.escape

[
Expand All @@ -139,17 +161,14 @@
(false)
] @boolean

[
(nil)
] @constant.builtin
(nil) @constant.builtin

; Regular comments (exclude RBS inline comments)
((comment) @comment
(#not-match? @comment "^\\s*#[:|]")
(#not-match? @comment "^\\s*#\\s*(@rbs|\\|)"))

; Operators

[
"!"
"~"
Expand Down
Loading