diff options
Diffstat (limited to 'runtime/queries')
-rw-r--r-- | runtime/queries/elixir/textobjects.scm | 8 | ||||
-rw-r--r-- | runtime/queries/erlang/textobjects.scm | 8 | ||||
-rw-r--r-- | runtime/queries/gleam/textobjects.scm | 5 | ||||
-rw-r--r-- | runtime/queries/go/textobjects.scm | 5 | ||||
-rw-r--r-- | runtime/queries/javascript/injections.scm | 12 | ||||
-rw-r--r-- | runtime/queries/jsdoc/injections.scm | 5 | ||||
-rw-r--r-- | runtime/queries/python/textobjects.scm | 5 | ||||
-rw-r--r-- | runtime/queries/rust/textobjects.scm | 14 |
8 files changed, 59 insertions, 3 deletions
diff --git a/runtime/queries/elixir/textobjects.scm b/runtime/queries/elixir/textobjects.scm index 52a6f66d..227a52f4 100644 --- a/runtime/queries/elixir/textobjects.scm +++ b/runtime/queries/elixir/textobjects.scm @@ -16,7 +16,7 @@ (pair value: (_) @function.inside))?)? (do_block (_)* @function.inside)?) - (#match? @_keyword "^(def|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp|defp|test|describe|setup)$")) @function.around + (#match? @_keyword "^(def|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp|defp)$")) @function.around (anonymous_function (stab_clause right: (body) @function.inside)) @function.around @@ -25,3 +25,9 @@ target: (identifier) @_keyword (do_block (_)* @class.inside)) (#match? @_keyword "^(defmodule|defprotocol|defimpl)$")) @class.around + +((call + target: (identifier) @_keyword + (arguments ((string) . (_)?)) + (do_block (_)* @test.inside)?) + (#match? @_keyword "^(test|describe)$")) @test.around diff --git a/runtime/queries/erlang/textobjects.scm b/runtime/queries/erlang/textobjects.scm index c46b5c6f..013629f8 100644 --- a/runtime/queries/erlang/textobjects.scm +++ b/runtime/queries/erlang/textobjects.scm @@ -6,3 +6,11 @@ (stab_clause body: (_) @function.inside)) @function.around (comment (comment_content) @comment.inside) @comment.around + +; EUnit test names. +; (CommonTest cases are not recognizable by syntax alone.) +((function_clause + name: (atom) @_name + pattern: (arguments (_)? @parameter.inside) + body: (_) @test.inside) @test.around + (#match? @_name "_test$")) diff --git a/runtime/queries/gleam/textobjects.scm b/runtime/queries/gleam/textobjects.scm index b382f4bd..19cd0dcf 100644 --- a/runtime/queries/gleam/textobjects.scm +++ b/runtime/queries/gleam/textobjects.scm @@ -4,3 +4,8 @@ (anonymous_function body: (function_body) @function.inside) @function.around + +((function + name: (identifier) @_name + body: (function_body) @test.inside) @test.around + (#match? @_name "_test$")) diff --git a/runtime/queries/go/textobjects.scm b/runtime/queries/go/textobjects.scm index a48ccce1..df1b0866 100644 --- a/runtime/queries/go/textobjects.scm +++ b/runtime/queries/go/textobjects.scm @@ -26,3 +26,8 @@ (comment) @comment.inside (comment)+ @comment.around + +((function_declaration + name: (identifier) @_name + body: (block)? @test.inside) @test.around + (#match? @_name "^Test")) diff --git a/runtime/queries/javascript/injections.scm b/runtime/queries/javascript/injections.scm index e8429111..af3aef10 100644 --- a/runtime/queries/javascript/injections.scm +++ b/runtime/queries/javascript/injections.scm @@ -22,7 +22,15 @@ ((regex_pattern) @injection.content (#set! injection.language "regex")) - ; Parse JSDoc annotations in comments +; Parse JSDoc annotations in multiline comments ((comment) @injection.content - (#set! injection.language "jsdoc")) + (#set! injection.language "jsdoc") + (#match? @injection.content "^/\\*+")) + +; Parse general tags in single line comments + +((comment) @injection.content + (#set! injection.language "comment") + (#match? @injection.content "^//")) + diff --git a/runtime/queries/jsdoc/injections.scm b/runtime/queries/jsdoc/injections.scm new file mode 100644 index 00000000..877b671d --- /dev/null +++ b/runtime/queries/jsdoc/injections.scm @@ -0,0 +1,5 @@ +; Parse general comment tags + +((document) @injection.content + (#set! injection.include-children) + (#set! injection.language "comment"))
\ No newline at end of file diff --git a/runtime/queries/python/textobjects.scm b/runtime/queries/python/textobjects.scm index 5c6a61d1..966e4744 100644 --- a/runtime/queries/python/textobjects.scm +++ b/runtime/queries/python/textobjects.scm @@ -16,3 +16,8 @@ (comment) @comment.inside (comment)+ @comment.around + +((function_definition + name: (identifier) @_name + body: (block)? @test.inside) @test.around + (#match? @_name "^test_")) diff --git a/runtime/queries/rust/textobjects.scm b/runtime/queries/rust/textobjects.scm index ba86050b..94c8c9f8 100644 --- a/runtime/queries/rust/textobjects.scm +++ b/runtime/queries/rust/textobjects.scm @@ -77,3 +77,17 @@ (line_comment)+ @comment.around (block_comment) @comment.around + +(; #[test] + (attribute_item + (meta_item + (identifier) @_test_attribute)) + ; allow other attributes like #[should_panic] and comments + [ + (attribute_item) + (line_comment) + ]* + ; the test function + (function_item + body: (_) @test.inside) @test.around + (#eq? @_test_attribute "test")) |