From b90ec5c77985bd444e7043fe738bb51b396ed496 Mon Sep 17 00:00:00 2001 From: Jaakko Paju Date: Sat, 17 Aug 2024 20:27:50 +0300 Subject: [PATCH] Add/improve textobject queries (#11513) * Add textobject queries for YAML * Add textobject queries for SQL * Add textobject queries for HOCON * Add textobject queries for git-config * Add textobject queries for env * Add textobject queries for Dockerfile * Add textobject queries for docker-compose * Add textobject queries for prisma * Add entry textobject queries for hcl * Add entry textobject queries for Nix * Update docs --- book/src/generated/lang-support.md | 16 ++++++++-------- runtime/queries/docker-compose/textobjects.scm | 1 + runtime/queries/dockerfile/textobjects.scm | 4 ++++ runtime/queries/env/textobjects.scm | 6 ++++++ runtime/queries/git-config/textobjects.scm | 6 ++++++ runtime/queries/hcl/textobjects.scm | 5 +++++ runtime/queries/hocon/textobjects.scm | 10 ++++++++++ runtime/queries/nix/textobjects.scm | 3 +++ runtime/queries/prisma/textobjects.scm | 17 +++++++++++++++++ runtime/queries/sql/textobjects.scm | 4 ++++ runtime/queries/yaml/textobjects.scm | 7 +++++++ 11 files changed, 71 insertions(+), 8 deletions(-) create mode 100644 runtime/queries/docker-compose/textobjects.scm create mode 100644 runtime/queries/dockerfile/textobjects.scm create mode 100644 runtime/queries/env/textobjects.scm create mode 100644 runtime/queries/git-config/textobjects.scm create mode 100644 runtime/queries/hocon/textobjects.scm create mode 100644 runtime/queries/prisma/textobjects.scm create mode 100644 runtime/queries/sql/textobjects.scm create mode 100644 runtime/queries/yaml/textobjects.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 4ce9edb9d..cb1c815f2 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -34,8 +34,8 @@ | devicetree | ✓ | | | | | dhall | ✓ | ✓ | | `dhall-lsp-server` | | diff | ✓ | | | | -| docker-compose | ✓ | | ✓ | `docker-compose-langserver`, `yaml-language-server` | -| dockerfile | ✓ | | | `docker-langserver` | +| docker-compose | ✓ | ✓ | ✓ | `docker-compose-langserver`, `yaml-language-server` | +| dockerfile | ✓ | ✓ | | `docker-langserver` | | dot | ✓ | | | `dot-language-server` | | dtd | ✓ | | | | | earthfile | ✓ | ✓ | ✓ | `earthlyls` | @@ -46,7 +46,7 @@ | elixir | ✓ | ✓ | ✓ | `elixir-ls` | | elm | ✓ | ✓ | | `elm-language-server` | | elvish | ✓ | | | `elvish` | -| env | ✓ | | | | +| env | ✓ | ✓ | | | | erb | ✓ | | | | | erlang | ✓ | ✓ | | `erlang_ls` | | esdl | ✓ | | | | @@ -61,7 +61,7 @@ | gherkin | ✓ | | | | | git-attributes | ✓ | | | | | git-commit | ✓ | ✓ | | | -| git-config | ✓ | | | | +| git-config | ✓ | ✓ | | | | git-ignore | ✓ | | | | | git-rebase | ✓ | | | | | gjs | ✓ | ✓ | ✓ | `typescript-language-server`, `vscode-eslint-language-server`, `ember-language-server` | @@ -83,7 +83,7 @@ | hcl | ✓ | ✓ | ✓ | `terraform-ls` | | heex | ✓ | ✓ | | `elixir-ls` | | helm | ✓ | | | `helm_ls` | -| hocon | ✓ | | ✓ | | +| hocon | ✓ | ✓ | ✓ | | | hoon | ✓ | | | | | hosts | ✓ | | | | | html | ✓ | | | `vscode-html-language-server` | @@ -158,7 +158,7 @@ | pod | ✓ | | | | | ponylang | ✓ | ✓ | ✓ | | | powershell | ✓ | | | | -| prisma | ✓ | | | `prisma-language-server` | +| prisma | ✓ | ✓ | | `prisma-language-server` | | prolog | | | | `swipl` | | protobuf | ✓ | ✓ | ✓ | `bufls`, `pb` | | prql | ✓ | | | | @@ -186,7 +186,7 @@ | sml | ✓ | | | | | solidity | ✓ | ✓ | | `solc` | | spicedb | ✓ | | | | -| sql | ✓ | | | | +| sql | ✓ | ✓ | | | | sshclientconfig | ✓ | | | | | starlark | ✓ | ✓ | | | | strace | ✓ | | | | @@ -228,6 +228,6 @@ | xit | ✓ | | | | | xml | ✓ | | ✓ | | | xtc | ✓ | | | | -| yaml | ✓ | | ✓ | `yaml-language-server`, `ansible-language-server` | +| yaml | ✓ | ✓ | ✓ | `yaml-language-server`, `ansible-language-server` | | yuck | ✓ | | | | | zig | ✓ | ✓ | ✓ | `zls` | diff --git a/runtime/queries/docker-compose/textobjects.scm b/runtime/queries/docker-compose/textobjects.scm new file mode 100644 index 000000000..4ba254e82 --- /dev/null +++ b/runtime/queries/docker-compose/textobjects.scm @@ -0,0 +1 @@ +; inherits: yaml diff --git a/runtime/queries/dockerfile/textobjects.scm b/runtime/queries/dockerfile/textobjects.scm new file mode 100644 index 000000000..975fd4c5e --- /dev/null +++ b/runtime/queries/dockerfile/textobjects.scm @@ -0,0 +1,4 @@ +(comment) @comment.inside + +(comment)+ @comment.around + diff --git a/runtime/queries/env/textobjects.scm b/runtime/queries/env/textobjects.scm new file mode 100644 index 000000000..4bdbf5ec7 --- /dev/null +++ b/runtime/queries/env/textobjects.scm @@ -0,0 +1,6 @@ +(comment) @comment.inside + +(comment)+ @comment.around + +(variable_assignment + (_) @entry.inside) @entry.around diff --git a/runtime/queries/git-config/textobjects.scm b/runtime/queries/git-config/textobjects.scm new file mode 100644 index 000000000..4335f1392 --- /dev/null +++ b/runtime/queries/git-config/textobjects.scm @@ -0,0 +1,6 @@ +(comment) @comment.inside + +(comment)+ @comment.around + +(variable + (_) @entry.inside) @entry.around diff --git a/runtime/queries/hcl/textobjects.scm b/runtime/queries/hcl/textobjects.scm index 1e6505876..c5ee4ff2d 100644 --- a/runtime/queries/hcl/textobjects.scm +++ b/runtime/queries/hcl/textobjects.scm @@ -4,3 +4,8 @@ (function_arguments ((_) @parameter.inside . ","? @parameter.around) @parameter.around) +(attribute + (_) @entry.inside) @entry.around + +(tuple + (_) @entry.around) diff --git a/runtime/queries/hocon/textobjects.scm b/runtime/queries/hocon/textobjects.scm new file mode 100644 index 000000000..aa4583933 --- /dev/null +++ b/runtime/queries/hocon/textobjects.scm @@ -0,0 +1,10 @@ +(comment) @comment.inside + +(comment)+ @comment.around + +(pair + (_) @entry.inside) @entry.around + +(array + (_) @entry.around) + diff --git a/runtime/queries/nix/textobjects.scm b/runtime/queries/nix/textobjects.scm index 1508d4c2b..196ef46cb 100644 --- a/runtime/queries/nix/textobjects.scm +++ b/runtime/queries/nix/textobjects.scm @@ -7,3 +7,6 @@ (function_expression body: (_) @function.inside) @function.around +(binding + (_) @entry.inside) @entry.around + diff --git a/runtime/queries/prisma/textobjects.scm b/runtime/queries/prisma/textobjects.scm new file mode 100644 index 000000000..a59ac221c --- /dev/null +++ b/runtime/queries/prisma/textobjects.scm @@ -0,0 +1,17 @@ +(model_declaration + ((statement_block) @class.inside)) @class.around + +(call_expression + (arguments (_) @parameter.inside . ","? @parameter.around) @parameter.around) + +(column_declaration) @entry.around + +(array (_) @entry.around) + +(assignment_expression + (_) @entry.inside) @entry.around + +(developer_comment) @comment.inside + +(developer_comment)+ @comment.around + diff --git a/runtime/queries/sql/textobjects.scm b/runtime/queries/sql/textobjects.scm new file mode 100644 index 000000000..975fd4c5e --- /dev/null +++ b/runtime/queries/sql/textobjects.scm @@ -0,0 +1,4 @@ +(comment) @comment.inside + +(comment)+ @comment.around + diff --git a/runtime/queries/yaml/textobjects.scm b/runtime/queries/yaml/textobjects.scm new file mode 100644 index 000000000..8b9bd0560 --- /dev/null +++ b/runtime/queries/yaml/textobjects.scm @@ -0,0 +1,7 @@ +(comment) @comment.inside + +(comment)+ @comment.around + +(block_mapping_pair + (_) @entry.inside) @entry.around +