nvim-treesitter / nvim-treesitter/nvim-treesitter-textobjects
`textobjects.move` errors when no Treesitter parser is available (should no-op like select)
Nobody has claimed this yet.
- 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
- Open a filetype without an installed Treesitter parser (e.g.
:e test.txt) - 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)
- Press
]m - 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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