Skip to content

Commit

Permalink
Add textobject for javascript (#3213)
Browse files Browse the repository at this point in the history
  • Loading branch information
erasin committed Jul 28, 2022
1 parent cca83af commit 681c0a9
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 4 deletions.
8 changes: 4 additions & 4 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
| idris | | | | `idris2-lsp` |
| iex || | | |
| java || | | `jdtls` |
| javascript || || `typescript-language-server` |
| javascript || || `typescript-language-server` |
| jsdoc || | | |
| json || || `vscode-json-language-server` |
| jsx || || `typescript-language-server` |
| jsx || || `typescript-language-server` |
| julia || | | `julia` |
| kotlin || | | `kotlin-language-server` |
| latex || | | `texlab` |
Expand Down Expand Up @@ -97,9 +97,9 @@
| tfvars | | | | `terraform-ls` |
| toml || | | `taplo` |
| tsq || | | |
| tsx || | | `typescript-language-server` |
| tsx || | | `typescript-language-server` |
| twig || | | |
| typescript || || `typescript-language-server` |
| typescript || || `typescript-language-server` |
| ungrammar || | | |
| v || | | `vls` |
| vala || | | `vala-language-server` |
Expand Down
36 changes: 36 additions & 0 deletions runtime/queries/javascript/textobjects.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
(function_declaration
body: (_) @function.inside) @function.around

(function
body: (_) @function.inside) @function.around

(arrow_function
body: (_) @function.inside) @function.around

(method_definition
body: (_) @function.inside) @function.around

(generator_function_declaration
body: (_) @function.inside) @function.around

(class_declaration
body: (class_body) @class.inside) @class.around

(class
(class_body) @class.inside) @class.around

(export_statement
declaration: [
(function_declaration) @function.around
(class_declaration) @class.around
])

(formal_parameters
((_) @parameter.inside . ","? @parameter.around) @parameter.around)

(arguments
((_) @parameter.inside . ","? @parameter.around) @parameter.around)

(comment) @comment.inside

(comment)+ @comment.around
1 change: 1 addition & 0 deletions runtime/queries/jsx/textobjects.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
; inherits: javascript
1 change: 1 addition & 0 deletions runtime/queries/tsx/indents.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
; inherits: typescript
1 change: 1 addition & 0 deletions runtime/queries/tsx/textobjects.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
; inherits: typescript,jsx
8 changes: 8 additions & 0 deletions runtime/queries/typescript/textobjects.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
; inherits: javascript

[
(interface_declaration
body:(_) @class.inside)
(type_alias_declaration
value: (_) @class.inside)
] @class.around

0 comments on commit 681c0a9

Please sign in to comment.