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

`textobjects.move` errors when no Treesitter parser is available (should no-op like select)

Open Beginner friendly
#883 0 comments 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
nvim-treesitter-textobjects movement functions (e.g. goto_next_start) throw a Lua error when no Treesitter parser is available for the current buffer, instead of failing silently.

Selection textobjects (e.g. select_textobject) do not error in the same situation, which leads to inconsistent behavior within the plugin.


To Reproduce

  1. Open a filetype without an installed Treesitter parser (e.g. :e test.txt)
  2. Define a mapping using goto_next_start, e.g.:
vim.keymap.set('n', ']m', function()
  require('nvim-treesitter-textobjects.move')
    .goto_next_start('@function.outer', 'textobjects')
end)
  1. Press ]m
  2. Observe Lua error:
attempt to perform arithmetic on local 'score' (a nil value)

Expected behavior
Movement functions should behave like selection textobjects and fail silently / no-op when:

  • no Treesitter parser is available, or
  • no valid matches are found

They should not raise Lua errors.


Output of :checkhealth nvim-treesitter

(omitted / not relevant — issue occurs specifically when no parser is installed)


Output of nvim --version

NVIM v0.12.1
Build type: Release

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

Start with the nvim-treesitter-textobjects.move entry point and compare goto_next_start with the selection behavior described for select_textobject. Reproduce using the :e test.txt buffer and the mapping in the issue. Done means movement functions no-op without a parser or valid matches, without raising the reported Lua error.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.