nvim-treesitter / nvim-treesitter/nvim-treesitter-textobjects

Rust @function.outer breaks with indentation

Open
#553 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Tree-sitter Query
Stars
2.8k
Forks
271
Avg merge
8d 8h
Merged PRs (30d)
1

Description

Describe the bug
@function.outer works when the function is defined in the first column, but breaks when indented.

To Reproduce
Steps to reproduce the behavior:
1.

impl Test {
    fn one() {
    }

    fn two() {
    }
}
  1. omap af *@<Cmd>lua require'nvim-treesitter.textobjects.select'.select_textobject('@function.outer','textobjects','o')<CR>
  2. gg0vaf
  3. It selects lines 2 through 5, including the fn two() {

Expected behavior
It should have selected lines 2 and 3, the first function

Output of :checkhealth nvim-treesitter

nvim-treesitter: require("nvim-treesitter.health").check()

Installation ~

  • WARNING tree-sitter executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
  • WARNING node executable not found (only needed for :TSInstallFromGrammar, not required for :TSInstall)
  • OK git executable found.
  • OK clang executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
    Version: clang version 17.0.5
  • OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

OS Info:
{
machine = "x86_64",
release = "10.0.22631",
sysname = "Windows_NT",
version = "Windows 11 Pro for Workstations"
} ~

Parser/Features H L F I J

  • c ✓ ✓ ✓ ✓ ✓
  • elixir ✓ ✓ ✓ ✓ ✓
  • heex ✓ ✓ ✓ ✓ ✓
  • html ✓ ✓ ✓ ✓ ✓
  • javascript ✓ ✓ ✓ ✓ ✓
  • lua ✓ ✓ ✓ ✓ ✓
  • markdown ✓ . ✓ ✓ ✓
  • query ✓ ✓ ✓ ✓ ✓
  • rust ✓ ✓ ✓ ✓ ✓
  • slang ✓ ✓ ✓ ✓ ✓
  • toml ✓ ✓ ✓ ✓ ✓
  • vim ✓ ✓ ✓ . ✓
  • vimdoc ✓ . . . ✓

Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
+) multiple parsers found, only one will be used
x) errors found in the query, try to run :TSUpdate {lang} ~

Output of nvim --version

NVIM v0.10.0-dev-2080+g92c59c39c
Build type: RelWithDebInfo
LuaJIT 2.1.1703358377

Additional context

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the provided Rust example and the omap af command, then inspect nvim-treesitter.textobjects.select and the @function.outer query or entry point it uses. Done means selecting the first function includes only lines 2 and 3 rather than extending through fn two().

Written by the indexing model from the issue text.

Assessment

Tech stack
lua, rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.