Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
bf8d2ad
feat: modify behaviour of `@assignment.outer` so it includes keywords…
nik-rev Sep 8, 2024
a5c1cdb
feat(ecma): add support for @return.inner, @return.outer and @stateme…
nik-rev Sep 27, 2024
b1db8d5
feat(ecma): add `@function.*` capture for generator function (#689)
Juhan280 Sep 27, 2024
c1a6b12
fix(go): exclude braces for loops, conditions, class (#694)
ribru17 Sep 27, 2024
4a2d05e
docs: update queries in README (#693)
github-actions[bot] Sep 27, 2024
b91c98a
fix(lua): better @parameter.outer capture for fields
ribru17 Sep 27, 2024
5d6069b
feat(verilog): add queries (#678)
henrykvdb Oct 16, 2024
0d79d16
docs: update queries in README
Oct 16, 2024
3e450cd
docs: add `local` prefix for locals group to match upstream
Juhan280 Oct 25, 2024
ad8f0a4
fix(julia): adapt queries to parser changes
fredrikekre Nov 21, 2024
88fce4e
fix(ci): adapt to renamed nvim releases
clason Feb 17, 2025
8b4e32e
feat(lua): `@comment.inner` and `@statement.outer` (#728)
LionC Feb 28, 2025
ab0950c
docs: update queries in README (#735)
github-actions[bot] Feb 28, 2025
447ea2b
feat(svelte): add queries for template blocks (#737)
vnphanquang Mar 4, 2025
4fc5b1e
fix: offset_encoding is required now (#721)
rockyzhang24 Mar 4, 2025
9b261d4
Update @statement.outer query for Ecma to also include lexical declar…
zenshixd Mar 4, 2025
8b2d4d5
docs: update queries in README (#738)
github-actions[bot] Mar 4, 2025
a68af6f
feat(ocaml): Add OCaml queries (#723)
beajeanm Mar 8, 2025
143856b
docs: update queries in README (#740)
github-actions[bot] Mar 8, 2025
9937e5e
fix: typo `vim.api.util` to `vim.lsp.util` (#742)
carminecolucci Mar 17, 2025
698b5f8
fix (kotlin): textobj for bodyless class (#748)
alphashuro Apr 6, 2025
e4a71b4
fix: jsx attribute to use `@attribute.*` over `@parameter.*` (#751)
kiyoon Apr 15, 2025
205e336
docs: update queries in README (#752)
github-actions[bot] Apr 15, 2025
3ef4fd1
feat(toml): add `@comment.outer` (#755)
chrisgrieser Apr 27, 2025
ed37348
docs: update queries in README (#756)
github-actions[bot] Apr 27, 2025
1a28a77
feat(css): add `@comment.outer` (#757)
chrisgrieser May 7, 2025
0e3be38
docs: update queries in README (#758)
github-actions[bot] May 7, 2025
e10df91
feat(ecma): refine class.inner text object selection (#747)
Rayologist May 13, 2025
a7168a6
feat(enforce): add queries (#731)
simonvic May 13, 2025
ddb054f
feat(ecma): import statements (#759)
kiyoon May 13, 2025
b0debd5
docs: update queries in README (#760)
github-actions[bot] May 13, 2025
a91cd95
feat(ecma): list or object elements as `@paramter` (#763)
kiyoon May 19, 2025
379c0bc
feat(ecma): array pattern, obejct pattern as `@parameter`
kiyoon May 21, 2025
15f945e
refactor(ecma): remove unnecessary queries
kiyoon May 21, 2025
0f051e9
feat(rust): `array_expression` as `@parameter`, fix trailing comma at…
kiyoon May 23, 2025
89ebe73
feat(typescript): `type` and `interface` as `@parameter.*` (#779)
kiyoon Jun 14, 2025
71385f1
feat(java): add @return.inner & @return.outer text objects (#788)
gbroques Jul 29, 2025
d2bf609
Add Java support for `@statement.outer`
kezhenxu94 Oct 12, 2025
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
13 changes: 8 additions & 5 deletions .github/workflows/check_query_files.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Check loading of syntax files

on:
push:
pull_request:
schedule:
- cron: '0 0 * * *' # every day at midnight
Expand All @@ -10,6 +9,9 @@ jobs:
luacheck:
name: Check Query Files
runs-on: ubuntu-latest
env:
NVIM_TAG: stable
APPIMAGE: nvim-linux-x86_64.appimage
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand All @@ -20,19 +22,20 @@ jobs:
- name: Prepare
env:
NVIM_TAG: stable
APPIMAGE: nvim-linux-x86_64.appimage
run: |
sudo apt-get update && sudo apt-get install libfuse2
sudo add-apt-repository universe
wget https://github.com/neovim/neovim/releases/download/${NVIM_TAG}/nvim.appimage
chmod u+x nvim.appimage
wget https://github.com/neovim/neovim/releases/download/${NVIM_TAG}/${APPIMAGE}
chmod u+x ${APPIMAGE}
mkdir -p ~/.local/share/nvim/site/pack/nvim-treesitter-textobject/start
ln -s $(pwd) ~/.local/share/nvim/site/pack/nvim-treesitter-textobject/start
mkdir -p ~/.local/share/nvim/site/pack/nvim-treesitter/start
cd ~/.local/share/nvim/site/pack/nvim-treesitter/start
git clone https://github.com/nvim-treesitter/nvim-treesitter.git

- name: Compile parsers
run: ./nvim.appimage --headless -c "TSInstallSync all" -c "q"
run: ./${APPIMAGE} --headless -c "TSInstallSync all" -c "q"

- name: Check query files
run: ./nvim.appimage --headless -c "luafile ./scripts/check-queries.lua" -c "q"
run: ./${APPIMAGE} --headless -c "luafile ./scripts/check-queries.lua" -c "q"
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Linting and style checking

on: [push, pull_request]
on: pull_request

jobs:
luacheck:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: Tests

on:
push:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches:
- 'master'

Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/update-readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ jobs:
update-readme:
name: Update README.md
runs-on: ubuntu-latest
env:
APPIMAGE: nvim-linux-x86_64.appimage
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand All @@ -20,23 +22,23 @@ jobs:
run: |
sudo apt-get update && sudo apt-get install libfuse2
sudo add-apt-repository universe
wget https://github.com/neovim/neovim/releases/download/nightly/nvim.appimage
chmod u+x nvim.appimage
wget https://github.com/neovim/neovim/releases/download/nightly/${APPIMAGE}
chmod u+x ${APPIMAGE}
mkdir -p ~/.local/share/nvim/site/pack/nvim-treesitter-textobject/start
ln -s $(pwd) ~/.local/share/nvim/site/pack/nvim-treesitter-textobject/start
mkdir -p ~/.local/share/nvim/site/pack/nvim-treesitter/start
cd ~/.local/share/nvim/site/pack/nvim-treesitter/start
git clone https://github.com/nvim-treesitter/nvim-treesitter.git

- name: Compile parsers
run: ./nvim.appimage --headless -c "TSInstallSync all" -c "q"
run: ./${APPIMAGE} --headless -c "TSInstallSync all" -c "q"

# inspired by nvim-lspconfigs
- name: Check README
run: |
git config user.email "actions@github"
git config user.name "Github Actions"
./nvim.appimage --headless -c "luafile ./scripts/update-readme.lua" -c "q" || echo "Needs update"
./${APPIMAGE} --headless -c "luafile ./scripts/update-readme.lua" -c "q" || echo "Needs update"
git add README.md
git commit -m "docs: update queries in README" || echo 'No commit necessary!'
git clean -xf
Expand Down
26 changes: 16 additions & 10 deletions README.md

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion lua/nvim-treesitter/textobjects/lsp_interop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ function M.peek_definition_code(query_string, query_group, lsp_request, context)
if vim.tbl_contains(vim.api.nvim_list_wins(), floating_win) then
vim.api.nvim_set_current_win(floating_win)
else
local params = vim.lsp.util.make_position_params()
local win_id = vim.api.nvim_get_current_win()
local params = vim.fn.has "nvim-0.11" == 0 and vim.lsp.util.make_position_params()
or function(client)
return vim.lsp.util.make_position_params(win_id, client.offset_encoding)
end
return vim.lsp.buf_request(
0,
lsp_request,
Expand Down
12 changes: 9 additions & 3 deletions queries/apex/textobjects.scm
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@
] @comment.outer

; assignment
(variable_declarator
name: (identifier) @assignment.lhs
value: (_) @assignment.rhs) @assignment.inner @assignment.outer
(field_declaration
(variable_declarator
name: (identifier) @assignment.lhs
value: (_) @assignment.rhs) @assignment.inner) @assignment.outer

(local_variable_declaration
(variable_declarator
name: (identifier) @assignment.lhs
value: (_) @assignment.rhs) @assignment.inner) @assignment.outer
2 changes: 2 additions & 0 deletions queries/css/textobjects.scm
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@

(declaration
(property_name) @assignment.inner)

(comment) @comment.outer
197 changes: 160 additions & 37 deletions queries/ecma/textobjects.scm
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
(function_declaration
body: (statement_block)) @function.outer

(generator_function_declaration
body: (statement_block)) @function.outer

(function_expression
body: (statement_block)) @function.outer

Expand All @@ -15,6 +18,17 @@
"}"
(#make-range! "function.inner" @_start @_end)))

(generator_function_declaration
body: (statement_block
.
"{"
.
(_) @_start @_end
(_)? @_end
.
"}"
(#make-range! "function.inner" @_start @_end)))

(function_expression
body: (statement_block
.
Expand Down Expand Up @@ -58,7 +72,18 @@
(#make-range! "function.inner" @_start @_end)))

(class_declaration
body: (class_body) @class.inner) @class.outer
body: (class_body)) @class.outer

(class_declaration
body: (class_body
.
"{"
.
(_) @_start @_end
(_)? @_end
.
"}"
(#make-range! "class.inner" @_start @_end)))

(export_statement
(class_declaration)) @class.outer
Expand Down Expand Up @@ -182,39 +207,6 @@
","? @_end
(#make-range! "parameter.outer" @parameter.inner @_end))

; If the array/object pattern is the first parameter, treat its elements as the argument list
(formal_parameters
.
(_
[
(object_pattern
"," @_start
.
(_) @parameter.inner)
(array_pattern
"," @_start
.
(_) @parameter.inner)
])
(#make-range! "parameter.outer" @_start @parameter.inner))

(formal_parameters
.
(_
[
(object_pattern
.
(_) @parameter.inner
.
","? @_end)
(array_pattern
.
(_) @parameter.inner
.
","? @_end)
])
(#make-range! "parameter.outer" @parameter.inner @_end))

; arguments
(arguments
"," @_start
Expand All @@ -239,9 +231,10 @@
; number
(number) @number.inner

(variable_declarator
name: (_) @assignment.lhs
value: (_) @assignment.inner @assignment.rhs) @assignment.outer
(lexical_declaration
(variable_declarator
name: (_) @assignment.lhs
value: (_) @assignment.inner @assignment.rhs)) @assignment.outer

(variable_declarator
name: (_) @assignment.inner)
Expand All @@ -250,3 +243,133 @@
(pair
key: (_) @assignment.lhs
value: (_) @assignment.inner @assignment.rhs) @assignment.outer)

(return_statement
(_) @return.inner) @return.outer

(return_statement) @statement.outer

[
(if_statement)
(expression_statement)
(for_statement)
(while_statement)
(do_statement)
(for_in_statement)
(export_statement)
(lexical_declaration)
] @statement.outer

; 1. default import
(import_statement
(import_clause
(identifier) @parameter.inner @parameter.outer))

; 2. namespace import e.g. `* as React`
(import_statement
(import_clause
(namespace_import
(identifier) @parameter.inner) @parameter.outer))

; 3. named import e.g. `import { Bar, Baz } from ...`
(import_statement
(import_clause
(named_imports
(import_specifier) @parameter.inner)))

; 3‑A. named import followed by a comma
((import_statement
(import_clause
(named_imports
(import_specifier) @_start
.
"," @_end)))
(#make-range! "parameter.outer" @_start @_end))

; 3‑B. comma followed by named import
((import_statement
(import_clause
(named_imports
"," @_start
.
(import_specifier) @_end)))
(#make-range! "parameter.outer" @_start @_end))

; 3-C. only one named import without a comma
(import_statement
(import_clause
(named_imports
.
(import_specifier) @parameter.outer .)))

; Treat list or object elements as @parameter
; 1. parameter.inner
(object
(_) @parameter.inner)

(array
(_) @parameter.inner)

(object_pattern
(_) @parameter.inner)

(array_pattern
(_) @parameter.inner)

; 2. parameter.outer: Only one element, no comma
(object
.
(_) @parameter.outer .)

(array
.
(_) @parameter.outer .)

(object_pattern
.
(_) @parameter.outer .)

(array_pattern
.
(_) @parameter.outer .)

; 3. parameter.outer: Comma before or after
([
(object
"," @_start
.
(_) @_end)
(array
"," @_start
.
(_) @_end)
(object_pattern
"," @_start
.
(_) @_end)
(array_pattern
"," @_start
.
(_) @_end)
]
(#make-range! "parameter.outer" @_start @_end))

([
(object
(_) @_start
.
"," @_end)
(array
(_) @_start
.
"," @_end)
(object_pattern
(_) @_start
.
"," @_end)
(array_pattern
(_) @_start
.
"," @_end)
]
(#make-range! "parameter.outer" @_start @_end))
Loading
Loading